Skip to content

Commit

Permalink
fix: pass error to applyFailed events
Browse files Browse the repository at this point in the history
There was a bug where an error from an apply filter wasn't propagated to the applyFailed event, which leaded to printed events without error message set on them:
> {"group":"rbac.authorization.k8s.io","kind":"RoleBinding","name":"redacted","namespace":"redacted","status":"Failed","timestamp":"2022-12-21T12:43:46Z","type":"apply"}
  • Loading branch information
manfredlift committed Dec 21, 2022
1 parent 135cc3f commit 051eca7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/apply/task/apply_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"k8s.io/klog/v2"
"k8s.io/kubectl/pkg/cmd/apply"
cmddelete "k8s.io/kubectl/pkg/cmd/delete"

applyerror "sigs.k8s.io/cli-utils/pkg/apply/error"
"sigs.k8s.io/cli-utils/pkg/apply/event"
"sigs.k8s.io/cli-utils/pkg/apply/filter"
Expand Down Expand Up @@ -121,7 +122,7 @@ func (a *ApplyTask) Start(taskContext *taskrunner.TaskContext) {
// only log event emitted errors if the verbosity > 4
klog.Errorf("apply filter errored (filter: %s, object: %s): %v", applyFilter.Name(), id, fatalErr.Err)
}
taskContext.SendEvent(a.createApplyFailedEvent(id, err))
taskContext.SendEvent(a.createApplyFailedEvent(id, fatalErr))
taskContext.InventoryManager().AddFailedApply(id)
break
}
Expand Down

0 comments on commit 051eca7

Please sign in to comment.