Repository navigation
graceful shutdown: rework API types / compatibility - #11709
Merged
Merged
Conversation
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.
lifning
approved these changes
Nov 5, 2026
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. |
Contributor
There was a problem hiding this comment.
feels slightly silly when the const defs are right below, but better to make sure posterity know to change the schemars constraint i suppose
Contributor
Author
There was a problem hiding this comment.
yeah agreed, I could certainly see a case for dropping these. I don't feel strongly either way 🤷
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:shutdown_policyfield is no longer anOptionfor eitherInstanceorInstanceCreate.InstanceCreatehas a#[serde(default)], so it's not required at the API layer, but this way (a) we don't have to deal withNoneand (b) we don't have the oddity of always returningSome(_)to clients even if they had specifiedNone.shutdown_policyfield instead of failing if it isn'tHardOff. This is less important now that the default isHardOff, 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_policyis stillNoneinInstanceUpdate, which means "don't change", so an instance update from an old client is fine: it doesn't know aboutshutdown_policy, which turns intoNone, which turns into "don't change it".)Most of the bulk off the diff is trivial fallout from 1 - changing a bunch of
Nones toInstanceShutdownPolicy::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:
InstanceShutdownPolicyinto the 2-column database representation". I moved this into anInstanceUpdate::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?package-manifest.tomlto match what's inCargo.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.