Conversation
c13d108 to
157c161
Compare
anson627
approved these changes
Mar 3, 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.
This pull request refactors how systemd unit and drop-in files are managed across several components, introducing idempotent "ensure" methods that only write files when necessary and centralizing logic for starting and reloading units. The changes improve reliability and reduce unnecessary restarts or reloads by tracking when files have actually changed.
Systemd file management improvements:
WriteUnitFileandWriteDropInFilemethods with newEnsureUnitFileandEnsureDropInFilemethods in thesystemd.Managerinterface, which only write files if their content has changed or if the file does not exist. These methods now return a boolean indicating whether the file was updated. (pkg/systemd/types.go,pkg/systemd/dbus.go) [1] [2]kubelet,kubeadm, andcricomponents to use the new "ensure" methods, removing manual checks for file existence and content. (components/kubelet/v20260301/kubelet_service.go,components/kubeadm/v20260301/join.go,components/cri/v20260301/service.go) [1] [2] [3] [4]Unit lifecycle and reload logic centralization:
EnsureUnitRunninghelper function that encapsulates logic for reloading the systemd daemon and restarting or starting units only when necessary, based on whether unit files or drop-ins were updated. (pkg/systemd/ensure.go)components/kubelet/v20260301/kubelet_service.go,components/cri/v20260301/service.go) [1] [2]Code cleanup:
components/kubelet/v20260301/kubelet_service.go,pkg/systemd/dbus.go) [1] [2]These changes make systemd unit management more robust and reduce unnecessary operations, improving both reliability and maintainability.