operator: Fix update of labels and annotations of PodTemplates #9860
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it:
While testing the zone-awareness PR I noticed that the labels and annotations on the pods did not disappear when I deactivated the zone-awareness again. This turned out to be an issue with how we generally update existing Deployments/StateFulSets: We merge the existing PodTemplateSpec with the desired one.
I don't think we need the merge at that point, because the operator should be the complete owner of that attribute, so we should be able to completely replace the values instead of merging with the existing one.
Which issue(s) this PR fixes:
Special notes for your reviewer:
The situation with the annotations and labels of our resources is a bit confusing. On one hand we have
mergeWithOverride
code at the beginning of theMutateFuncFor
function but on the other hand almost every one of the per-typemutate*
functions contains code that overwrites existing labels/annotations. I think it should be either one or the other.On a related note, maybe it makes sense to keep existing labels/annotations on the resources ("merging" them with the existing ones, but explicitly keep track of our labels/annotations, so that we remove our annotations/labels when they are not needed anymore but don't touch "other people's annotations/labels". This would make the merge code a bit longer though.
This PR remains a draft until the question about how to proceed with labels/annotations is cleared up.
Checklist
CONTRIBUTING.md
guide (required)