A deployment can start every new instance successfully and still interrupt users when the old ones disappear. There may be a request halfway through, a worker holding a message or a transaction waiting to commit. The startup path gets plenty of attention. I want the shutdown path to have an equally deliberate answer for the work already in progress.
The Kubernetes termination lifecycle gives containers a grace period, then forcibly stops anything still running after it expires. That is a deadline for the application to handle, not a guarantee that its work will finish. The server needs to receive the stop signal, begin draining and exit within the time available. Check that the way the container starts actually delivers that signal to the application.
For an HTTP service, I would stop accepting new work as part of the platform’s traffic-draining process and give existing requests a bounded chance to complete. Removing an instance from routing and finishing its current connections are related steps, but they do not happen everywhere at precisely the same instant. Workers need their own decision: stop taking messages, finish what can finish and leave unfinished work available for safe redelivery. Acknowledging it just because the process is shutting down can lose the job.
Test this during a real local or staging rollout with a deliberately slow request and an in-progress worker operation. Watch the client result, the stored outcome and whether a redelivered message repeats a side effect. Shutdown will never replace recovery from a crash, so the forced-stop case still matters. A useful deployment test shows both that ordinary draining works and that unfinished work has a sensible recovery path when time runs out.
