Visitar URL original
kubelet parameter(eviction-max-pod-grace-period ), not work as expected like officical comment. · Issue #118172 · kubernetes/kubernetes · GitHub
Skip to content

kubelet parameter(eviction-max-pod-grace-period ), not work as expected like officical comment. #118172

Open

Description

@rainbowBPF2

What happened?

Hey brothers , feedback a confusing point about kubelet soft eviction:

Just like kubelet --help show:
--eviction-max-pod-grace-period int32 Maximum allowed grace period (in seconds) to use when terminating pods in response to a soft eviction threshold being met. If negative, defer to pod specified value.

I guess if this parameter is set to negative ,such as -1, soft eviction would use pod specified value(TerminationGracePeriodSeconds),

But When I try to evict pod by creating node pressure(such as memory pressure), I found it's always -1 send to CRI runtime.
Then pod container stopped immediately with sigkill, exit 137.

In short, this parameter:
(1)set as active number:work as expected;
(2)no set, kubelet read its default number:0, work as expected;
(3)set as negative number: not work as kubelet help show.

Thanks for your response. May it be a bug ?

What did you expect to happen?

--eviction-max-pod-grace-period set to negative, then kubelet syncPod logic send pod‘s TerminationGracePeriodSeconds as gracePeriod to CRI runtime to stop container.

How can we reproduce it (as minimally and precisely as possible)?

(1) set this parameter to a negative number, such as -1;
(2) config kubelet soft eviction ;
(3) running a pod asking a lot memory , to trigger node memory pressure;
(4) check CRI runtime log, such as containerd ;
(5) then you will find timeout parameter -1 sent to pod container , then container exit with code 137(sigkill);

Anything else we need to know?

I running these tests on Tencent Cloud TKE.

And I thought it seem not related to Cloud Service Provider.

Kubernetes version

Details

Client Version: version.Info{Major:"1", Minor:"16+", GitVersion:"v1.16.3-tke.34", GitCommit:"61cc96d2f7e9277e89e29b4b04d045f27d6e75df", GitTreeState:"clean", BuildDate:"2023-03-08T07:40:04Z", GoVersion:"go1.12.17", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"16+", GitVersion:"v1.16.3-tke.32", GitCommit:"8ca5807ae095365d68754a2ba20b10bbe5a8998c", GitTreeState:"clean", BuildDate:"2022-10-08T04:00:33Z", GoVersion:"go1.12.14", Compiler:"gc", Platform:"linux/amd64"}

Cloud provider

Details Tencent Cloud TKE

OS version

Details AME="Ubuntu" VERSION="18.04.4 LTS (Bionic Beaver)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 18.04.4 LTS" VERSION_ID="18.04" HOME_URL="https://www.ubuntu.com/" SUPPORT_URL="https://help.ubuntu.com/" BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" VERSION_CODENAME=bionic UBUNTU_CODENAME=bionic

Install tools

Details

Container runtime (CRI) and version (if applicable)

Details

containerd --version
containerd github.com/containerd/containerd v1.4.3-tke.2 a11500cbfa0b4d2fc9b905e03c35f349ef5b1a9f

Related plugins (CNI, CSI, ...) and versions (if applicable)

Details

Activity

  1. added
    needs-sigIndicates an issue or PR lacks a `sig/foo` label and requires one.
    needs-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.
    on May 22, 2023
  2. tzneal commented on May 22, 2023

    @tzneal
    Contributor

    /sig node

  3. added
    sig/nodeCategorizes an issue or PR as relevant to SIG Node.
    and removed
    needs-sigIndicates an issue or PR lacks a `sig/foo` label and requires one.
    on May 22, 2023
  4. SergeyKanzhelev commented on May 24, 2023

    @SergeyKanzhelev
    Member

    /triage accepted

    The question is whether we fix code and make the backward incompatible change or fix a doc. I'd vote for a doc change which is less work. But blocks an interesting scenarios.

    @rainbowBPF2 were you looking for the described behavior? Does your scenario requires this?

    /priority important-longterm

  5. added
    triage/acceptedIndicates an issue or PR is ready to be actively worked on.
    priority/important-longtermImportant over the long term, but may not be staffed and/or may need multiple releases to complete.
    and removed
    needs-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.
    on May 24, 2023
  6. rainbowBPF2 commented on May 25, 2023

    @rainbowBPF2
    Author

    @SergeyKanzhelev

    Thanks for brothers‘ attention on this point.

    1. For daily business running, temporarily no bad effects, and seems not required. Doc change is also a choice.
    2. But look at it in the long run, it will be an amazing/exciting feature.
      Because we have a more reasonable choice to terminate pods in case of soft-eviction, to realize Pod-Graceful-Shutdown

    In short,no required but deep expected, 😄。

  7. fgksgf commented on May 25, 2023

    @fgksgf

    /assign

  8. k8s-triage-robot commented on May 24, 2024

    @k8s-triage-robot

    This issue has not been updated in over 1 year, and should be re-triaged.

    You can:

    • Confirm that this issue is still relevant with /triage accepted (org members only)
    • Close this issue with /close

    For more details on the triage process, see https://www.kubernetes.dev/docs/guide/issue-triage/

    /remove-triage accepted

  9. added
    needs-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.
    on May 24, 2024
  10. 54 remaining items

  11. frank-bee commented on Mar 11, 2026

    @frank-bee

    A fix for this issue has been submitted in PR #137624.

    The bug was in pkg/kubelet/eviction/eviction_manager.go: the soft eviction path used min(MaxPodGracePeriodSeconds, podGracePeriod), which when MaxPodGracePeriodSeconds=-1 always evaluated to -1. The CRI runtime then received -1 and immediately SIGKILLed the container (exit code 137), ignoring terminationGracePeriodSeconds entirely.

    The fix checks for a negative value first and defers to the pod's own TerminationGracePeriodSeconds (or the default 30s if unset), matching the documented flag behavior.

  12. SergeyKanzhelev commented on Mar 24, 2026

    @SergeyKanzhelev
    Member

    A fix for this issue has been submitted in PR #137624.

    Can you please read the top of the thread and comment on how to address backward incompatibility of the code fix. This issue needs to build the case: why code fix is better, what is the worst case scenario of breaking existing behavior for customers, and how can the backward incompatibility be mitigated

  13. nimdrak commented on Mar 25, 2026

    @nimdrak

    Hi @SergeyKanzhelev,

    Could you please take a look at this PR when you have a moment?

    It clarifies the Kubelet help text and docs for --eviction-max-pod-grace-period to match the actual behavior. You’ve already given it a LGTM, but it still needs a formal /approve to move forward from another.

    I’ve tried reaching out on Slack and mentioning others, but haven't had any luck yet.
    I’d appreciate your help in getting this merged!

    If it is merged, we can close this issue.

  14. kunalworldwide commented on May 26, 2026

    @kunalworldwide

    @SergeyKanzhelev re the hold on #137624 — trying to answer the backward-compat question.

    The operators most likely affected are anyone using -1 as a "just SIGKILL it immediately" shortcut during soft eviction. It's not documented that way, but I've seen it used like that in practice — memory pressure situations where people don't want pods hanging around. After this fix, those pods would hang for up to terminationGracePeriodSeconds before terminating, which could be a real surprise under pressure.

    Two ways to handle that:

    • Feature gate it (EvictionNegativeGracePeriodFix, off by default for one release) so people have time to adapt
    • Or just a release note pointing out the behavior change + "use 0 if you want SIGKILL behavior"

    Personally the flag is documented to mean "defer to pod value" so the current behavior is already a bug, not a feature. A release note feels proportionate. But if the concern is that enough clusters are relying on the current broken behavior, a feature gate is the safer path.

    Does that cover what you were looking for, or is there a specific scenario I'm missing?

  15. neoLsH commented on Aug 24, 2026

    @neoLsH
    Contributor

    /assign

  16. Hariharanpugazh commented on Sep 1, 2026

    @Hariharanpugazh

    /assign

  17. reetig commented on Sep 28, 2026

    @reetig

    /assign

  18. kubernetes-prow commented on Sep 28, 2026

    @kubernetes-prow
    Contributor

    @reetig: GitHub didn't allow me to assign the following users: reetig.

    Note that only kubernetes members with read permissions, repo collaborators and people who have commented on this issue/PR can be assigned. Additionally, issues/PRs can only have 10 assignees at the same time.
    For more information please see the contributor guide

    Details

    In response to this:

    /assign

    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.

  19. Hariharanpugazh commented on Sep 29, 2026

    @Hariharanpugazh

    Opened #142504 to fix this. When --eviction-max-pod-grace-period is negative, soft eviction now defers to the pod's terminationGracePeriodSeconds (or the 30s default), instead of sending the negative value to the CRI and triggering an immediate SIGKILL.

    On the backward-compat question raised earlier: the only behavior that changes is for clusters relying on a negative value as an "immediate kill" shortcut, which contradicts the documented flag contract. I've added a release note; happy to add a feature gate for one release if that's the preferred rollout. Regression tests included (they fail on the current code and pass with the fix).

  20. kpdagrt22 commented on Oct 6, 2026

    @kpdagrt22

    /assign

  21. kubernetes-prow commented on Oct 6, 2026

    @kubernetes-prow
    Contributor

    @kpdagrt22: GitHub didn't allow me to assign the following users: kpdagrt22.

    Note that only kubernetes members with read permissions, repo collaborators and people who have commented on this issue/PR can be assigned. Additionally, issues/PRs can only have 10 assignees at the same time.
    For more information please see the contributor guide

    Details

    In response to this:

    /assign

    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.

  22. kpdagrt22 commented on Oct 6, 2026

    @kpdagrt22

    I have reproduced this locally (min(-1, podGrace) passes -1 to CRI) and opened #142714 with a fix plus unit test. The issue is at the 10-assignee cap so /assign could not apply; requesting a review when possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

good first issueDenotes an issue ready for a new contributor, according to the "help wanted" guidelines.help wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.kind/bugCategorizes issue or PR as related to a bug.kind/documentationCategorizes issue or PR as related to documentation.priority/backlogHigher priority than priority/awaiting-more-evidence.priority/important-longtermImportant over the long term, but may not be staffed and/or may need multiple releases to complete.sig/nodeCategorizes an issue or PR as relevant to SIG Node.triage/acceptedIndicates an issue or PR is ready to be actively worked on.

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions