Skip to content

Commit

Permalink
fix: some missing changes
Browse files Browse the repository at this point in the history
Signed-off-by: Evsyukov Denis <[email protected]>

diff --git c/pkg/executor/executor.go i/pkg/executor/executor.go
index 2b4c1f4..56060ea 100644
--- c/pkg/executor/executor.go
+++ i/pkg/executor/executor.go
@@ -82,7 +82,9 @@ func NewExecutor(dir string, entrypoint string, args []string, envs []string) *E
 }

 func (e *Executor) Output() ([]byte, error) {
-	e.logger.Debug("Executing command", strings.Join(e.cmd.Args, " "), e.cmd.Dir)
+	e.logger.Debug("Executing command",
+		slog.String("command", strings.Join(e.cmd.Args, " ")),
+		slog.String("dir", e.cmd.Dir))
 	return e.cmd.Output()
 }

@@ -98,7 +100,9 @@ func (e *Executor) RunAndLogLines(logLabels map[string]string) (*CmdUsage, error
 	stdoutLogEntry := logEntry.With("output", "stdout")
 	stderrLogEntry := logEntry.With("output", "stderr")

-	log.Debug("Executing command", slog.String("command", strings.Join(e.cmd.Args, " ")), slog.String("dir", e.cmd.Dir))
+	log.Debug("Executing command",
+		slog.String("command", strings.Join(e.cmd.Args, " ")),
+		slog.String("dir", e.cmd.Dir))

 	plo := &proxyLogger{e.logProxyHookJSON, e.proxyJsonKey, stdoutLogEntry, make([]byte, 0)}
 	ple := &proxyLogger{e.logProxyHookJSON, e.proxyJsonKey, stderrLogEntry, make([]byte, 0)}
diff --git c/pkg/executor/executor_test.go i/pkg/executor/executor_test.go
index 7c707d0..04fa272 100644
--- c/pkg/executor/executor_test.go
+++ i/pkg/executor/executor_test.go
@@ -107,8 +107,8 @@ func TestRunAndLogLines(t *testing.T) {
 		_, err := ex.RunAndLogLines(map[string]string{"a": "b"})
 		assert.NoError(t, err)

-		assert.Equal(t, buf.String(), `{"level":"debug","msg":"json log line not map[string]interface{}","source":"executor/executor.go:173","a":"b","line":["a","b","c"],"output":"stdout","time":"2006-01-02T15:04:05Z"}`+"\n"+
-			`{"level":"info","msg":"[\"a\",\"b\",\"c\"]\n","source":"executor/executor.go:176","a":"b","output":"stdout","time":"2006-01-02T15:04:05Z"}`+"\n")
+		assert.Equal(t, buf.String(), `{"level":"debug","msg":"json log line not map[string]interface{}","source":"executor/executor.go:177","a":"b","line":["a","b","c"],"output":"stdout","time":"2006-01-02T15:04:05Z"}`+"\n"+
+			`{"level":"info","msg":"[\"a\",\"b\",\"c\"]\n","source":"executor/executor.go:180","a":"b","output":"stdout","time":"2006-01-02T15:04:05Z"}`+"\n")

 		buf.Reset()
 	})
diff --git c/pkg/hook/controller/conversion_bindings_controller.go i/pkg/hook/controller/conversion_bindings_controller.go
index 3975f82..a7920ef 100644
--- c/pkg/hook/controller/conversion_bindings_controller.go
+++ i/pkg/hook/controller/conversion_bindings_controller.go
@@ -84,7 +84,7 @@ func (c *ConversionBindingsController) CanHandleEvent(crdName string, _ *v1.Conv
 func (c *ConversionBindingsController) HandleEvent(crdName string, request *v1.ConversionRequest, rule conversion.Rule) BindingExecutionInfo {
 	_, hasKey := c.Links[crdName]
 	if !hasKey {
-		log.Error("Possible bug!!! No binding for conversion event for crd", slog.String("name", crdName))
+		log.Error("Possible bug!!! No binding for conversion event for crd", slog.String("crd", crdName))
 		return BindingExecutionInfo{
 			BindingContext: []bctx.BindingContext{},
 			AllowFailure:   false,
diff --git c/pkg/kube_events_manager/namespace_informer.go i/pkg/kube_events_manager/namespace_informer.go
index 2920641..a97c6bb 100644
--- c/pkg/kube_events_manager/namespace_informer.go
+++ i/pkg/kube_events_manager/namespace_informer.go
@@ -124,7 +124,7 @@ func (ni *namespaceInformer) start() {
 	log.Debug("Run namespace informer", slog.String("name", ni.Monitor.Metadata.DebugName))
 	if ni.SharedInformer == nil {
 		log.Error("Possible BUG!!! Start called before createSharedInformer, ShredInformer is nil",
-			slog.String("name", ni.Monitor.Metadata.DebugName))
+			slog.String("debugName", ni.Monitor.Metadata.DebugName))
 		return
 	}
 	cctx, cancel := context.WithCancel(ni.ctx)
@@ -140,10 +140,10 @@ func (ni *namespaceInformer) start() {
 		return ni.SharedInformer.HasSynced(), nil
 	}); err != nil {
 		ni.Monitor.Logger.Error("Cache is not synced for informer",
-			slog.String("name", ni.Monitor.Metadata.DebugName))
+			slog.String("debugName", ni.Monitor.Metadata.DebugName))
 	}

-	log.Debug("Informer is ready", slog.String("name", ni.Monitor.Metadata.DebugName))
+	log.Debug("Informer is ready", slog.String("debugName", ni.Monitor.Metadata.DebugName))
 }

 func (ni *namespaceInformer) pauseHandleEvents() {
diff --git c/pkg/kube_events_manager/resource_informer.go i/pkg/kube_events_manager/resource_informer.go
index 1307a1d..0da0991 100644
--- c/pkg/kube_events_manager/resource_informer.go
+++ i/pkg/kube_events_manager/resource_informer.go
@@ -117,11 +117,10 @@ func (ei *resourceInformer) createSharedInformer() error {
 	if ei.GroupVersionResource, err = ei.KubeClient.GroupVersionResource(ei.Monitor.ApiVersion, ei.Monitor.Kind); err != nil {
 		return fmt.Errorf("%s: Cannot get GroupVersionResource info for apiVersion '%s' kind '%s' from api-server. Possibly CRD is not created before informers are started. Error was: %w", ei.Monitor.Metadata.DebugName, ei.Monitor.ApiVersion, ei.Monitor.Kind, err)
 	}
-
-	log.Debug("%GVR for kind",
+	log.Debug("GVR for kind",
 		slog.String("debugName", ei.Monitor.Metadata.DebugName),
 		slog.String("kind", ei.Monitor.Kind),
-		slog.String("GVR", ei.GroupVersionResource.String()))
+		slog.String("gvr", ei.GroupVersionResource.String()))

 	// define tweakListOptions for informer
 	fmtLabelSelector, err := FormatLabelSelector(ei.Monitor.LabelSelector)
@@ -196,7 +195,7 @@ func (ei *resourceInformer) loadExistedObjects() error {
 		Namespace(ei.Namespace).
 		List(context.TODO(), ei.ListOptions)
 	if err != nil {
-		log.Error("%s: initial list resources of kind '%s': %v",
+		log.Error("initial list resources of kind",
 			slog.String("debugName", ei.Monitor.Metadata.DebugName),
 			slog.String("kind", ei.Monitor.Kind),
 			log.Err(err))
diff --git c/pkg/task/queue/task_queue.go i/pkg/task/queue/task_queue.go
index 54c0fab..44e64bc 100644
--- c/pkg/task/queue/task_queue.go
+++ i/pkg/task/queue/task_queue.go
@@ -384,7 +384,7 @@ func (q *TaskQueue) debugf(format string, args ...interface{}) {
 	if !q.debug {
 		return
 	}
-	log.Debug("", fmt.Sprintf(format, args...))
+	log.Debug("DEBUG", fmt.Sprintf(format, args...))
 }

 func (q *TaskQueue) Stop() {
  • Loading branch information
juev committed Dec 20, 2024
1 parent 0b20110 commit 6894922
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 13 deletions.
8 changes: 6 additions & 2 deletions pkg/executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ func NewExecutor(dir string, entrypoint string, args []string, envs []string) *E
}

func (e *Executor) Output() ([]byte, error) {
e.logger.Debug("Executing command", strings.Join(e.cmd.Args, " "), e.cmd.Dir)
e.logger.Debug("Executing command",
slog.String("command", strings.Join(e.cmd.Args, " ")),
slog.String("dir", e.cmd.Dir))
return e.cmd.Output()
}

Expand All @@ -98,7 +100,9 @@ func (e *Executor) RunAndLogLines(logLabels map[string]string) (*CmdUsage, error
stdoutLogEntry := logEntry.With("output", "stdout")
stderrLogEntry := logEntry.With("output", "stderr")

log.Debug("Executing command", slog.String("command", strings.Join(e.cmd.Args, " ")), slog.String("dir", e.cmd.Dir))
log.Debug("Executing command",
slog.String("command", strings.Join(e.cmd.Args, " ")),
slog.String("dir", e.cmd.Dir))

plo := &proxyLogger{e.logProxyHookJSON, e.proxyJsonKey, stdoutLogEntry, make([]byte, 0)}
ple := &proxyLogger{e.logProxyHookJSON, e.proxyJsonKey, stderrLogEntry, make([]byte, 0)}
Expand Down
4 changes: 2 additions & 2 deletions pkg/executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ func TestRunAndLogLines(t *testing.T) {
_, err := ex.RunAndLogLines(map[string]string{"a": "b"})
assert.NoError(t, err)

assert.Equal(t, buf.String(), `{"level":"debug","msg":"json log line not map[string]interface{}","source":"executor/executor.go:173","a":"b","line":["a","b","c"],"output":"stdout","time":"2006-01-02T15:04:05Z"}`+"\n"+
`{"level":"info","msg":"[\"a\",\"b\",\"c\"]\n","source":"executor/executor.go:176","a":"b","output":"stdout","time":"2006-01-02T15:04:05Z"}`+"\n")
assert.Equal(t, buf.String(), `{"level":"debug","msg":"json log line not map[string]interface{}","source":"executor/executor.go:177","a":"b","line":["a","b","c"],"output":"stdout","time":"2006-01-02T15:04:05Z"}`+"\n"+
`{"level":"info","msg":"[\"a\",\"b\",\"c\"]\n","source":"executor/executor.go:180","a":"b","output":"stdout","time":"2006-01-02T15:04:05Z"}`+"\n")

buf.Reset()
})
Expand Down
2 changes: 1 addition & 1 deletion pkg/hook/controller/conversion_bindings_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (c *ConversionBindingsController) CanHandleEvent(crdName string, _ *v1.Conv
func (c *ConversionBindingsController) HandleEvent(crdName string, request *v1.ConversionRequest, rule conversion.Rule) BindingExecutionInfo {
_, hasKey := c.Links[crdName]
if !hasKey {
log.Error("Possible bug!!! No binding for conversion event for crd", slog.String("name", crdName))
log.Error("Possible bug!!! No binding for conversion event for crd", slog.String("crd", crdName))
return BindingExecutionInfo{
BindingContext: []bctx.BindingContext{},
AllowFailure: false,
Expand Down
6 changes: 3 additions & 3 deletions pkg/kube_events_manager/namespace_informer.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func (ni *namespaceInformer) start() {
log.Debug("Run namespace informer", slog.String("name", ni.Monitor.Metadata.DebugName))
if ni.SharedInformer == nil {
log.Error("Possible BUG!!! Start called before createSharedInformer, ShredInformer is nil",
slog.String("name", ni.Monitor.Metadata.DebugName))
slog.String("debugName", ni.Monitor.Metadata.DebugName))
return
}
cctx, cancel := context.WithCancel(ni.ctx)
Expand All @@ -140,10 +140,10 @@ func (ni *namespaceInformer) start() {
return ni.SharedInformer.HasSynced(), nil
}); err != nil {
ni.Monitor.Logger.Error("Cache is not synced for informer",
slog.String("name", ni.Monitor.Metadata.DebugName))
slog.String("debugName", ni.Monitor.Metadata.DebugName))
}

log.Debug("Informer is ready", slog.String("name", ni.Monitor.Metadata.DebugName))
log.Debug("Informer is ready", slog.String("debugName", ni.Monitor.Metadata.DebugName))
}

func (ni *namespaceInformer) pauseHandleEvents() {
Expand Down
7 changes: 3 additions & 4 deletions pkg/kube_events_manager/resource_informer.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,10 @@ func (ei *resourceInformer) createSharedInformer() error {
if ei.GroupVersionResource, err = ei.KubeClient.GroupVersionResource(ei.Monitor.ApiVersion, ei.Monitor.Kind); err != nil {
return fmt.Errorf("%s: Cannot get GroupVersionResource info for apiVersion '%s' kind '%s' from api-server. Possibly CRD is not created before informers are started. Error was: %w", ei.Monitor.Metadata.DebugName, ei.Monitor.ApiVersion, ei.Monitor.Kind, err)
}

log.Debug("%GVR for kind",
log.Debug("GVR for kind",
slog.String("debugName", ei.Monitor.Metadata.DebugName),
slog.String("kind", ei.Monitor.Kind),
slog.String("GVR", ei.GroupVersionResource.String()))
slog.String("gvr", ei.GroupVersionResource.String()))

// define tweakListOptions for informer
fmtLabelSelector, err := FormatLabelSelector(ei.Monitor.LabelSelector)
Expand Down Expand Up @@ -196,7 +195,7 @@ func (ei *resourceInformer) loadExistedObjects() error {
Namespace(ei.Namespace).
List(context.TODO(), ei.ListOptions)
if err != nil {
log.Error("%s: initial list resources of kind '%s': %v",
log.Error("initial list resources of kind",
slog.String("debugName", ei.Monitor.Metadata.DebugName),
slog.String("kind", ei.Monitor.Kind),
log.Err(err))
Expand Down
2 changes: 1 addition & 1 deletion pkg/task/queue/task_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ func (q *TaskQueue) debugf(format string, args ...interface{}) {
if !q.debug {
return
}
log.Debug("", fmt.Sprintf(format, args...))
log.Debug("DEBUG", fmt.Sprintf(format, args...))
}

func (q *TaskQueue) Stop() {
Expand Down

0 comments on commit 6894922

Please sign in to comment.