Repository navigation
fix(server): Worker.Stop blocked forever, so shutdown waited for SIGKILL - #29
Conversation
Worker.Start adds to the worker's WaitGroup and Worker.Stop waits on it, but the work loop never called Done. TaskManager.Stop therefore blocked on the first worker, Server.Shutdown never got past it, and the process ignored SIGTERM until the kubelet killed it at the end of the 30-second grace period. kubevirtClient.Close, which stops the watchers, never ran. Every rollout took 30s longer than it needed to. Release the WaitGroup when the work loop exits. Signed-off-by: itayherzberg <itayherzberg@gmail.com>
|
Hi @itayherzberg. Thanks for your PR. PRs from untrusted users cannot be marked as trusted with I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: MarSik The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Problem
The process never finishes a graceful shutdown. On SIGTERM it logs
Stopping enhanced task manager...and then hangs until the kubelet kills it at the end of the 30-second grace period. Every rollout and everyhelm upgradetakes 30 s longer than it needs to, and nothing after the task manager inServer.Shutdownruns: the job scheduler, the caches, the health checker, andkubevirtClient.Close(), which stops the boot-once / import-pod / CDI-PVC watchers.Cause
Worker.Startdoesw.wg.Add(1)andWorker.Stopdoesw.wg.Wait(), but the work loop started byStartnever callsw.wg.Done()when it exits.TaskManager.Stopcancels the context (the loop does return) and then blocks forever on the first worker'sStop.Unit test added by this PR, run against current
main:On a cluster (upstream
b40c637, OpenShift 4.22), deleting the pod — its complete log after SIGTERM, then nothing for 30 s:Fix
defer w.wg.Done()at the top ofWorker.work.Verification on the cluster
Same deletion with this branch:
The whole shutdown sequence now runs, including the watcher stops in
kubevirtClient.Close(). Also verified together with #32 (whose informer stop pathClose()could never reach before): terminated in 3.18 s, no panic.Tests
pkg/server/worker_test.go:TestWorkerStopReturns(fails on currentmainas shown above, passes with the fix).go build ./...,go vet ./...,go test ./...,gofmt,go mod tidy(no change) pass.Related
One of four independent PRs from running many concurrent BMHs against kubevirt-redfish; each stands on its own and they can merge in any order: #30 (client-go rate limit), #31 (task worker pool), #32 (VM/VMI informer cache).
Found the same way but not fixed here: config hot reload never fires in a pod, because the kubelet updates a mounted Secret by swapping the
..datasymlink and thecmd/main.gowatcher only reacts to Write/Create events onconfig.yaml. Happy to open an issue for it.