Skip to content

Commit

Permalink
Not always verify CR deletion event on cleanup
Browse files Browse the repository at this point in the history
Seek for FAR CR deletion event only when there isn't an API is not found error
  • Loading branch information
razo7 committed Jan 24, 2024
1 parent 89db554 commit be40de5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion controllers/fenceagentsremediation_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -582,16 +582,20 @@ func cleanupFar() func(ctx context.Context, far *v1alpha1.FenceAgentsRemediation
return err
}

var isCRNotFound bool
ConsistentlyWithOffset(1, func() error {
deleteErr := k8sClient.Get(ctx, client.ObjectKeyFromObject(far), cr)
if apierrors.IsNotFound(deleteErr) {
// when trying to create far CR with invalid name
log.Info("Cleanup: Got error 404", "name", cr.Name)
isCRNotFound = true
return nil
}
return deleteErr
}, pollInterval, timeoutPostRemediation).Should(BeNil(), "CR should be deleted")
verifyEvent(corev1.EventTypeNormal, utils.EventReasonRemoveRemediationCR, utils.EventMessageRemoveRemediationCR)
if !isCRNotFound {
verifyEvent(corev1.EventTypeNormal, utils.EventReasonRemoveRemediationCR, utils.EventMessageRemoveRemediationCR)
}
clearEvents()
return nil
}
Expand Down

0 comments on commit be40de5

Please sign in to comment.