control agent can now uboot commands
This commit is contained in:
37
clitools/pkg/controller/osupgrade/bootenv.go
Normal file
37
clitools/pkg/controller/osupgrade/bootenv.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package osupgrade
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
type NextBootConfig struct {
|
||||
Key string
|
||||
Value string
|
||||
}
|
||||
|
||||
func SetNextBootEnv(ctx context.Context, cfg NextBootConfig) error {
|
||||
if cfg.Key == "" {
|
||||
return fmt.Errorf("boot env key is empty")
|
||||
}
|
||||
if cfg.Value == "" {
|
||||
return fmt.Errorf("boot env value is empty")
|
||||
}
|
||||
|
||||
cmd := exec.CommandContext(
|
||||
ctx,
|
||||
"/proc/self/exe",
|
||||
"internal",
|
||||
"fw-setenv",
|
||||
"--key", cfg.Key,
|
||||
"--value", cfg.Value,
|
||||
)
|
||||
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
return fmt.Errorf("invoke internal fw-setenv: %w: %s", err, string(out))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -128,7 +128,22 @@ func HandleOSUpgrade(ctx context.Context, clients *kube.Clients,
|
||||
}
|
||||
|
||||
klog.Info(result)
|
||||
// TODO: fw_setenv
|
||||
if err := SetNextBootEnv(ctx, NextBootConfig{
|
||||
Key: "boot_part",
|
||||
Value: "B",
|
||||
}); err != nil {
|
||||
return failProgress(ctx, clients, osup, "set boot env", err)
|
||||
}
|
||||
|
||||
now = metav1.Now()
|
||||
osup.Status.LastUpdatedAt = &now
|
||||
osup.Status.Message = "image applied, verified, and next boot environment updated"
|
||||
osup.Status.Phase = monov1alpha1.OSUpgradeProgressPhaseRebooting
|
||||
|
||||
osup, err = updateProgressStatus(ctx, clients, osup_gvr, osup)
|
||||
if err != nil {
|
||||
return fmt.Errorf("update progress status: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user