Repository navigation
fix: improve daemon robustness - #197
Merged
Merged
Conversation
Owner
|
Thank you @crazyproger for all your nice contributions! Please rebase this PR. |
…oehrl01#194-woehrl01#196 Node daemon: - Getting the node for the PacemakerConfig selection and removing the startup taint retry (6 attempts, about 30s) instead of log.Fatalf. A restart loses the slots held in memory, so up to N more pods start at once. When the node still cannot be read the current throttlers stay; only before the first successful configuration the daemon still exits, so that a restart retries instead of leaving the node unthrottled until the next config change. - A PacemakerConfig that fails to convert is skipped instead of stopping the daemon on every node. - A missed pod delete arrives after a re-list as cache.DeletedFinalStateUnknown; DeleteFunc unwraps it instead of panicking. - A pod without container statuses yet no longer counts as started and terminated. - The gRPC server goroutine no longer calls wg.Done twice (panic on SIGTERM), and http.ErrServerClosed of the metrics server is not fatal. - ErrImagePull and ImagePullBackOff release the slot only after the pull has kept failing for imagePullGracePeriod (2m) from the first failure: a pull also fails while the registry throttles, and releasing those slots at once would start all waiting pods of the node together. CNI plugin: shouldSkipThrotteling checks runtimeConfig for nil; the acquireSlot comment describes the connect logic from woehrl01#194. Chart: cni-config-sync is not rendered for a zero cni.watchInterval (0, 0s, 0m, ...); cni-init exits right after the setup then and the container restarted forever.
crazyproger
force-pushed
the
fix/daemon-robustness
branch
from
November 6, 2026 17:01
9a8fb4f to
828fb6a
Compare
GracefulStop waits for the requests in flight, and a request waiting for a slot can block until its deadline (maxWaitTimeInSeconds), so the daemon did not exit on SIGTERM. Before this branch that went unnoticed: the double wg.Done made the daemon panic and exit right away. The e2e test deletes the daemon pod while pods wait and its kubectl delete was killed after 5s. Stop drops the waiting requests; the CNI plugin sees a connection error and retries against the next daemon. A test covers the plugin side of a restart.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Robustness fixes for the node daemon, plus follow-ups to #194, #195 and #196 that missed their merge. Rebased on
mainas one commit.Problems
Updateof the Node. Both end the daemon withlog.Fatalfon any error. On a starting node the kubelet and node provisioners update the Node too, so a conflict is expected now and then. The restart loses the slots held in memory, up to N more pods start at once, and new pods wait for the socket meanwhile.log.Fatalftoo.cache.DeletedFinalStateUnknown;obj.(*v1.Pod)inDeleteFuncpanics and all slots are lost.allStartedandallTerminatedstart astrueand loop over an empty list, so a pod that has not reported container statuses yet (right after the CNI ADD) loses its slot before it starts.wg.Done()twice; when the server returns, e.g. on SIGTERM, the daemon panics withsync: negative WaitGroup counter.GracefulStopwaits for the requests in flight, and a request waiting for a slot blocks until its deadline, so with the doublewg.Done()fixed the daemon would hang on SIGTERM for up tomaxWaitTimeInSeconds(the e2e test deleting the daemon pod caught it).log.Fatal(srv.ListenAndServe())also fires onhttp.ErrServerClosedafter the graceful shutdown of the metrics server.shouldSkipThrottelingreadsconf.RuntimeConfig.PodAnnotationswithout a nil check; a runtime that passes noruntimeConfigmakes every ADD panic.Follow-ups:
cni.watchInterval: 0smakescni-config-syncrestart forever.cni-init --watch-interval=0exits after the setup, but the template only skips the container for an empty value.acquireSlotcomment still described the non-blocking dial.Fix
retry.OnError, 6 attempts, about 30 s). If the node still cannot be read, the current throttlers stay and the error is logged; only before the first successful configuration the daemon still exits, so that a restart retries instead of leaving the node unthrottled until the next config change. Removing the taint still exits after the retries: the taint keeps pods off the node and a restart tries again.DeleteFuncunwraps the tombstone.allStarted/allTerminatedrequire at least one container status.wg.Done()is removed;http.ErrServerClosedis not treated as an error.Stop: the waiting requests are dropped and the CNI plugin retries them against the next daemon (covered by a plugin test with a daemon restart).RuntimeConfigis checked for nil.ErrImagePullandImagePullBackOffrelease the slot only after the pull has kept failing for 2 minutes (imagePullGracePeriod), counted from the first failure;InvalidImageName,CrashLoopBackOffand theCreateContainer*errors still release it right away. The--max-slot-holdhelp says it is checked on pod events and the 30s resync.cni-config-syncis not rendered for any zerocni.watchInterval(0,0s,0m, ...).Tests
shouldSkipThrottelingwithoutruntimeConfig;go test -race ./...andhelm lintpass;helm templaterenderscni-config-syncfor10s/1m/0.5sand not for empty/0/0s/0m/0m0s.main,maxConcurrent.value: 3:cni-config-syncre-merged the configuration 8 s after an aws-node restart with changed env;maxWaitTimeInSeconds(220 s).