Repository navigation
[sled-agent] don't use use_only_currently_managed_zpools - #11497
Conversation
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
left a comment
There was a problem hiding this comment.
sweet, like this approach a lot more
| // For logging. | ||
| instance_id: InstanceUuid, | ||
| propolis_id: PropolisUuid, |
There was a problem hiding this comment.
Are these not already present as keys in the logger we pass to the Terminator functions?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
Yeah, this solution worked out really nicely!
|
It occurs to me that we may be able to make a similar change to the |
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_zpoolsmethod. This is called in theInstanceManagermain 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 theInstanceRunnerto terminate the Propolis zone if it is on a zpool that is no longer managed. Because this occurs within theInstanceManagermain 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
InstanceRunnerpublish 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 theInstanceManagerloop over all instances and check if they are using un-managed zpools, we can just give thewatchchannel of currently managed zpools to eachInstanceRunner, 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.rsmodule, and we no longer have to do any of this work in theInstanceManagermain loop. We no longer need theGetFilesystemZpoolrequest to theInstanceRunneractor 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 bothInstanceManagerandInstanceRunner.Closes #11492