Repository navigation
sled-agent / illumos-utils: refactor PathInPool - #11495
Conversation
bnaecker
left a comment
There was a problem hiding this comment.
Nice, makes more sense that the instance's pool is never optional. Thanks!
|
@jgallagher while I'm in favor of this change overall, I think I'd rather it be based on #11497 rather than #11492, since I'm hoping we can use that approach for terminating the Propolis zone when the zpool goes away. |
| pub struct PathInPool { | ||
| pub pool: ZpoolName, | ||
| pub path: Utf8PathBuf, | ||
| } |
There was a problem hiding this comment.
I wonder if we might consider making the fields private, and having a constructor that validates that the path actually is in the pool. But, that might make the existing uses of this kinda painful, so I dunno...
There was a problem hiding this comment.
Yeah I had both of those same thoughts too. I know the consumers of this end up destructuring it to get path without cloning, but I guess it could have an .into_parts() that returned both fields too? I'll give this a whirl after rebasong onto #11497.
9c5079f to
286a167
Compare
…disk` `illumos-utils` supports running zones with a root filesystem on a zpool (most zones) or a ramdisk (the switch zone). Prior to this change, it exposed a `PathInPool` type that could represent both. That type was used in several places where the only possible value was "on a zpool", but the type still allowed the representation of "on a ramdisk". This change adds a second type, `PathInPoolOrRamdisk`, and reserves `PathInPool` for those spots where we know the only option is "on a zpool".
This returned a `ZpoolOrRamdisk`, but its only two callers (sled-agent's instance and probe manager subsystems) only ever start zones on zpools. They now remember which zpool they picked and no longer call this method, allowing us to delete it and removing the internal unrepresentable state of "an instance or probe with a root on a ramdisk".
This formerly took a struct containing the path and its parent zpool, but we no longer need the parent zpool. Take the path directly.
286a167 to
119267d
Compare
|
Ok, this is rebased onto main after the #11497 merge and ready for another look. I had to touch up the |
hawkw
left a comment
There was a problem hiding this comment.
Sorry it took me a minute to review this one, but this looks great --- it's nice to see a bunch of error variants being removed because they're now unrepresentable!
| &self.path | ||
| } | ||
|
|
||
| pub fn into_path(self) -> Utf8PathBuf { |
There was a problem hiding this comment.
I suppose we don't really need an into_parts that returns both because ZpoolName is Copy and you can just get it from pool() first?
| _zpool_monitor_handle: Option<AbortOnDropHandle<()>>, | ||
| _zpool_monitor_handle: AbortOnDropHandle<()>, |
(This is stacked on top of #11492.)
I thought about opening this as a stack of PRs, but the total diff is still pretty small and mostly churns on itself, so instead it's just one PR with a stack of commits. Feel free to review those individually if "how did we get from A to B" is useful.
The major changes are:
RunningZone::root_zpool()is gone. The two callers of this (the instance and probe managers in sled-agent) now remember the zpool they chose for the zones they start.illumos-util's zone-starting functions now take the zone root path as aUtf8PathBufinstead of aPathInPool. (illumos-utilsitself only ever needed thepath, except to return the pool inroot_zpool(), which is now removed.)PathInPool::poolis now aZpoolName, not aZpoolOrRamdisk.ZpoolOrRamdiskis removed. This let us drop some awkward "what if we have a zone on a ramdisk that can never be on a ramdisk in practice" handling bits in a few different places.