Skip to content

[sled-agent] don't use use_only_currently_managed_zpools - #11497

Merged
hawkw merged 3 commits into
mainfrom
eliza/theres-a-better-way-to-do-the-zpools-thing
Oct 15, 2026
Merged

hawkw merged 3 commits into
mainfrom
eliza/theres-a-better-way-to-do-the-zpools-thing

Conversation

@hawkw

@hawkw hawkw commented Oct 14, 2026

Copy link
Copy Markdown
Member

This change makes it so that sled-agent can ensure that it's using only currently-managed zpools without using
use_only_currently_managed_zpools. :)

At present, the mechanism that sled-agent uses to ensure that any Propolis zones whose zone-root filesystems are on zpools that no longer exist is the InstanceManager::use_only_currently_managed_zpools method. This is called in the InstanceManager main loop when the set of currently-managed zpools changes, and works by looping over all managed instances, asking them which zpool the root filesystem for the Propolis zone is on, and then telling the InstanceRunner to terminate the Propolis zone if it is on a zpool that is no longer managed. Because this occurs within the InstanceManager main loop, it's important that nothing that happens here can prevent that loop from making progress indefinitely, as it would prevent any unrelated instance management operations from running.

In #11492, I made an attempt to tidy this up a bit by having the InstanceRunner publish its zpool separately from its main request channel. After thinking it through, though, @smklein, @jgallagher, and I all came to the conclusion (see this comment) that there's actually a much better way of doing this. Rather than having the InstanceManager loop over all instances and check if they are using un-managed zpools, we can just give the watch channel of currently managed zpools to each InstanceRunner, and have it wait for changes to that set and check whether its zpools are still in the currently managed set.

This avoids a lot of the potential raciness with publishing the zpool name once the zone is running, since we can just wait to spawn a task to wait for changes to the set of currently-managed zpools only once a zone is actually running. After that point, the zpool name will never change, and we cannot race with creating the zone or get stuck if the zone fails to start. This simplifies a lot of other aspects of the implementation, too, since it makes one of the two paths to instance termination completely internal to the instance.rs module, and we no longer have to do any of this work in the InstanceManager main loop. We no longer need the GetFilesystemZpool request to the InstanceRunner actor at all, because the task is now spawned with the zpool name once it's determined. Building on the changes to termination in #11462, the entire "zpool no longer managed, terminate propolis forcefully" path is now completely separate from the synchronous (well, async-but-actor-blocking) request/response channels in both InstanceManager and InstanceRunner.

Closes #11492

This change makes it so that sled-agent can ensure that it's using only
currently-managed zpools without using
`use_only_currently_managed_zpools`. :)

At present, the mechanism that sled-agent uses to ensure that any
Propolis zones whose zone-root filesystems are on zpools that no longer
exist is the `InstanceManager::use_only_currently_managed_zpools`
method. This is called in the `InstanceManager` main loop when the set
of currently-managed zpools changes, and works by looping over all
managed instances, asking them which zpool the root filesystem for the
Propolis zone is on, and then telling the `InstanceRunner` to terminate
the Propolis zone if it is on a zpool that is no longer managed. Because
this occurs within the `InstanceManager` main loop, it's important that
nothing that happens here can prevent that loop from making progress
indefinitely, as it would prevent any unrelated instance management
operations from running.

In #11492, I made an attempt to tidy this up a bit by having the
`InstanceRunner` publish its zpool separately from its main request
channel. After thinking it through, though, @smklein, @jgallagher, and I
all came to the conclusion (see [this comment][1]) that there's actually
a much better way of doing this. Rather than having the
`InstanceManager` loop over all *instances* and check if they are using
un-managed zpools, we can just give the `watch` channel of currently
managed zpools to each `InstanceRunner`, and have it wait for changes to
that set and check whether its zpools are still in the currently managed
set.

This avoids a lot of the potential raciness with publishing the zpool
name once the zone is running, since we can just wait to spawn a task to
wait for changes to the set of currently-managed zpools only once a zone
is actually running. After that point, the zpool name will never change,
and we cannot race with creating the zone *or* get stuck if the zone
fails to start. This simplifies a lot of other aspects of the
implementation, too, since it makes one of the two paths to instance
termination completely internal to the `instance.rs` module, and we no
longer have to do any of this work in the `InstanceManager` main loop.
We no longer need the `GetFilesystemZpool` request to the
`InstanceRunner` actor at all, because the task is now spawned with the
zpool name once it's determined. Building on the changes to termination
in #11462, the entire "zpool no longer managed, terminate propolis
forcefully" path is now completely separate from the synchronous (well,
async-but-actor-blocking) request/response channels in both
`InstanceManager` and `InstanceRunner`.

Closes #11492

[1]:
https://github.com/oxidecomputer/omicron/pull/11492/changes/BASE..837f552c06380587eba3526da5236cce68983bea#r4275100226

@smklein smklein left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

sweet, like this approach a lot more

Comment thread sled-agent/src/instance.rs Resolved
Comment on lines +561 to +563
// For logging.
instance_id: InstanceUuid,
propolis_id: PropolisUuid,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Are these not already present as keys in the logger we pass to the Terminator functions?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

they are when it's terminated by the zpool_monitor task, but the other termination comes from InstanceManager, where they are not part of the logger that's passed in there, which is why I added them.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think potentially there is room for some more logging cleanup here, in general --- I was surprised that a large amount of the InstanceRunner logs appear to include only the instance ID and not the Propolis ID. But I wanted to keep the diff small in this PR.

@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.

Yeah, this solution worked out really nicely!

@hawkw
hawkw merged commit 5d5a4c4 into main Oct 15, 2026
20 checks passed
@hawkw
hawkw deleted the eliza/theres-a-better-way-to-do-the-zpools-thing branch October 15, 2026 16:03
@hawkw

hawkw commented Oct 15, 2026

Copy link
Copy Markdown
Member Author

It occurs to me that we may be able to make a similar change to the ProbeManager code that also has a "loop over all probes and destroy any using zpools that no longer exist" function like use_only_currently_managed_zpools, but I'm a lot less familiar with that part of sled-agent.

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.

3 participants