Skip to content

Feature Request: Add terminationGracePeriodSeconds field in liveness probe #15823

Open

Description

@gane5hvarma

/area API
/kind good-first-issue
/kind spec

Describe the feature

The kubernetes pod spec allows us to mention terminationGracePeriodSeconds under livenessProbe for a specific container. This helps restarting a failed container. Current the knative service spec ignores this field.

docs for reference: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#probe-level-terminationgraceperiodseconds

My use case:
The liveness probe for the container fails and the container receives a sigterm. The container code went into a deadlock and doesnt respect gracefull shutdown. Now the container waits for pod terminationGracePeriodSeconds which is set by knative. This is taking around 300 second for the pod to restart. I dont want this to setting because of request timeout, but want the container to restart as soon as liveness probe fails.

Activity

  1. added
    area/APIAPI objects and controllers
    kind/good-first-issueDenotes an issue ready for a new contributor.
    kind/specDiscussion of how a feature should be exposed to customers.
    on Mar 31, 2025
  2. flomedja commented on Apr 7, 2025

    @flomedja
    Contributor

    This seems like a duplicate of #15599

  3. gane5hvarma commented on Apr 8, 2025

    @gane5hvarma
    Author

    Hi @flomedja this is not a duplicate of #15599. 15599 talks about deleting deployment and it talks about terminationGracePeriodSeconds in pod spec.
    This issue is about adding terminationGracePeriodSeconds in livenessProbe. This is need if the container get sigterm, it should restart as soon as possible. The pod wont be terminated.

  4. flomedja commented on Apr 8, 2025

    @flomedja
    Contributor

    My bad. I get it.

  5. gane5hvarma commented on Apr 14, 2025

    @gane5hvarma
    Author

    @flomedja what do you think of this feature?

  6. flomedja commented on Apr 18, 2025

    @flomedja
    Contributor

    @skonto @dprotaso Was there a specific reason for ignoring the terminationGracePeriodSeconds at the container level ?

  7. dprotaso commented on Apr 18, 2025

    @dprotaso
    Member

    So Knative by default sets the terminationGracePeriod to the revision's timeoutseconds. This handles the scenario where a request comes in around the time the pod is being terminated - thus we want to handle that request and not fail.

    The kubernetes pod spec allows us to mention terminationGracePeriodSeconds under livenessProbe for a specific container.

    I'm reading the K8s docs and I really don't see the motivation for this feature. Do you have a KEP link handy?

    The container code went into a deadlock and doesnt respect gracefull shutdown

    Which container? the queue proxy or the user's app?

  8. added
    triage/needs-user-inputIssues which are waiting on a response from the reporter
    triage/acceptedIssues which should be fixed (post-triage)
    and removed
    triage/needs-user-inputIssues which are waiting on a response from the reporter
    on Apr 18, 2025
  9. added this to the v1.19.0 milestone on Apr 18, 2025
  10. dprotaso commented on Apr 18, 2025

    @dprotaso
    Member

    Ok - I found the KEP and it explained the use

    https://github.com/kubernetes/enhancements/tree/master/keps/sig-node/2238-liveness-probe-grace-period#summary

    Yeah I think this makes sense to support.

    From the KEP the TerminationGracePeriod in the probe is used for abnormal termination when the liveness probes fail.

    The top-level TerminationGracePeriod is for normal shutdown.

  11. 11 remaining items

  12. modified the milestones: v1.19.0, v1.20.0 on Sep 3, 2025
  13. modified the milestones: v1.20.0, v1.21.0 on Nov 6, 2025
  14. linkvt commented on Nov 13, 2025

    @linkvt
    Member

    @flomedja are you still working on this issue? There is a commit referenced but not sure how complete it is.

    I would otherwise assign this issue myself to finalize it for the current milestone (we already missed 1.19 and 1.20).

  15. changminbark commented on Nov 15, 2025

    @changminbark

    @linkvt would it be okay if I take over? I want to contribute to knative and this was the only good-first-issue tagged issue there is.

  16. flomedja commented on Nov 15, 2025

    @flomedja
    Contributor

    @linkvt Sorry for the delay. I was waiting for an information from @dprotaso about the task and get sidetracked by some work afterwards.
    I will have a MR ready during this week.

  17. flomedja commented on Nov 21, 2025

    @flomedja
    Contributor

    @linkvt I pushed the MR. As requested by @dprotaso I add an issue #16256 for adding validation for startup probes.

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

Metadata

Metadata

Assignees

Labels

area/APIAPI objects and controllerskind/featureWell-understood/specified features, ready for coding.kind/good-first-issueDenotes an issue ready for a new contributor.kind/specDiscussion of how a feature should be exposed to customers.triage/acceptedIssues which should be fixed (post-triage)

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions