-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to set custom terminationGracePeriodSeconds for a knative Service pod #15555
Comments
UpdateIt looks like the terminationGracePeriodSeconds value is being directly picked from the revision-timeout-seconds value specified in the config-defaults configmap in the knative namespace. Is there any way I can have different value for these two ? |
Hi @sebastianjohnk, Knative manages the pod termination cycle as it: |
This issue is stale because it has been open for 90 days with no |
/remove-lifecycle stale |
Currently, Knative uses the same timeout setting for both service startup and shutdown. However, we would like to have separate timeouts for these operations. |
By having separate timeouts you'll have incoming requests that are timed out earlier than For example - imagine a request is received by a Pod right before the pod receives a SIGTERM. That's why When the request is finished the pod should shutdown before the grace period ends. @sebastianjohnk @kahirokunn are your requests long running (eg. websockets, server-side events) ? |
From what I have seen (also downstream) this is usually due to AI use cases where you want to stop a model from finishing (these requests can be long) a request and shut it down quickly. cc @Jooho |
Ask your question here:
Hi. I'm working on a small POC to create some knative Services.
The image I'm providing for the pod currently contains a small flask app that listens on a port.
Right now I'm testing out the scale-down-ability of these Services.
It seems that once Knative decides to scale down the number of replicas of a pod from, say 3 to 2, or even to 0, these pods remain in a "Terminating" state for a long time, close to 4 or 5 minutes I'd say.
And they seem to be in a 1/2 state.
I checked the container logs. It seems the queue-proxy container is shutting down properly, but not my flask app container.
But anyway, I learned that every pod has a terminationGracePeriodSeconds value that decides how long a pod can stay in this "Terminating" stage before kubernetes force kills it.
Now here is the problem. The terminationGracePeriodSeconds seems to be a default value of 300 for all pods spawned as part of a Service, with seemingly no option to specify it in the Service yaml spec.
I'm able to specify this in a Pod yaml spec and deploy that pod individually and it gets reflected in the pod (when I fetch the pod yaml using kubectl).
But when I try to deploy a Service using a yaml spec, which in turn contains a pod spec with the same configuration, something like this --
I get an error saying
Error from server (BadRequest): error when creating "helloservice.yaml": Service in version "v1" cannot be handled as a Service: strict decoding error: unknown field "spec.template.spec.terminationGracePeriodSeconds"
But if I remove this field from the Service yaml, the service gets deployed, and the pod seems to have a default terminationGracePeriodSeconds value of 300.
I also checked what the default value for a pod that is directly deployed from a pod yaml spec is (without the terminationGracePeriodSeconds specified ), to see if it a kubernetes default thing, but it seems to be 30.
So the default seems to be 30 for individual pods and 300 for pods that are part of a Service.
I guess my question is, how is this default terminationGracePeriodSeconds value of 300 being set for pods belonging to Services and is there any way I can change this either by mentioning it in my Service yaml spec, or by changing some kubernetes/knative configuration ?
Any help would be much appreciated thank you.
The text was updated successfully, but these errors were encountered: