-
Notifications
You must be signed in to change notification settings - Fork 21
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
fix(labels): propagates labels to Deployment's spec.template #236
Open
bartoszmajsak
wants to merge
2
commits into
Kuadrant:main
Choose a base branch
from
bartoszmajsak:label-propagation-fix
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
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.
This works well for the inital creation of an
Authorino
CR but there's a few things missing that require some further consideration for this to work for if an existingAuthorino
CR labels is updated also:authorino-operator/controllers/authorino_controller.go
Line 134 in a92b462
authorino-operator/controllers/authorino_controller.go
Line 552 in a92b462
deployment.spec.matchLabels
which are immutable once set. Because these labels are immutable, the update will never succeed with an error from the API serverauthorino-operator/pkg/resources/k8s_deployment.go
Lines 17 to 19 in a92b462
podLabels
map of labels that contains the hardcodedauthorinoLabels
and theAuthorino
CR labels and use this in the deployment pod template. ThematchLabel
should always just use the hardcoded labels 🤔Authorino
CR can overwrite the hardcoded labels inlabelsForAuthorino
function, which then hit into 2) where the we attempt to update thedeployment.spec.matchLabels
. The hardcoded labels should take precedence in this case the prevent this 🤔authorino-operator/pkg/resources/k8s_util.go
Lines 13 to 18 in a92b462
Other considerations around upgrade are:
deployment.spec.template.labels
🤔. In this case, if the deployment is upgraded, any user added labels will be lost since only the labels currently present on theAuthorino
CR and the hardcoded labels is kept. We should do a "smart" merge of labels where:Authorino
CR labelsThis will however mean there's a wider scope of change as the desired deployment will need awareness of the existing deployment pod template labels
@eguzki Let me know if I've missed anything or if you have any thoughts on these suggestions.
@bartoszmajsak What are your thought on the above?
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.
These are all valid points. Thanks for your thorough analysis.
Do you want me to expand this PR based on this discussion or is something to be done as a follow-up? Happy to work on it either way.
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.
Personally, I think it would be nicer to exapnd this PR based on this discussion, especially for points 1 - 3 for accounting for updates.
However, If you feel the PR change would get too big though, I think the smart merge bit for upgrades can be done as follow-up/seperate PR. Let me know if you prefer this. Thanks for taking on this work 👍
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.
@KevFan some of it definitely belongs to this PR, so I will dig into it in the 2nd half of the week. I came purely from "create CR" angle and didn't consider all the other "what-ifs" :)