Skip to content

Support for instance 'graceful' shutdown policy - #11565

Merged
iximeow merged 36 commits into
mainfrom
lif/acpi-shutdown
Nov 22, 2026
Merged

iximeow merged 36 commits into
mainfrom
lif/acpi-shutdown

Conversation

@lifning

@lifning lifning commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

This feature is intended to allow VM guest shutdowns to be triggered through the API and as part of sled evacuations for updates. An intent of this feature is to afford non-ephemeral instances a chance to cleanly unmount their filesystems, such that taking a new Oxide software release does not carry with it an unnecessary risk of filesystem corruption.

To quote RFD 622:

Oxide users must manually access each instance to perform a stop, which is very inconvenient when dealing with large numbers of instances. This is particularly relevant for mupdates, and until live-migration is available users are likely to frequently want to stop their instances. Even with live-migration, they may want to gracefully stop instances that are too large to migrate on a fully utilized rack.

A note on terminology: ACPI calls the feature currently implemented on the Propolis side "Fixed Power Button". ACPI also specifies an altogether different feature that it calls "Graceful Shutdown Request" which is not presently implemented by Propolis. We may sometimes talk about "gracefully" stopping an instance, but for the sake of clarity, we may wish to be take care not to confuse operators and customers with the term "Graceful Shutdown" in documentation.

POST /v1/instances now takes a shutdown_policy parameter, either HardOff or PowerButton with a (mandatory) timeout between 1 and 3600 seconds. New instances with no shutdown policy specified in their create request will default to a policy of the pre-existing behavior: Hard-poweroff of the guest OS with no forewarning. Existing instances will also default to hard_off in the CRDB migration.

PUT /v1/instances/{instance} will only change an instance's shutdown_policy if one is explicitly included in the request, such that clients of an older API revision don't potentially clobber an existing instance's shutdown policy.

POST /v1/instances/{instance}/stop and POST /v1/instances/{instance}/reboot now may be passed skip_os_shutdown=true to force a hard-poweroff even if an instance has a soft shutdown policy. If an instance does have a PowerButton shutdown policy, and skip_os_shutdown isn't passed, the instance will have its simulated Power Button pressed, and then following either the guest-initiated power event or the exhaustion of the configured timeout, the instance will be accordingly stopped or rebooted by Propolis.

Further requests to stop or reboot an instance while it is still in the process of shutting down (i.e. the guest hasn't emitted a power event and the configured timeout hasn't expired) are permitted to change the instance's fate, i.e. whether or not Propolis will reboot the instance once it has stopped. However, changes to the shutdown policy's timeout will not be propagated to instances that are already shutting down; only the first timeout Propolis receives in a stop or reboot request is considered. Non-ACPI stop/reset requests, either through skip_os_shutdown or changing to a HardOff policy, will be honored.

The sled-agent's existing 10-minute propolis-zone-reaping timeout is extended by the configured timeout of a PowerButton-type shutdown; that is to say, the zone will be forcibly terminated if propolis does not stop in the ACPI timeout plus 10 minutes. If a hard-stop request is sent during this timeout, and there are more than 10 minutes remaining, it will be replaced by a 10-minute timeout. If a reboot request is sent to propolis while it is still waiting for an ACPI shutdown, the zone-reaping timeout is dropped.

@hawkw
hawkw self-requested a review October 22, 2026 20:55
@karencfv

Copy link
Copy Markdown
Contributor

Heya! Just a heads up that this -> #11380 will be landing very soon. It's part of a larger issue to orchestrate instance restarts during live update (RFD 739).

Notably, in the specific PR that I linked we have to use vmm_put_state() directly because we need to make sure the intended state continues to be what it was. #11380 (comment) . Looking at the code here, I'm not sure how the graceful shutdown process would fit in as it is in this draft.

Anyway, happy to discuss further if you have any questions about what we're doing in update land or whatever :)

@lifning

lifning commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor Author

Notably, in the specific PR that I linked we have to use vmm_put_state() directly because we need to make sure the intended state continues to be what it was. #11380 (comment) . Looking at the code here, I'm not sure how the graceful shutdown process would fit in as it is in this draft.

re: your note from from that PR (copied here),

Note: I took a look at how graceful shutdown is being implemented on the control plane side in main...lif/acpi-shutdown. It appears there will be a shutdown_policy_action knob similar to how the auto_restart_policy works today. Once this functionality is implemented, we can decide whether we override this preference or just let whatever settings the user set to carry on to this task.

my understanding is that one of the main desires for shutting down instances gracefully is customers wanting not to have uncleanly unmounted disks in the "shutting everything down to take an update" use-case, so it's my assumption that we would want to send the vmm_put_state with the appropriate timeout from policy in the instance table.

@karencfv

Copy link
Copy Markdown
Contributor

re: your note from from that PR (copied here),

Argh, I wrote that note ages ago, sorry! I should have removed it before writing this 😅

my understanding is that one of the main desires for shutting down instances gracefully is customers wanting not to have uncleanly unmounted disks in the "shutting everything down to take an update" use-case, so it's my assumption that we would want to send the vmm_put_state with the appropriate timeout from policy in the instance table.

Yes, definitely. Unless the customers don't want to wait for graceful shutdown (disabling graceful shutdown would really speed up updates). In this case, I guess that means if they chose the HardOff shutdown policy.

@lifning

lifning commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor Author

in that case, looking at stop_batch in there, should i perhaps consider propagating the shutdown policy info into the vmm table so it's more readily accessible to the background task for that purpose? (forgive my relative diesel naivete if that's a silly question)

@karencfv

Copy link
Copy Markdown
Contributor

Do you mean propagating the policy to each VMM entry and then passing the policy via vmm_put_state() in stop_vmm() ?

I've only taken a look at this PR superficially, but I wonder if there is a way to have it so the background task doesn't need to know about the policy at all. When this task stops the VMM the system automatically shuts down the instances gracefully or not depending on the policy in each instance. Is that possible?

@lifning

lifning commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

I've only taken a look at this PR superficially, but I wonder if there is a way to have it so the background task doesn't need to know about the policy at all. When this task stops the VMM the system automatically shuts down the instances gracefully or not depending on the policy in each instance. Is that possible?

as i've implemented the sled-agent side of this (per the rfd), vmm_put_state just forwards whatever timeout is passed to it by nexus to propolis. so nexus is the thing responsible for retrieving the instance's shutdown policy from the instance table in the database whenever an instance stop/reboot is requested, and the sled-agent has no knowledge of what the instance's shutdown policy when it's servicing a vmm_put_state request besides what's included in the request itself.

@karencfv

Copy link
Copy Markdown
Contributor

Ah aha! I see now. Then yeah, I think your proposal of propagating the information to the VMM table makes sense.

karencfv added a commit that referenced this pull request Oct 27, 2026
Adds a task that gathers all stoppable VMMs that are marked to stop for
a sled evacuation during an update, and stops them.

Sample of how the information will be displayed:

Various successes, failures and errors
```console
    VMMs stopped for sled evacuation: 13 total
      sled_id=1b8c2e9a-4d3f-4b1e-9c7a-2f5e8d6b0a11 n_stopped=6
      sled_id=a4f0d7c3-8e2b-4c6d-b1f9-7e3a5c9d2b44 n_stopped=7
    VMMs that failed to stop: 7 total
      sled_id=1b8c2e9a-4d3f-4b1e-9c7a-2f5e8d6b0a11 n_failed_to_stop=3
        vmm_id=5c3e9f12-7a4b-4d8e-a2c6-1f9b3e7d5a08
        vmm_id=7f1a2b3c-4d5e-4f60-8a7b-9c0d1e2f3a41
        vmm_id=9d4e6f80-2b1c-4a3d-b5e6-0f7a8b9c1d52
      sled_id=a4f0d7c3-8e2b-4c6d-b1f9-7e3a5c9d2b44 n_failed_to_stop=4
        vmm_id=e2d8b4f6-1c9a-4e7b-8d3f-6a2c5b9e1f37
        vmm_id=0a1b2c3d-5e6f-4a70-9b81-c2d3e4f5a663
        vmm_id=3c4d5e6f-7a8b-4c9d-8e0f-1a2b3c4d5e74
        vmm_id=b6c7d8e9-0f1a-4b2c-9d3e-4f5a6b7c8d85
    Error messages: 2 total
      fake error 1
      fake error 2
```

No failures

```console
    VMMs stopped for sled evacuation: 13 total
      sled_id=1b8c2e9a-4d3f-4b1e-9c7a-2f5e8d6b0a11 n_stopped=6
      sled_id=a4f0d7c3-8e2b-4c6d-b1f9-7e3a5c9d2b44 n_stopped=7
```

Nothing happened
```console
    VMMs stopped for sled evacuation: 0 total
```

Note: graceful shutdown preferences will need to be integrated in
#11565, or once it lands

Related: #11169
Comment thread nexus/db-model/src/instance.rs Resolved
Comment thread nexus/src/app/mod.rs Resolved

@hawkw hawkw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As we discussed in the hypervisor huddle today, I think the best way to resolve the problem of needing the configured policy in the vmm_stop_for_update task is to make the query it's running do a JOIN with the VMM's instance record, rather than copying the policy into the vmm record. The latter means we would have to keep the two in sync when the policy changes, which seems fraught.

Comment thread nexus/defaults/src/lib.rs Resolved
Comment thread nexus/src/app/instance.rs Resolved
Comment thread schema/crdb/dbinit.sql Resolved
Comment thread schema/crdb/dbinit.sql Resolved
Comment thread sled-agent/src/instance.rs Resolved

@jgallagher jgallagher left a comment

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.

Skimmed over this in the same context as Karen (i.e., how this fits in with the reconfigurator work for sled evacuation) and had a few questions. Sorry if they're premature - I know this is a draft, but I'd be happy to cobble together a test branch that includes this and the outstanding reconfigurator bits to start testing it as soon as that's feasible.

Comment thread sled-agent/src/instance.rs Resolved
Comment thread sled-agent/src/instance.rs Resolved
jgallagher added a commit that referenced this pull request Nov 4, 2026
(This is pointed at #11565 and is one of that patches needed for it to
work with sled evacuation during updates.)

The main change here is that
`vmm_list_stoppable_for_update_by_sled_id()` now returns each VMM's
instance's shutdown policy alongside the VMM, and the
`vmm_stop_for_update` background task now sends that policy when it's
shutting down instances for sled evacuation.

A smaller change that came along for the ride was some cleanup around
the db representation of the shutdown policy:

* the model fields are now private, forcing callers to go through the
`shutdown_policy()` helper that reconstructs the Rust enum for the
policy
* `shutdown_policy()` now returns a `Result` instead of an `Option` -
returning an `Option` means the caller has to decide what to do with
`None`, which doesn't seem correct if the only way it can happen means
something has gone horribly wrong (i.e., our db constraints have been
violated). This bubbled out to changing some conversions from `.into()`
to `.try_into()`, but I think that's basically fine and consistent with
other types where we have to check at runtime that some unrepresentable
state hasn't made its way back to us from the db.

I don't expect CI tests to work on this branch since they don't on
#11565 either; I don't think that should block merging this since it's
really a part of that branch anyway.
jgallagher added a commit that referenced this pull request Nov 5, 2026
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 `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 pushed a commit that referenced this pull request Nov 5, 2026
(This is pointed at #11565 and is one of that patches needed for it to
work with sled evacuation during updates.)

The main change here is that
`vmm_list_stoppable_for_update_by_sled_id()` now returns each VMM's
instance's shutdown policy alongside the VMM, and the
`vmm_stop_for_update` background task now sends that policy when it's
shutting down instances for sled evacuation.

A smaller change that came along for the ride was some cleanup around
the db representation of the shutdown policy:

* the model fields are now private, forcing callers to go through the
`shutdown_policy()` helper that reconstructs the Rust enum for the
policy
* `shutdown_policy()` now returns a `Result` instead of an `Option` -
returning an `Option` means the caller has to decide what to do with
`None`, which doesn't seem correct if the only way it can happen means
something has gone horribly wrong (i.e., our db constraints have been
violated). This bubbled out to changing some conversions from `.into()`
to `.try_into()`, but I think that's basically fine and consistent with
other types where we have to check at runtime that some unrepresentable
state hasn't made its way back to us from the db.

I don't expect CI tests to work on this branch since they don't on
#11565 either; I don't think that should block merging this since it's
really a part of that branch anyway.
lifning pushed a commit that referenced this pull request Nov 5, 2026
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 pushed a commit that referenced this pull request Nov 6, 2026
(This is pointed at #11565 and is one of that patches needed for it to
work with sled evacuation during updates.)

The main change here is that
`vmm_list_stoppable_for_update_by_sled_id()` now returns each VMM's
instance's shutdown policy alongside the VMM, and the
`vmm_stop_for_update` background task now sends that policy when it's
shutting down instances for sled evacuation.

A smaller change that came along for the ride was some cleanup around
the db representation of the shutdown policy:

* the model fields are now private, forcing callers to go through the
`shutdown_policy()` helper that reconstructs the Rust enum for the
policy
* `shutdown_policy()` now returns a `Result` instead of an `Option` -
returning an `Option` means the caller has to decide what to do with
`None`, which doesn't seem correct if the only way it can happen means
something has gone horribly wrong (i.e., our db constraints have been
violated). This bubbled out to changing some conversions from `.into()`
to `.try_into()`, but I think that's basically fine and consistent with
other types where we have to check at runtime that some unrepresentable
state hasn't made its way back to us from the db.

I don't expect CI tests to work on this branch since they don't on
#11565 either; I don't think that should block merging this since it's
really a part of that branch anyway.
lifning pushed a commit that referenced this pull request Nov 6, 2026
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 -809 to -811
VmmStateRequested::Running => {
let vmms = self.vmms.clone();
let log = self.log.new(

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.

the previous behavior of sled-agent-sim here: when there's a mock propolis, and Run is requested: not send anything to propolis, spawn a task that sleeps 10 seconds before calling sim_ensure(), and early-return VmmPutStateResponse { updated_runtime:None }. this was peculiar and seems like just a bug, as none of the small handful of integ tests calling start_local_mock_propolis_server rely on this behavior at all, and it does not apply to the vast majority of tests not starting a mock propolis.

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.

It looks like the old behavior here is from #4691. The PR description seems reasonable, I think? Specifically the

in this world where instance create calls to nexus now no longer block on sled-agent's propolis zone installation finishing, care must be taken in e.g. integ tests not to assume you can, say, connect to the instance as soon as the instance create call returns. accordingly, integ tests have been changed to poll until the instance is ready.

bit. Do you happen to remember more about the original intent?

@lifning lifning Nov 12, 2026 •

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.

i believe the intent for this snippet was to make the one integ test that used a mock propolis behave realistically, as described.

noble as the intent may have been, the code block as written isn't really advancing that goal in a way that matters any more. it isn't relevant to any current tests other than test_instance_serial; mock_lock is none everywhere else*.

(* a few tests to do with handling of anti-affinity groups and ssh keys do invoke .start_local_mock_propolis_server(), but have nothing in their test logic about whether instances reach the running state that this would impact; perhaps its invocation at all in these was an artifact of duplicated test heading boilerplate?)

nowadays, i believe the goal of not having instance states be immediately reflected in instance integ tests is achieved by way of instance_simulate and instance_wait_for_state - and the former is called by the serial test in its own custom version of the latter

prototyping rfd622: acpi api plumbing

further wip: figuring out db schema for acpi power button

external api versioning wrappers for instance endpoints

still working on the db schema

wip - wired enough up of shutdown policy to pass simple cargo check

further wip: now with cargo check --tests

sled agent api versioning, regen openapi

consistent column order between dbinit and up*

missed a spot with column order consistency & default to 10 minutes when shutdown policy underspecified in create request & also just point to the propolis PR branch for this

fill in some TODOs, mostly doc comments

add override param to instance stop and reboot nexus endpoints, and wire up instance update params in diesel

start making tests for shutdown policy. also, consider the case of an instance update request that *doesn't* change the shutdown policy

more acpi shutdown integ test. i think the most appropriate way to test this will be to add a little escape hatch to mock propolis

integ test for shutdown feature

wip - acpi shutdown cleanups, trying to get integ test working

still working on shutdown integ test, but now figured out the workarounds needed for mock propolis server to participate in the way we need

don't clamp acpi timeout in DbInstance

elaborate a bit on InstanceCreate and InstanceUpdate request shutdown_policy fields

wip - notes on my current fixquest

wip - out of one bug, into another..

fix further issues with mock-propolis / sled-agent-sim (former does not like being started with different vmm id), now shutdown integ tests partially passing, but need to convince nexus to be comfortable sending hard-stop requests to an instance that only received a soft-stop so far

wip - another test case. still puzzling on the most appropriate way to address the fact the instance update saga yoinks the vmm record for the first soft-off request such that the subsequent hard-off doesn't make it through

oh, it was sled-agent-sim again. good.

oops sorry clippy

move consts to a common denominator of nexus-db-model and nexus - per pr feedback (thanks eliza)

helix got a bit confused this evening

addressing a few pr comments

also fixup: unwritten buffer amid a rebase :(

missed the upper bound on the CHECK conditions
@jordanhendricks
jordanhendricks self-requested a review November 16, 2026 20:04
Comment thread nexus/db-model/src/instance.rs Resolved

@jordanhendricks jordanhendricks left a comment •

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.

Looked through this just for additional context / knowledge sharing. One important comment around the API restrictions (lowering the timeout allowed) but nothing else.

I also left a comment on the propolis side that we should consider moving the shtudown timeout handling into sled-agent instead of having propolis do that: oxidecomputer/propolis#1217 (comment).

I don't know what the lift is there, and it doesn't seem super important to figure out before merging this.

Comment on lines +37 to +38
// RFD 622: "A user-configurable timeout for the instance to finish stopping
// itself should be present, bounded between 1 and 3600 seconds, inclusive."

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.

+1, I think a much shorter timeout is prudent until we hear customers clamoring for it for some reason (and it would be good to understand why).

@lifning
lifning marked this pull request as ready for review November 19, 2026 21:43

@david-crespo david-crespo left a comment

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.

API and docs look good to me. Looks like you need to merge main because your API version got taken.

@iximeow

iximeow commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

your API version got taken

that was me adding conflicts on every InstanceCreate by merging #11858 lol. I'd promised to merge back up here and resolve conflicts, which 9e859b1 does.

... unfortunately that commit is victim to "buildomat is currently wedged", so that's deeply unfortunate.

@david-crespo

david-crespo commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Sorry yeah I misread, I see now 111000 and 111100 are different :)

image

@iximeow iximeow left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I have a smattering of comments but the top-line is I'm down to click the button too. most important "we should probably not pub use sled_agent_types_versions in Nexus", and if we give this a moment (helios/deploy is helping in its own way..) I'll push a commit to fix that in this initial external API version, otherwise we can of course Just Fix It at any later point.

Comment thread sled-agent/src/instance.rs Resolved
Comment thread sled-agent/src/instance.rs Resolved
Comment thread sled-agent/src/instance.rs Resolved
Comment thread sled-agent/src/instance.rs Resolved
Comment on lines +25 to +26
pub use sled_agent_types_versions::v66::instance::{
AcpiTimeoutSecs, InstanceShutdownPolicy,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

re-using the client types from a different API here was very surprising - I was going to remark that we should leave a better comment on InstanceShutdownPolicy for ourselves reading later, that the doc comment on InstanceCreate::shutdown_policy seems great, and that we should probably just copy it before realizing that the sled-agent client type is the external API type.

I realize we've done this elsewhere (bgp_peer_src_addr does this with RouterPeerType in the external BgpPeer struct) but it definitely pokes a hole in my mental model that sled-agent's API is very internal!

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.

it was certainly a little strange for me too, but per #11565 (comment) they're at least both versioned.. though yeah, the difference in docstring audience is certainly a factor

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.

I realize we've done this elsewhere (bgp_peer_src_addr does this with RouterPeerType in the external BgpPeer struct) but it definitely pokes a hole in my mental model that sled-agent's API is very internal!

Yeah that's fair; this has come up several times and I think neither option is fantastic:

  • Use one type (defined in sled-agent-types-versions, used/re-exported by nexus-types): this is surprising in the way you mentioned
  • Use two separate types, but defined identically: this is annoying in all the normal ways having the same type defined twice are ("expected Foo but got Foo" errors, and if you want to change the type you have to redefine both)

I personally prefer the former; it means there's just one place where the type is defined (although as you noted, it's important that one place's docs be written as though it's for the external API, which isn't obvious/ideal). If there are future changes to the type, we have either:

  • We want both sled-agent and nexus to change the same way (I think this is by far the most common; usually these are types that we receive in Nexus and end up passing through to sled-agent, as in the InstanceShutdownPolicy case): Add a new version in sled-agent-types-versions the normal way, then add a new nexus-types versions that only needs to re-export the new sled-agent type
  • We want them to diverge: this is fine; we can split them at this point if they actually need to be different

Comment on lines +81 to +82
fn try_from(value: u64) -> Result<Self, Self::Error> {
if value < Self::MIN || value > Self::MAX {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this is because we're trying to keep schemars in line with what the column constraints actually are, right? since the constraint still has 3600 seconds as a maximum (as noted on the AcpiTimeoutSecs doc comment) at the very least we're checking different things in different places..

@lifning lifning Nov 21, 2026 •

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.

whoops 💀 definitely wanna fix that once the whole waiting-for-buildomat situation clears up... but would want to get that in right away so as not to make a whole new schema revision about it, i think? maybe it's ok to eat the CI delay to not risk it

Comment thread nexus/db-model/src/instance.rs Resolved
@lifning

lifning commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author

I have a smattering of comments but the top-line is I'm down to click the button too. most important "we should probably not pub use sled_agent_types_versions in Nexus", and if we give this a moment (helios/deploy is helping in its own way..) I'll push a commit to fix that in this initial external API version, otherwise we can of course Just Fix It at any later point.

if the tyranny of helios/deploy is not too daunting i tried to address most of this in https://github.com/oxidecomputer/omicron/compare/lif/acpi-shutdown..lif/acpi-shutdown-followup

@iximeow

iximeow commented Nov 21, 2026

Copy link
Copy Markdown
Member

https://github.com/oxidecomputer/omicron/compare/lif/acpi-shutdown..lif/acpi-shutdown-followup

oh nice, that looks good across the board to me - thanks! I think what we probably ought to do is see where helios/deploy gets on the respective commits, and when we decide to merge things we can figure out if we fast-forward this to the hopefully-also-passing lif/acpi-shutdown-followup, or if we'll be collectively sad about the state of CI and actually make that a different change.

@iximeow
iximeow merged commit 08a04d2 into main Nov 22, 2026
21 checks passed
@iximeow
iximeow deleted the lif/acpi-shutdown branch November 22, 2026 01:49
@iximeow

iximeow commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

given that my commits here are really just "fixing the conflict I caused" I feel there's no conflict of interest in both approving and clicking the button :) for the record, I did a bit of commit message editing vs the PR description in the squash: the description of PUT /v1/instances/{instance} had gotten stale and the policy description still also suggested the upper limit of the shutdown timeout was an hour. I also moved the ACPI spec links out of line so a skim of the git log reads more normally.

ok! CI is happy! it's in! yay!

Comment on lines +26 to +36
pub enum InstanceShutdownPolicy {
/// Instance's VM is forcefully terminated immediately.
// default to hard-off, preserving the existing behavior of our system prior
// to ACPI shutdown support
#[default]
HardOff,
/// Instance is sent PWRBTN_STS as described in ACPI chapter 4. If the VM
/// guest has not stopped itself with a power event within the given
/// timeout, it is *then* forcefully terminated.
PowerButton { timeout_secs: AcpiTimeoutSecs },
}

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.

unfortunately, this doesn't have a readily generated CLI output and causes the oxide instance update subcommand to require a --json-body parameter--inconvenient and unfortunate.

I'm unsure of how the two options (and the timeout) could be expressed nicely in the CLI.

Generation = omicron_generation_kinds::Generation,
Hostname = omicron_common::api::external::Hostname,
ImportExportPolicy = sled_agent_types_versions::latest::early_networking::ImportExportPolicy,
InstanceShutdownPolicy = sled_agent_types_versions::latest::instance::InstanceShutdownPolicy,

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.

InstanceShutdownPolicy is an inert enum with no impls; why are we replacing it?

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.

I think this is so the type we receive in Nexus can be passed through as-is and doesn't have to be converted into the progenitor-produced type? (#11565 (comment) strongly related)

Comment on lines +50 to +55
pub struct AcpiTimeoutSecs(#[schemars(range(min = 1, max = 900))] u64);

// 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.
const _: () = const { assert!(AcpiTimeoutSecs::MIN == 1) };
const _: () = const { assert!(AcpiTimeoutSecs::MAX == 900) };

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.

this just translates to a NonZeruU64 in progenitor/typify. Were you hoping that it would turn into some other type?

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.

10 participants