Skip to content

graceful shutdown: rework API types / compatibility - #11709

Merged
jgallagher merged 1 commit into
lif/acpi-shutdownfrom
john/acpi-shutdown-api-versioning
Nov 5, 2026
Merged

jgallagher merged 1 commit into
lif/acpi-shutdownfrom
john/acpi-shutdown-api-versioning

Conversation

@jgallagher

Copy link
Copy Markdown
Contributor

This PR addresses items 1 and 2 from #11565 (comment). (Item 3 was addressed yesterday in 28daa74, which changed the default for the API to hard_off.) The changes for those two are:

  1. The shutdown_policy field is no longer an Option for either Instance or InstanceCreate. InstanceCreate has a #[serde(default)], so it's not required at the API layer, but this way (a) we don't have to deal with None and (b) we don't have the oddity of always returning Some(_) to clients even if they had specified None.
  2. The type conversion for old clients just throws away the shutdown_policy field instead of failing if it isn't HardOff. This is less important now that the default is HardOff, but I still think it's reasonable - this way old clients can still see / list instances that were created by new clients. They just won't be able to tell what those instance's shutdown policies are. (shutdown_policy is still None in InstanceUpdate, which means "don't change", so an instance update from an old client is fine: it doesn't know about shutdown_policy, which turns into None, which turns into "don't change it".)

Most of the bulk off the diff is trivial fallout from 1 - changing a bunch of Nones to InstanceShutdownPolicy::default()s in a lot of tests. The end-to-end test had to switch from specifying all the fields to using the progenitor-client's builder API (which allows you to not specify defaultable fields).

A few other cleanup things came along for the ride:

  1. I moved the enforcement of the ACPI timeout second range into a newtype in the API. This means it's enforced at deserialization time, so we don't have to remember to validate it every place it comes in in Nexus.
  2. The instance update handler had duplicated the logic of "convert the InstanceShutdownPolicy into the 2-column database representation". I moved this into an InstanceUpdate::new() function in the db-model; I don't love that it takes a bunch of args but I think it's still a net win?
  3. I changed the propolis pointer in package-manifest.toml to match what's in Cargo.toml (all of which now point to the latest commit on Support soft shutdown via ACPI PWRBTN_STS propolis#1217). I'm hoping this lets CI make more progress; I'd like to confirm the end-to-end test change mentioned above, at least, which I think requires CI.

This PR addresses items 1 and 2 from
#11565 (comment).
(Item 3 was addressed yesterday in
28daa74,
which changed the default for the API to `hard_off`.) The changes for
those two are:

1. The `shutdown_policy` field is no longer an `Option` for either
   `Instance` or `InstanceCreate`. They do both have a
   `#[serde(default)]` on them, so they're not required at the API
   layer, but this way (a) we don't have to deal with `None` and (b) we
   don't have the oddity of always returning `Some(_)` to clients even
   if they had specified `None`.
2. The type conversion for old clients just throws away the
   `shutdown_policy` field instead of failing if it isn't `HardOff`.
   This is less important now that the default is `HardOff`, but I still
   think it's reasonable - this way old clients can still see / list
   instances that were created by new clients. They just won't be able
   to tell what those instance's shutdown policies are.
   (`shutdown_policy` is still `None` in `InstanceUpdate`, which means
   "don't change", so an instance update from an old client is fine: it
   doesn't know about `shutdown_policy`, which turns into `None`, which
   turns into "don't change it".)

Most of the bulk off the diff is trivial fallout from 1 - changing a
bunch of `None`s to `InstanceShutdownPolicy::default()`s in a lot of
tests. The end-to-end test had to switch from specifying all the fields
to using the progenitor-client's builder API (which allows you to _not_
specify defaultable fields).

A few other cleanup things came along for the ride:

1. I moved the enforcement of the ACPI timeout second range into a
   newtype in the API. This means it's enforced at deserialization time,
   so we don't have to remember to validate it every place it comes in
   in Nexus.
2. The instance update handler had duplicated the logic of "convert the
   `InstanceShutdownPolicy` into the 2-column database representation".
   I moved this into an `InstanceUpdate::new()` function in the
   db-model; I don't love that it takes a bunch of args but I think it's
   still a net win?
3. I changed the propolis pointer in `package-manifest.toml` to match
   what's in `Cargo.toml` (all of which now point to the latest commit
   on oxidecomputer/propolis#1217). I'm hoping
   this lets CI make more progress; I'd like to confirm the end-to-end
   test change mentioned above, at least, which I think requires CI.
Comment on lines 62 to 63
// schemars(range(max)) above is required to be a *literal*. if the constant
// changes, and you're here because of the assertion, change it accordingly.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feels slightly silly when the const defs are right below, but better to make sure posterity know to change the schemars constraint i suppose

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah agreed, I could certainly see a case for dropping these. I don't feel strongly either way 🤷

@jgallagher
jgallagher merged commit 06a367e into lif/acpi-shutdown Nov 5, 2026
19 checks passed
@jgallagher
jgallagher deleted the john/acpi-shutdown-api-versioning branch November 5, 2026 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants