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]>
  • Loading branch information
juev committed Dec 17, 2024
1 parent 2a745f2 commit fe5d0ba
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ linters:
- depguard
- dogsled
- durationcheck
- exportloopref
- copyloopvar
- gci
- gochecknoinits
- gocritic
Expand Down
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
6 changes: 3 additions & 3 deletions pkg/kube_events_manager/resource_informer.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ func (ei *resourceInformer) createSharedInformer() (err error) {
log.Err(err))
return 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 @@ -201,7 +201,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 @@ -365,7 +365,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 fe5d0ba

Please sign in to comment.