-
Notifications
You must be signed in to change notification settings - Fork 4k
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(helm): Allow pdb minAvailable to take precedence over default max… #7139
Open
ParichayDidwania
wants to merge
4
commits into
kubernetes:master
Choose a base branch
from
ParichayDidwania:pdb-minavailable-precedence
base: master
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
4 commits
Select commit
Hold shift + click to select a range
640ee83
fix(helm): Allow pdb minAvailable to take precedence over default max…
ParichayDidwania 2481e73
Merge branch 'master' into pdb-minavailable-precedence
ParichayDidwania 1bd0e8d
Merge branch 'master' into pdb-minavailable-precedence
ParichayDidwania e02f665
Update Chart.yaml
ParichayDidwania 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
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.
I think having an
{{- else}}
block after{{- if .Values.podDisruptionBudget.minAvailable }}
here is simpler and equivalent to a separate{{- if and .Values.podDisruptionBudget.maxUnavailable (not .Values.podDisruptionBudget.minAvailable) }}
block.The way the current values.yaml data structure is implemented is sort of incorrect as a way to represent the podDisruptionBudget interface. See:
Especially:
I think this PR points towards an improvement in the existing solution, but FYI we're in a non-ideal place here, as we're essentially putting it on the users to understand that they're only allowed to use one or the other of the child properties of the
podDisruptionBudget
values object, and that if they do specify both thenminAvailable
will be preferred, andmaxUnavailable
will be ignored. (There isn't a great way to do runtime template error validation in helm AFAIK .)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.
cc @gjtempleton on that last part 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.
I have generally seen in other helm charts that they usually have the podDisruptionBudget block as empty in values.yaml. By default they set it off, and then allow the users to enter what they want.
Usually, when users enter both maxUnavailable and minAvailable together in such case, it will add both within the template instead of prioritizing one over above. Applying this generated template will then throw the error by kubernetes itself suggesting that only one of the 2 should be available. I think this is the correct way to go about it.
The reason I made it prioritize one of the two (maxUnavailable and minAvailable) and did not touch values.yaml was to ensure that it still works the same way for old users. But if that is not the case, then I can change the PR to make it how it should ideally be.
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.
Yeah, that all makes sense, and 💯 on making this back-compat for users.
Now that I think about it, maybe this is the most correct template solution:
If we do the above, if users declare both configuration flavors, it will be ignored by the template. I suppose this is not strictly back-compat, but the current template will not work in such a scenario anyways (I assume it will be rejected by apiserver webhook for the
PodDisruptionBudget
resource type).wdyt?
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.
Yes, the current template is rejected by the webhook if we declare both flavors. It is also rejected if i just add minAvailable in the override yaml file, because maxUnavailable is included by default in values.yaml.
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.
After thinking about this I think this is the best, back-compat way forward:
And then would need to get rid of the default in values.yaml. I don't think we can statically assign defaults to one or the other based on the mutually exclusive API requirements here; moving the defaults into the template in the above way should solve for that.
Thanks for your patience!
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.
@jackfrancis Having defaults in the template is not a good practice in my opinion. This is because, users will always go through the values.yaml and override things from there. Having default should be the job of values.yaml. If someone just turns the pdb on from override.values.yaml, they would automatically end up with maxUnavailable as 1. Helm should only be used for templatizing fields, not providing defaults.
According to me, we should keep the maxUnavailable in values.yaml for backward compatibility, and just provide a user with a choice to add maxUnavailable or minAvailable from the override.values.yaml. Even if they don't provide anything of the flavours, they would know that maxUnavailable: 1 is applied because that is the default value in values.yaml
What do you think?
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.
The problem here is that the values.yaml data interface doesn't support either/or property existence requirements.
How do we do the above exactly?
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.
@jackfrancis If we have this
along with maxUnavailable: 1 in values.yaml. The users will know that they can use override.values.yaml to choose the flavour they want.
They can simply set in the override, minAvailable: 1 to override the default maxUnavailable.
In the other case, they can either let it be default and explicitly specify maxUnavailable: 1 in order to get this flavor.
This way they have a choice.
Now, if they add both, the ideal scenario is to add both from our end and let the kubernetes API throw an error, but since we need to make it backward compatible, we can't do that. This is why, we prioritize one over the other. And since, maxUnavailable is present by default, we have to prioritize minAvailable.
The solution you provided will yield the same result as mine, except the maxUnavailable default value will be visible to users in values.yaml, where the users would expect it to be, and not inside the template itself.
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.
@jackfrancis Any update on this?