Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed the order of CreateOrUpdate functions #1623

Merged
merged 2 commits into from
Sep 30, 2024
Merged

Conversation

lsierant
Copy link
Collaborator

This PR changes the way we do CreateOrUpdate functions.

It was: Get the Update if exists else Create.
For some cases after the resource was created in the same reconcile event, another execution will again hit into Create case as the informer caches weren't yet refreshed. And that resulted in errors.

@lsierant lsierant changed the title Changed the order or CreateOrUpdate functions Changed the order of CreateOrUpdate functions Sep 28, 2024
@lsierant lsierant merged commit a6075d4 into master Sep 30, 2024
49 of 50 checks passed
@lsierant lsierant deleted the fix-create-or-update branch September 30, 2024 08:32
if apiErrors.IsNotFound(err) {
return getUpdateCreator.CreateConfigMap(ctx, cm)
} else {
Copy link
Collaborator

Choose a reason for hiding this comment

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

i am a bit late to the party but we could have saved the else and just return, right?

Copy link
Collaborator

Choose a reason for hiding this comment

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

When I see such if/else I always wonder if I should leave a comment
Should we try to be consistent in the whole codebase about that ?
We use both currently

Copy link
Collaborator

Choose a reason for hiding this comment

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

we should add a linter for that and we should be fine. Problem: mco doesn't have that linter configured

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants