monogon-dev / monogon

The Monogon Monorepo. May contain traces of peanuts and a ✨pure Go Linux userland✨. Work in progress!
https://monogon.tech
Apache License 2.0
378 stars 9 forks source link

API for rebooting node #326

Closed leoluk closed 2 months ago

leoluk commented 3 months ago

Graceful restart is a bit further out (https://github.com/monogon-dev/monogon/issues/253), but in the meantime, we should have a simple API call for rebooting a node.

lorenz commented 3 months ago

While at it we should also add a call for shutting down a node.

lorenz commented 3 months ago

@leoluk Do we want separate Reboot and PowerOff RPCs or a single more complex one?

lorenz commented 3 months ago

Proposed API for single RPC:

message RebootRequest {
  enum Type {
    // SOFT performs a KEXEC reboot if the hardware is expected to support
    // that, falling back to FIRMWARE_WARM if not which falls back on the
    // firmware side to cold if unsupported.
    SOFT = 0;
    // FIRMWARE_COLD tells the firmware to remove power after shutdown before
    // reapplying it and powering back up.
    FIRMWARE_COLD = 1;
    // FIRMWARE_WARM tells the firmware to just reset the processors and boot
    // back up. If unsupported the firmware will fall back to a cold reboot.
    FIRMWARE_WARM = 2;
    // KEXEC performs a KEXEC reboot without going through firmware at all.
    // This is the fastest reboot option, but does not fully reset most
    // hardware and has compatibility issues on certain hardware.
    KEXEC = 3;
    // POWER_OFF fully powers off the system. It can only be started again by
    // a physical power button, Wake On LAN if set supported by the NIC or
    // an out-of-band management controller if available.
    POWER_OFF = 4;
  }
  Type type = 1;
  enum NextBoot {
    // START_NORMAL starts the system normally, respecting standard A/B slot
    // booting rules. Any staged but not activated updates will be activated
    // as with a normal reboot.
    START_NORMAL = 0;
    // START_ROLLBACK tries to boot into the currently inactive slot on reboot.
    START_ROLLBACK = 1;
  }
  // NextBoot can be used to select the boot slot to reboot into. This works
  // even for POWER_OFF, but there the next boot will need to be triggered
  // externally.
  NextBoot next_boot = 2;
}
message RebootResponse {
}
lorenz commented 2 months ago

Implemented in https://review.monogon.dev/c/monogon/+/3354, metroctl changes in https://review.monogon.dev/c/monogon/+/3391