Skip to content

Conversation

@ParichayDidwania
Copy link
Contributor

@ParichayDidwania ParichayDidwania commented Aug 7, 2024

What type of PR is this?

/kind bug

What this PR does / why we need it:

Allow minAvailable to take precedence over default maxUnavailable in pdb of cluster-autoscaler helm chart

Which issue(s) this PR fixes:

Fixes #7128

Special notes for your reviewer:

Does this PR introduce a user-facing change?

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Aug 7, 2024
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Aug 7, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Aug 7, 2024
@k8s-ci-robot
Copy link
Contributor

Welcome @ParichayDidwania!

It looks like this is your first PR to kubernetes/autoscaler 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/autoscaler has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Aug 7, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @ParichayDidwania. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Aug 7, 2024
{{- if .Values.podDisruptionBudget.minAvailable }}
minAvailable: {{ .Values.podDisruptionBudget.minAvailable }}
{{- end }}
{{- if and .Values.podDisruptionBudget.maxUnavailable (not .Values.podDisruptionBudget.minAvailable) }}
Copy link
Contributor

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:

You can specify only one of maxUnavailable and minAvailable in a single PodDisruptionBudget.

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 then minAvailable will be preferred, and maxUnavailable will be ignored. (There isn't a great way to do runtime template error validation in helm AFAIK .)

Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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 then minAvailable will be preferred, and maxUnavailable will be ignored. (There isn't a great way to do runtime template error validation in helm AFAIK .)

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.

Copy link
Contributor

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 .Values.podDisruptionBudget.minAvailable and (not .Values.podDisruptionBudget.maxUnavailable) }}
  minAvailable: {{ .Values.podDisruptionBudget.minAvailable }}
  {{- end }}
  {{- if and .Values.podDisruptionBudget.maxUnavailable (not .Values.podDisruptionBudget.minAvailable) }}
  maxUnavailable: {{ .Values.podDisruptionBudget.maxUnavailable }}
  {{- end }}

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if you do not want {{- fail ... }} statements in code, i can put the check in notes and do the same check in deployment.yaml

Copy link
Contributor

Choose a reason for hiding this comment

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

I like the fail statement, failing fast is a feature not a bug IMO

Copy link
Contributor Author

Choose a reason for hiding this comment

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

cool, is there anything else you need apart from rebase, for approval?

Copy link
Contributor

Choose a reason for hiding this comment

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

nope, I'm good with this, thanks!

Copy link
Contributor Author

@ParichayDidwania ParichayDidwania Mar 8, 2025

Choose a reason for hiding this comment

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

are you waiting on something else before giving the approval?

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 24, 2024
@jackfrancis
Copy link
Contributor

/assign

@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 6, 2024
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 4, 2024
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Mark this PR as fresh with /remove-lifecycle stale
  • Close this PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Feb 2, 2025
@ParichayDidwania
Copy link
Contributor Author

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Feb 10, 2025
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 25, 2025
@ParichayDidwania ParichayDidwania force-pushed the pdb-minavailable-precedence branch from e02f665 to b806889 Compare March 5, 2025 00:58
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 5, 2025
Copy link
Contributor

@jackfrancis jackfrancis left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

thx @ParichayDidwania (for both this improvement and your patience)

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 13, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jackfrancis, ParichayDidwania

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 13, 2025
@k8s-ci-robot k8s-ci-robot merged commit 0a9528b into kubernetes:master Mar 13, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. area/helm-charts cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Helm] Allow minAvailable to take precedence over default maxUnavailable in pdb of cluster-autoscaler helm chart

4 participants