Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

Improve controller error handling and logging. #42

Merged
merged 1 commit into from Sep 17, 2020

Conversation

dgoodwin
Copy link
Contributor

@dgoodwin dgoodwin commented Sep 4, 2020

Controller was ignoring errors creating/updating/deleting Applications
when it should be returning that error so the object is requeued with
backoff.

Fixed some inaccurate or messy logging.

@@ -135,18 +144,19 @@ func (r *ApplicationSetReconciler) createOrUpdateInCluster(ctx context.Context,
})

if err != nil {
appLog.WithError(err).Errorf("failed to %s Application", action)
appLog.WithError(err).WithField("action", action).Error("failed to create/update Application")
continue
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a flag to indicate if there were errors, and return the flag at the end of the function

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -167,12 +177,13 @@ func (r *ApplicationSetReconciler) deleteInCluster(ctx context.Context, applicat
err := r.Client.Delete(ctx, &app)
if err != nil {
appLog.WithError(err).Error("failed to delete Application")
continue
return err
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of stoping the loop, we can try to do the best effort, and continue to delete other applications. We can use a boolean flag to indicate if there was an error

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

It seems to make sense here. We should be careful with the concept of continuing after an error though as there could be some implications, if we applied the same concept up a level and decided to proceed with cleanup of obsolete apps after a failure creating a new one, something unintended could happen.

@xianlubird
Copy link
Member

Pls fix the conflict

Controller was ignoring errors creating/updating/deleting Applications
when it should be returning that error so the object is requeued with
backoff.

Fixed some inaccurate or messy logging.
@@ -57,6 +57,7 @@ func TestExtractApplications(t *testing.T) {
template argoprojiov1alpha1.ApplicationSetTemplate
generateParamsError error
rendererError error
expectErr bool
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per these changes we now expect these tests to do something differently, as we don't want to swallow an error, we want to return it and let the queue retry with backoff.

@dgoodwin
Copy link
Contributor Author

PR updated, conflict resolved, tests passing.

@xianlubird xianlubird merged commit dfb56ff into argoproj:master Sep 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants