You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Feature Request: Add terminationGracePeriodSeconds field in liveness probe #15823
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.
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.
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.
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?
@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.
Activity
flomedja commentedon Apr 7, 2025
This seems like a duplicate of #15599
gane5hvarma commentedon Apr 8, 2025
Hi @flomedja this is not a duplicate of #15599. 15599 talks about deleting deployment and it talks about
terminationGracePeriodSecondsin pod spec.This issue is about adding
terminationGracePeriodSecondsin livenessProbe. This is need if the container get sigterm, it should restart as soon as possible. The pod wont be terminated.flomedja commentedon Apr 8, 2025
My bad. I get it.
gane5hvarma commentedon Apr 14, 2025
@flomedja what do you think of this feature?
flomedja commentedon Apr 18, 2025
@skonto @dprotaso Was there a specific reason for ignoring the
terminationGracePeriodSecondsat the container level ?dprotaso commentedon Apr 18, 2025
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.
I'm reading the K8s docs and I really don't see the motivation for this feature. Do you have a KEP link handy?
Which container? the queue proxy or the user's app?
dprotaso commentedon Apr 18, 2025
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
TerminationGracePeriodis for normal shutdown.11 remaining items
linkvt commentedon Nov 13, 2025
@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).
changminbark commentedon Nov 15, 2025
@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.
flomedja commentedon Nov 15, 2025
@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.
Add terminationGracePeriodSeconds support to user and sidecar contain…
Add terminationGracePeriodSeconds support to user and sidecar contain…
flomedja commentedon Nov 21, 2025
@linkvt I pushed the MR. As requested by @dprotaso I add an issue #16256 for adding validation for startup probes.
Add terminationGracePeriodSeconds support to user and sidecar contain…
Add terminationGracePeriodSeconds support to user and sidecar contain…
Add terminationGracePeriodSeconds support to user and sidecar contain…
Add terminationGracePeriodSeconds support to user and sidecar contain…
Add terminationGracePeriodSeconds support to user and sidecar contain…