m/n/c/mgmt: move and factor out reboot code
Make sure we do not have two copies of mostly temporary reboot code
sitting around and put it in a sensible place.
Change-Id: I293a699dbfc3cfe23378485c512d8769b2859ab8
Reviewed-on: https://review.monogon.dev/c/monogon/+/3396
Reviewed-by: Serge Bazanski <serge@monogon.tech>
Tested-by: Jenkins CI
diff --git a/metropolis/node/core/mgmt/update.go b/metropolis/node/core/mgmt/update.go
index ab31682..eb838dd 100644
--- a/metropolis/node/core/mgmt/update.go
+++ b/metropolis/node/core/mgmt/update.go
@@ -2,9 +2,7 @@
import (
"context"
- "time"
- "github.com/vishvananda/netlink"
"golang.org/x/sys/unix"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
@@ -34,36 +32,8 @@
}
s.LogTree.MustLeveledFor("update").Infof("activating update with method: %s", methodString)
-
- go func() {
- // TODO(#253): Tell Supervisor to shut down gracefully and reboot
- time.Sleep(10 * time.Second)
- s.LogTree.MustLeveledFor("update").Info("activating now...")
- unix.Unmount(s.UpdateService.ESPPath, 0)
- unix.Sync()
- disableNetworkInterfaces()
- unix.Reboot(method)
- }()
+ s.initiateReboot(method)
}
return &apb.UpdateNodeResponse{}, nil
}
-
-// For kexec it's recommended to disable all physical network interfaces
-// before doing it. This function doesn't return any errors as it's best-
-// effort anyways as we cannot reliably log the error anymore.
-func disableNetworkInterfaces() {
- links, err := netlink.LinkList()
- if err != nil {
- return
- }
- for _, link := range links {
- d, ok := link.(*netlink.Device)
- if !ok {
- continue
- }
- if err := netlink.LinkSetDown(d); err != nil {
- continue
- }
- }
-}