Skip to content

pkg/registry/core/pod/storage: add PDB-specific CauseType to eviction forbidden errors#138003

Merged
k8s-ci-robot merged 3 commits intokubernetes:masterfrom
shady0503:add-pdb-cause-type-to-eviction-forbidden-errors
Apr 24, 2026
Merged

pkg/registry/core/pod/storage: add PDB-specific CauseType to eviction forbidden errors#138003
k8s-ci-robot merged 3 commits intokubernetes:masterfrom
shady0503:add-pdb-cause-type-to-eviction-forbidden-errors

Conversation

@shady0503
Copy link
Copy Markdown
Contributor

@shady0503 shady0503 commented Mar 24, 2026

What type of PR is this?

/kind feature
/kind api-change

What this PR does / why we need it:

When checkAndDecrement returns a Forbidden error due to negative DisruptionsAllowed or an oversized DisruptedPods map, clients had no programmatic way to distinguish these from other Forbidden errors without string-matching on the message.

This PR adds two new CauseType constants to policy/v1:

  • DisruptionBudgetNegativeAllowedDisruptions — for the DisruptionsAllowed < 0 case
  • DisruptionBudgetTooManyDisruptedPods — for the DisruptedPods map overflow case

And populates StatusCause on both Forbidden error paths in checkAndDecrement, consistent with the existing pattern already used on the TooManyRequests path via DisruptionBudgetCause.

Clients can now use errors.HasStatusCause(err, policyv1.DisruptionBudgetNegativeAllowedDisruptions) for reliable, typed, machine-readable error discrimination, no message parsing needed.

Which issue(s) this PR is related to:

Fixes #125500

Special notes:

The two new CauseType constants follow the same naming convention and placement as the existing DisruptionBudgetCause constant in staging/src/k8s.io/api/policy/v1/types.go. No codegen changes were required since CauseType is a string alias.

Does this PR introduce a user-facing change?

Added structured `CauseType` values to PodDisruptionBudget-related eviction `Forbidden` errors in the eviction API, allowing clients to programmatically distinguish PDB invalid-state errors from other forbidden errors without string-matching on the message.

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/feature Categorizes issue or PR as related to a new feature. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API labels Mar 24, 2026
@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla Bot commented Mar 24, 2026

CLA Signed

The committers listed above are authorized under a signed CLA.

@k8s-ci-robot k8s-ci-robot added the do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. label Mar 24, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Welcome @shady0503!

It looks like this is your first PR to kubernetes/kubernetes 🎉. 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/kubernetes 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 cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Mar 24, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Hi @shady0503. 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.

Details

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 needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. sig/apps Categorizes an issue or PR as relevant to SIG Apps. sig/auth Categorizes an issue or PR as relevant to SIG Auth. sig/node Categorizes an issue or PR as relevant to SIG Node. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Mar 24, 2026
@github-project-automation github-project-automation Bot moved this to Needs Triage in SIG Apps Mar 24, 2026
@k8s-ci-robot k8s-ci-robot requested a review from rphillips March 24, 2026 15:49
@k8s-ci-robot k8s-ci-robot requested a review from soltysh March 24, 2026 15:49
@shady0503 shady0503 force-pushed the add-pdb-cause-type-to-eviction-forbidden-errors branch from e678125 to 4a9fcf7 Compare March 24, 2026 15:52
@k8s-ci-robot k8s-ci-robot added 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 Mar 24, 2026
@shady0503
Copy link
Copy Markdown
Contributor Author

/easycla

@k8s-triage-robot
Copy link
Copy Markdown

This PR may require API review.

If so, when the changes are ready, complete the pre-review checklist and request an API review.

Status of requested reviews is tracked in the API Review project.

1 similar comment
@k8s-triage-robot
Copy link
Copy Markdown

This PR may require API review.

If so, when the changes are ready, complete the pre-review checklist and request an API review.

Status of requested reviews is tracked in the API Review project.

@shady0503
Copy link
Copy Markdown
Contributor Author

/label api-review

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Apr 20, 2026
@soltysh
Copy link
Copy Markdown
Contributor

soltysh commented Apr 20, 2026

/assign @tallclair
as a node approver

@shady0503
Copy link
Copy Markdown
Contributor Author

@tallclair PTAL, this needs approval for pkg/registry/core/pod when you have a moment. CI is green.

@liggitt
Copy link
Copy Markdown
Member

liggitt commented Apr 23, 2026

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. labels Apr 23, 2026
@k8s-ci-robot k8s-ci-robot added the do-not-merge/contains-merge-commits Indicates a PR which contains merge commits. label Apr 23, 2026
@shady0503 shady0503 force-pushed the add-pdb-cause-type-to-eviction-forbidden-errors branch from e44f4b8 to 3d4b0dd Compare April 23, 2026 17:45
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/contains-merge-commits Indicates a PR which contains merge commits. label Apr 23, 2026
…en errors

When checkAndDecrement returns a Forbidden error due to negative
DisruptionsAllowed or an oversized DisruptedPods map, clients had no
way to distinguish these from other Forbidden errors without
string-matching on the message.

Populate StatusCause with the existing DisruptionBudgetCause on both
Forbidden error paths, consistent with the existing pattern on the
TooManyRequests path.

Fixes: kubernetes#125500
@shady0503 shady0503 force-pushed the add-pdb-cause-type-to-eviction-forbidden-errors branch from 3d4b0dd to 507d980 Compare April 23, 2026 17:47
@shady0503
Copy link
Copy Markdown
Contributor Author

/retest

Copy link
Copy Markdown
Contributor

@soltysh soltysh left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 24, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

LGTM label has been added.

DetailsGit tree hash: c89dee988b3d0fafe155b5f25167669543a5fda6

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: atombrella, liggitt, shady0503, soltysh

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

The pull request process is described here

Details 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 merged commit e5657aa into kubernetes:master Apr 24, 2026
13 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.37 milestone Apr 24, 2026
@github-project-automation github-project-automation Bot moved this from In Review to Closed / Done in SIG Auth Apr 24, 2026
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/apps Categorizes an issue or PR as relevant to SIG Apps. sig/auth Categorizes an issue or PR as relevant to SIG Auth. sig/node Categorizes an issue or PR as relevant to SIG Node. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. triage/accepted Indicates an issue or PR is ready to be actively worked on.

Projects

Status: Done
Status: Closed / Done

Development

Successfully merging this pull request may close these issues.

Distinguish PDB error separately in eviction API

10 participants