Git Product home page Git Product logo

Comments (8)

HirazawaUi avatar HirazawaUi commented on May 27, 2024 1

I think it's the change in #115835 that causes to break the original implementation of the feature.

Although we didn't explain it (preStopHook will not be executed when gracePeriod is 0) in Forced Pod termination and Container Lifecycle Hooks documentation.

I'll fix this and amend the documentation to state that preStopHook is not run when we force delete pod using --grace-period=0.

/triage accepted
/priority important-soon

from kubernetes.

axiang99 avatar axiang99 commented on May 27, 2024 1

I think it's the change in #115835 that causes to break the original implementation of the feature.

Although we didn't explain it (preStopHook will not be executed when gracePeriod is 0) in Forced Pod termination and Container Lifecycle Hooks documentation.

I'll fix this and amend the documentation to state that preStopHook is not run when we force delete pod using --grace-period=0.

/triage accepted /priority important-soon

Hi @HirazawaUi and all, I am also concerned about what the expected behavior is when the --force parameter is given.

  • Based on the description in document Container Lifecycle Hooks as below, my understanding is that the invocation of PreStop is unconditional:

PreStop

This hook is called immediately before a container is terminated due to an API request or management event such as a liveness/startup probe failure, preemption, resource contention, and others....

Btw, no changes on the statement from 1.25 to 1. 29.

  • In addition, in document pod-termination-forced it is said that "...still be given a small grace period before being force killed":

When a force deletion is performed, the API server does not wait for confirmation from the kubelet that the Pod has been terminated on the node it was running on. It removes the Pod in the API immediately so a new Pod can be created with the same name. On the node, Pods that are set to terminate immediately will still be given a small grace period before being force killed.

It is not mentioned that how long the “small grace period” is. Here I am just thinking that the behavior prior to fix implemented in #115835 did not align with this statement while the new behavior does, or at least to some extent.

Looking forward to clarification from the expert group.

Many thanks.

from kubernetes.

AxeZhan avatar AxeZhan commented on May 27, 2024

/cc

from kubernetes.

neolit123 avatar neolit123 commented on May 27, 2024

/sig node

from kubernetes.

HirazawaUi avatar HirazawaUi commented on May 27, 2024

Let me do some research.
/assign

from kubernetes.

HirazawaUi avatar HirazawaUi commented on May 27, 2024

In PR #115835, we use gracePeriodOverride to override gracePeriod before executing the preStop hook, which brings two destructive changes.

a). When the pod is force delete using --grace-period=0, we will not execute the preStop hook.
b). The result of the calculateEffectiveGracePeriod function will always be applied to the preStop hook.

For a, we should fix it, it breaks the original logic,
We always set a value greater than or equal to 1 for gracePeriod in the calculateEffectiveGracePeriod function.
ref:

// no matter what, we always supply a grace period of 1
if gracePeriod < 1 {
gracePeriod = 1
}

Although I saw an explanation for this behavior, I'm still curious as to why we need to set gracePeriod to 1, because I saw in killContainer that when gracePeriod is less than minimumGracePeriodInSeconds, we always set it to the value of minimumGracePeriodInSeconds
ref:

// always give containers a minimal shutdown window to avoid unnecessary SIGKILLs
if gracePeriod < minimumGracePeriodInSeconds {
gracePeriod = minimumGracePeriodInSeconds
}

For me, the solution to this issue is to have calculateEffectiveGracePeriod not set gracePeriod to a value greater than or equal to 1, or we don't override gracePeriod when pod.DeletionGracePeriodSeconds=0

For b, I think we did the right thing, but now there seems to be some bugs in the calculateEffectiveGracePeriod function (when the pod is evicted or force deleted, the value of terminationGracePeriodSeconds is used as the time to delete the pod). I have seen a PR in fix it, like: #119570

@smarterclayton @bobbypage May I ask if I'm right?

from kubernetes.

HirazawaUi avatar HirazawaUi commented on May 27, 2024

/remove-priority important-soon
/priority important-longterm

from kubernetes.

k8s-ci-robot avatar k8s-ci-robot commented on May 27, 2024

@HirazawaUi: The label(s) priority/ cannot be applied, because the repository doesn't have them.

In response to this:

/remove-priority important-soon
/priority important-longterm

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/test-infra repository.

from kubernetes.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.