aurae-runtime / auraed

Secure mTLS and gRPC backed runtime daemon. Alternative to systemd. Written in Rust.
https://aurae.io/auraed
Apache License 2.0
60 stars 11 forks source link

Graceful shutdown #36

Open MalteJ opened 1 year ago

MalteJ commented 1 year ago

We need to implement a graceful shutdown flow. This flow must be executed when auraed gets a SIGTERM signal, the power button is pressed (if executed as pid 1) or when auraed gets a reboot or shutdown request via GRPC.

  1. An event has to be sent to all GRPC clients to inform them about the imminent shutdown.
  2. No new workloads (processes, containers, VMs, ...) may be scheduled.
  3. All threads, processes, containers, VMs, MicroVMs must be shut down gracefully (e.g. sending SIGTERM to processes, waiting for x seconds and then sending SIGKILL if they have not shut down; sending ACPI shutdown to VMs, power off after timeout).
  4. The GRPC API needs to be stopped.
  5. The API socket needs to be deleted.
future-highway commented 1 year ago

Using serve_with_incoming_shutdown, we can stop the GRPC server on a supplied signal.

It would replace: https://github.com/aurae-runtime/auraed/blob/809a488d8c36c45ccde88d4dc668d3cd5c085652/src/lib.rs#L141