Skip to content

Invert dependency between sled-agent-types and illumos-utils#10158

Merged
jgallagher merged 7 commits intomainfrom
john/invert-illumos-utils-sled-agent-types-dep
Mar 26, 2026
Merged

Invert dependency between sled-agent-types and illumos-utils#10158
jgallagher merged 7 commits intomainfrom
john/invert-illumos-utils-sled-agent-types-dep

Conversation

@jgallagher
Copy link
Contributor

Both @bnaecker and @zeeshanlakhani recently bumped into issues where the fact that sled-agent-types-versions depends on illumos-utils caused pain, because we needed to add or change types that are defined or consumed by illumos-utils, but those types appear in the sled-agent API and therefore also need to be versioned. We can't put them in sled-agent-types-versions because that creates a cycle between the two crates, but putting them in illumos-utils means they can't (easily) be versioned.

We talked about two possible solutions to this:

  1. Add a new *-types-versions + *-types crate that both illumos-utils and sled-agent-types-versions can depend on. [multicast] M2P forwarding, OPTE port subscription, and sled-agent propagation #10070 starts down this path.
  2. Invert the dependency: if illumos-utils could depend on sled-agent-types instead of the other way around, we can put the types in sled-agent-types-versions as we'd prefer for versioned types.

This PR implements the second of those, but I'm not totally sold it's the right way to go - maybe it would be cleaner to have a lower-level types crate shared by both. I did want to see how painful it was, and it wasn't too bad.

My gut feeling is that the changes here fall into three categories:

  1. Definite win: it moves definitions of types that appear in the sled-agent API out of illumos-utils and into sled-agent-types-versions, allowing them to be cleanly versioned in the future. (Svc, SvcState, ZpoolHealth)
  2. Seems fine either way: From impls converting between illumos-utils types and sled-agent types now live in illumos-utils instead of sled-agent-types-versions (AttachedSubnet, AttachedSubnetKind, SvcsResult, DatasetProperties)
  3. Seems slightly worse but I could live with it: The one place sled-agent-types used functionality from illumos_utils that didn't make sense to move was OmicronZoneConfig::zone_name(), which calls a function in illumos_utils to construct a zone name. I moved this to an OmicronZoneConfigExt extension trait defined by illumos_utils; I don't love this but on balance I think it's worth taking to get point 1?

Copy link
Collaborator

@bnaecker bnaecker left a comment

Choose a reason for hiding this comment

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

This is great! Much smaller than I feared.

pub struct ZpoolHealthParseError(pub String);

// TODO-correctness `ZpoolHealth` implements both `FromStr` and `Display`, but
// they aren't symmetric - we should replace one of these (probably `FromStr`?)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree with replacing FromStr. That looks like it's parsing the CLI tool output format.

Copy link
Collaborator

@zeeshanlakhani zeeshanlakhani left a comment

Choose a reason for hiding this comment

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

I do think this limits the complexity of solution #1. As we discussed in chat, its seems that much of illumos-utils (excepting zone naming) it mainly targeting the sled-agent context. Nonetheless, it seems like the original goals of illumos-utils was somewhat murky and that it was meant to be more general?

Nonetheless, this is a nice, focused PR, and helps us in the now.

@jgallagher jgallagher merged commit f4dd98d into main Mar 26, 2026
17 checks passed
@jgallagher jgallagher deleted the john/invert-illumos-utils-sled-agent-types-dep branch March 26, 2026 17:09
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