Repository navigation
feat(dfinit): create restart sentinel only when runtime config is rewritten - #2116
Merged
Merged
Conversation
…ritten dfinit now reports whether the container runtime configuration actually changed and creates a sentinel file (default `<root>/dfinit/restart-required`, overridable via `--restart-sentinel`) only in that case, so an unchanged runtime is never restarted. - Add `write_if_changed` util that skips writes when contents are identical and returns whether the file was written. - containerd, docker, cri-o and podman runners now return whether a non-reloaded config file (config.toml, daemon.json, registries.conf) was rewritten; containerd hosts.toml changes never require a restart. - Bump workspace version to 1.5.10. Signed-off-by: Gaius <gaius.qi@gmail.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2116 +/- ##
==========================================
+ Coverage 65.63% 65.71% +0.07%
==========================================
Files 102 102
Lines 31141 31231 +90
==========================================
+ Hits 20439 20522 +83
- Misses 10702 10709 +7
🚀 New features to boost your workflow:
|
hyy0322
approved these changes
Oct 23, 2026
EvanCley
approved these changes
Oct 23, 2026
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.
Description
dfinit now reports whether the container runtime configuration actually changed and creates a sentinel file,
/var/run/dragonfly/dfinit/restart-requiredby default and overridable with--restart-sentinel, only in that case. Therestart-container-runtimeinit container of the Helm chart will restart the runtime only when this sentinel exists and consume it before restarting, so an unchanged runtime is never restarted and the restart can never loop.dragonfly_client_util::fs::write_if_changed, which skips the write when the contents are identical and returns whether the file was written, modelled on cargo'spaths::write_if_changed.config.toml,daemon.json,registries.conf) was rewritten. Writinghosts.tomlunder an existing containerdregistry.config_pathnever requires a restart.ContainerRuntimeowns the sentinel path and creates the file when a restart is required, like/run/reboot-requiredon Debian and the--reboot-sentinelof kured.Related Issue
Fixes #2115
Related: dragonflyoss/helm-charts#539 reports the same loop on Flatcar with containerd 2.2.5, dragonflyoss/helm-charts#541 proposes
systemctl --no-block restart, which narrows the race but does not remove it. The chart change that consumes the sentinel and removesclient.dfinit.restartContainerRuntimefollows in dragonflyoss/helm-charts.Motivation and Context
The chart's
restart-container-runtimeinit container restarts containerd unconditionally from inside a container that containerd manages. OnType=simpleunits such as Azure Linux 3.0 and the Flatcar containerd sysext,systemctl restartreturns before the new containerd has reloaded its shims, the init container's shell exits in that window, the new containerd cleans its task up as a leaked shim and records exit code 255, and kubelet re-runs the init container forever, restarting containerd roughly every five minutes.On AKS, GKE and every other node image that already sets
registry.config_path, dfinit only writeshosts.toml, which containerd reloads without a restart, so the restart was never needed there. With this change the decision moves into dfinit: the runtime is restarted only when a file it does not reload was actually rewritten, which for containerd happens once, on the first install of nodes withoutconfig_path. As a side effect, cri-o, podman and docker are no longer restarted on every pod start when their generated configuration is unchanged.Screenshots (if appropriate)
N/A
🤖 Generated with Claude Code