From 7f3eb1dac6458bf4eb8daf3a93844fa01dfc6d08 Mon Sep 17 00:00:00 2001 From: Ben Kuhn Date: Sun, 17 Feb 2019 15:40:45 +0000 Subject: [PATCH] Better example of a preStop hook for nginx (#12563) It looks like `nginx -s quit` returns immediately rather than blocking until nginx has finished gracefully shutting down. As a result, just running `nginx -s quit` in the preStop hook won't work very well for high load and/or long running requests; nginx will get a TERM signal (and do a hard shutdown) immediately after `nginx -s quit` returns. (I was getting connection errors while terminating pods, and adding a sleep-until-done to the preStop hook seemed to make them go away.) --- content/en/examples/pods/lifecycle-events.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/en/examples/pods/lifecycle-events.yaml b/content/en/examples/pods/lifecycle-events.yaml index e5fcffcc9e..4b79d7289c 100644 --- a/content/en/examples/pods/lifecycle-events.yaml +++ b/content/en/examples/pods/lifecycle-events.yaml @@ -12,5 +12,5 @@ spec: command: ["/bin/sh", "-c", "echo Hello from the postStart handler > /usr/share/message"] preStop: exec: - command: ["/usr/sbin/nginx","-s","quit"] + command: ["/bin/sh","-c","nginx -s quit; while killall -0 nginx; do sleep 1; done"]