Cleanup k8s states after upgrade
This commit is contained in:
@@ -29,6 +29,31 @@ func ReleaseControlGate(ctx context.Context, nctx *NodeContext) error {
|
||||
return fmt.Errorf("relate control gate: %w", err)
|
||||
}
|
||||
|
||||
return WriteLastState(ctx, nctx)
|
||||
}
|
||||
|
||||
// Required for detecting bootslot changes
|
||||
func WriteLastState(ctx context.Context, nctx *NodeContext) error {
|
||||
stBootPart := filepath.Join(monov1alpha1.EnvConfigDir, ".bootpart")
|
||||
|
||||
state, err := osimage.ReadBootState()
|
||||
if err != nil {
|
||||
return fmt.Errorf("read boot state: %w", err)
|
||||
}
|
||||
|
||||
bootPart := state["BOOT_PART"]
|
||||
if bootPart == "" {
|
||||
return fmt.Errorf("BOOT_PART missing")
|
||||
}
|
||||
|
||||
tmp := stBootPart + ".tmp"
|
||||
if err := os.WriteFile(tmp, []byte(bootPart+"\n"), 0o644); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := os.Rename(tmp, stBootPart); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user