-
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
Feature Request: Consider timeoutSeconds
for queue-proxy
graceful shutdown
#13953
Comments
timeoutSeconds
for queue-proxy
graceful shutdown
This should be fixed in v1.10.0 and v1.9.3 (#13815) - I realize it's missing in the release notes which I've just updated
Technically we drain for 30 seconds but will reset that timer if there is a new incoming request. The maximum we will drain is set to the revision's timeout - we do this by setting the Pod's termination grace period like so
So if there isn't a request after 30seconds we'll shutdown gracefully. Are you seeing something different? |
@dprotaso I am currently using v1.9.3 because Knative v1.10.0 has tls problems.
I rechecked with v1.9.3 and the problem has not been resolved. Reproduction procedure
Complete source code used for reproduction. const http = require("http");
const { setTimeout } = require("timers/promises");
const t = process.env.SLEEP && Number(process.env.SLEEP);
const port = process.env.PORT || 8080;
const msg = `Hello World ${process.env.SERVING_POD}`;
console.log(`
SLEEP: ${process.env.SLEEP}
SERVING_POD: ${process.env.SERVING_POD}
PORT: ${port}
msg: ${msg}
`);
let count = 0;
const server = http
.createServer(async (req, res) => {
console.log("received request");
count ++;
if (t) {
await setTimeout(t);
}
res.write(`${msg}, concurrency: ${count}`);
res.end();
count--;
})
.listen(port); apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: hello
namespace: default
spec:
template:
metadata:
spec:
timeoutSeconds: 65
containers:
- env:
- name: SLEEP
value: "60000"
- name: SERVING_POD
valueFrom:
fieldRef:
fieldPath: metadata.name
image: kahiro/hello-world-node:latest
name: hello-container
ports:
- containerPort: 8080
protocol: TCP
traffic:
- latestRevision: true
percent: 100 The content is simple: just sleep the http request for 60 seconds and return it. |
I'm having trouble reproducing what you're describing with 1.9.3 and 1.10
note: the node code doesn't shutdown gracefully - you can accomplish that by adding and the code below and it will shutdown the server on a TERM signal process.on('SIGTERM', () => {
console.info('SIGTERM signal received.');
server.close(() => {
console.log('Http server closed.');
});
}); |
I tried to bump the timeout to 2min and I see the queue proxy remain alive for that long apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: helloworld
namespace: default
spec:
template:
spec:
timeoutSeconds: 130
containers:
- image: dprotaso/hello-world-node:latest # handles SIGTERM
env:
- name: TARGET
value: "Go Sample v1"
- name: SLEEP
value: "120000" |
@dprotaso |
Describe the feature
In Knative Service, the
timeoutSeconds
can be set to, for example, 10 minutes.serving/pkg/apis/serving/v1/revision_types.go
Line 90 in 2e77abf
However, when the
queue-proxy
receives aSIG_TERM
, it terminates in 30 seconds regardless of thetimeoutSeconds
setting.serving/pkg/queue/sharedmain/main.go
Line 67 in 53e91c9
Additionally, the held TCP connections are forcibly closed at this time.
With this specification, Knative Serving requires each connection to complete within 30 seconds or less to achieve a graceful shutdown.
I'd like to enable more applications to run on Knative Serving by addressing this issue.
The text was updated successfully, but these errors were encountered: