Skip to content

Commit

Permalink
Remove cpu_manager_state in initramfs stage
Browse files Browse the repository at this point in the history
Signed-off-by: Cooper Tseng <cooper.tseng@suse.com>
  • Loading branch information
brandboat committed Aug 23, 2024
1 parent 6642d40 commit 7940f0d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/config/cos.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,12 @@ func ConvertToCOS(config *HarvesterConfig) (*yipSchema.YipConfig, error) {
for _, module := range cfg.OS.Modules {
initramfs.Commands = append(initramfs.Commands, "modprobe "+module)
}
// Delete the cpu_manager_state file during the initramfs stage. During a reboot, this state file is always reverted
// because it was originally created during the system installation, becoming part of the root filesystem.
// As a result, the policy in cpu_manager_state file is "none" (default policy) after reboot. If we've already set
// the cpu-manager-policy to "static" before reboot, this mismatch can prevent kubelet from starting,
// and make the entire node unavailable.
initramfs.Commands = append(initramfs.Commands, "rm -f /var/lib/kubelet/cpu_manager_state")

initramfs.Sysctl = cfg.OS.Sysctls
initramfs.Environment = cfg.OS.Environment
Expand Down
10 changes: 10 additions & 0 deletions pkg/config/cos_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,16 @@ func TestConvertToCos_VerifyNetworkInstallMode(t *testing.T) {
assert.False(t, containsFile(yipConfig.Stages["initramfs"][0].Files, "/etc/sysconfig/network/ifcfg-ens3"))
}

func TestConvertToCos_Remove_CPUManagerState(t *testing.T) {
conf, err := LoadHarvesterConfig(util.LoadFixture(t, "harvester-config.yaml"))
assert.NoError(t, err)

yipConfig, err := ConvertToCOS(conf)
assert.NoError(t, err)

assert.Contains(t, yipConfig.Stages["initramfs"][0].Commands, "rm -f /var/lib/kubelet/cpu_manager_state")
}

func containsFile(files []yipSchema.File, fileName string) bool {
for _, v := range files {
if v.Path == fileName {
Expand Down

0 comments on commit 7940f0d

Please sign in to comment.