Skip to content

Commit

Permalink
fix: Send Failed status when erroring
Browse files Browse the repository at this point in the history
- Caller should switch on Type == Failed, not Error != nil
- Error should always be non-nil for Failed and Skipped events
  • Loading branch information
karlkfi committed Apr 20, 2022
1 parent 825458e commit 119b51a
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions pkg/apply/prune/event-factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func (pef PruneEventFactory) CreateFailedEvent(id object.ObjMetadata, err error)
Type: event.PruneType,
PruneEvent: event.PruneEvent{
GroupName: pef.groupName,
Status: event.PruneFailed,
Identifier: id,
Error: err,
},
Expand Down Expand Up @@ -110,6 +111,7 @@ func (def DeleteEventFactory) CreateFailedEvent(id object.ObjMetadata, err error
Type: event.DeleteType,
DeleteEvent: event.DeleteEvent{
GroupName: def.groupName,
Status: event.DeleteFailed,
Identifier: id,
Error: err,
},
Expand Down
2 changes: 2 additions & 0 deletions pkg/apply/prune/prune_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,7 @@ func TestPruneWithErrors(t *testing.T) {
EventType: event.PruneType,
PruneEvent: &testutil.ExpPruneEvent{
Identifier: object.UnstructuredToObjMetadata(pdbDeleteFailure),
Status: event.PruneFailed,
Error: fmt.Errorf("expected delete error"),
},
},
Expand All @@ -710,6 +711,7 @@ func TestPruneWithErrors(t *testing.T) {
EventType: event.DeleteType,
DeleteEvent: &testutil.ExpDeleteEvent{
Identifier: object.UnstructuredToObjMetadata(pdbDeleteFailure),
Status: event.DeleteFailed,
Error: fmt.Errorf("expected delete error"),
},
},
Expand Down
1 change: 1 addition & 0 deletions pkg/apply/task/apply_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ func (a *ApplyTask) createApplyFailedEvent(id object.ObjMetadata, err error) eve
ApplyEvent: event.ApplyEvent{
GroupName: a.Name(),
Identifier: id,
Status: event.ApplyFailed,
Error: err,
},
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/apply/task/apply_task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,8 @@ func TestApplyTaskWithError(t *testing.T) {
{
Type: event.ApplyType,
ApplyEvent: event.ApplyEvent{
Error: fmt.Errorf("expected apply error"),
Status: event.ApplyFailed,
Error: fmt.Errorf("expected apply error"),
},
},
},
Expand Down
1 change: 1 addition & 0 deletions test/e2e/continue_on_error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ func continueOnErrorTest(ctx context.Context, c client.Client, invConfig invconf
EventType: event.ApplyType,
ApplyEvent: &testutil.ExpApplyEvent{
GroupName: "apply-0",
Status: event.ApplyFailed,
Identifier: object.UnstructuredToObjMetadata(invalidCrdObj),
Error: testutil.EqualErrorType(
applyerror.NewApplyRunError(errors.New("failed to apply")),
Expand Down

0 comments on commit 119b51a

Please sign in to comment.