Begin using typed instance and Propolis UUIDs in sled agent and Nexus #5896
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
One goal of the ongoing Great Instance State Rework of 2024 is to clarify that, in broad strokes, Nexus manages instances and sled agents manage VMMs. Nexus decides whether and when an instance is connected to a VMM and how to convert VMM states to instance states; sled agents manage individual Propolis processes and send their state changes to Nexus so that it has the relevant VMM states available.
Today, sled agent's instance manager tracks VMMs in a map with type
BTreeMap<Uuid, (Uuid, Instance)>
, where the keys are instance IDs and the values contain Propolis IDs. In our proposed brave new world, sled agent can use Propolis IDs as keys and may not need instance IDs at all--i.e., its map type should beBTreeMap<PropolisUuid, Vmm>
, where theVmm
may or may not contain anInstanceUuid
.To support this future change, change sled agent's instance map to a
BTreeMap<InstanceUuid, (PropolisUuid, Instance)>
and work through all the compiler-error fallout. This causes the difference between instance and Propolis UUIDs to filter all the way up through Nexus's instance management routines and sagas. This should make it much easier to refactor sled agent's APIs to take Propolis IDs, since the compiler can then help catch instance and Propolis ID transpositions.Nexus's instance management code often deals with instance IDs, Propolis IDs, and sled IDs together, so also start using
SledUuid
in some of these paths.This change draws an arbitrary line at using typed UUIDs in database model types and in the generated resource objects in the authz layer; calls into/out of these layers use
GenericUuid
andfrom_untyped_uuid
/into_untyped_uuid
as needed.(This is not because these changes are necessarily impossible, merely because the line had to go somewhere.)Tests:
cargo nextest
; while this change is large, it should by and large be a rote refactoring exercise.