-
Notifications
You must be signed in to change notification settings - Fork 524
Changed the order of CreateOrUpdate functions #1623
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
Conversation
if apiErrors.IsNotFound(err) { | ||
return getUpdateCreator.CreateConfigMap(ctx, cm) | ||
} else { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
This patch contains a number of improvements tried in order to deflake e2e tests. Overally result is quite successful: [100% green EVG](https://spruce.mongodb.com/version/66f81d4d24506900071e3563/tasks?sorts=STATUS%3AASC%3BBASE_STATUS%3ADESC) and progress with [flakes](https://ui.honeycomb.io/mongodb-4b/environments/production/result/8p2zFkfJ2Pz) Changes: - deleting kind clusters before creating kind clusters; controllable by new DELETE_KIND_NETWORK env, which is true only in EVG run (set in evg-private-context only). This one is actually of a dubious value as we're doing docker prune in teardown already. But it's useful also for our own evg hosts as we've never cleared docker network once created. - setting the subnet for docker network explicitly to 172.18.0.0/16. We hardcode usage of this subnet locally, and docker network in evg started to assign subnets on different IPs. That's why sometimes our "interconnected" tests were passing - when docker network created in evg got lucky subnet (172.18)! - added ttl and refresh to coredns config map - cannot harm, not sure if helps - changed the order of CreateOrUpdate to always update first and if 404 then create. Previously we had get first which was susceptible to not refreshed informers and CreateOrUpdate was going directly to Create which was failing. Details in [PR in MCO](mongodb/mongodb-kubernetes-operator#1623)
This patch contains a number of improvements tried in order to deflake e2e tests. Overally result is quite successful: [100% green EVG](https://spruce.mongodb.com/version/66f81d4d24506900071e3563/tasks?sorts=STATUS%3AASC%3BBASE_STATUS%3ADESC) and progress with [flakes](REDACTED) Changes: - deleting kind clusters before creating kind clusters; controllable by new DELETE_KIND_NETWORK env, which is true only in EVG run (set in evg-private-context only). This one is actually of a dubious value as we're doing docker prune in teardown already. But it's useful also for our own evg hosts as we've never cleared docker network once created. - setting the subnet for docker network explicitly to 172.18.0.0/16. We hardcode usage of this subnet locally, and docker network in evg started to assign subnets on different IPs. That's why sometimes our "interconnected" tests were passing - when docker network created in evg got lucky subnet (172.18)! - added ttl and refresh to coredns config map - cannot harm, not sure if helps - changed the order of CreateOrUpdate to always update first and if 404 then create. Previously we had get first which was susceptible to not refreshed informers and CreateOrUpdate was going directly to Create which was failing. Details in [PR in MCO](mongodb/mongodb-kubernetes-operator#1623)
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.