Skip to content

Rip InstanceRuntimeState out of the internal API #6556

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Sep 11, 2024

Conversation

hawkw
Copy link
Member

@hawkw hawkw commented Sep 11, 2024

The omicron_common::api::internal::InstanceRuntimeState type was once
a key component of how Nexus and sled-agents communicated about
instances. Now, however, it's outlived its usefulness: #5749 changed
Nexus' cpapi_instances_put and sled-agent's instance_get APIs to
operate exclusively on VmmRuntimeStates rather than
InstanceRuntimeState, with the sled-agent almost completely unaware of
InstanceRuntimeState.

At present, the InstanceRuntimeState type remains in the internal API
just because it's used in the InstanceEnsureBody type, which is sent
to sled-agent's instance_ensure_registered API when a new VMM is
registered. However, looking at the code that
instance_ensure_registered calls into in sled-agent, we see that the
only thing from the InstanceRuntimeState that the sled-agent actually
uses is the migration ID of the current migration (if the instance is
migrating in). Soooo...we can just replace the whole
InstanceRuntimeState there with a migration_id: Option<Uuid>. Once
that's done, there are now no longer any internal APIs in Nexus or in
sled-agent that actually use InstanceRuntimeState, so the type can be
removed from the internal API entirely. All of the code in Nexus that
deals with instance runtime states already has changed to operate
exclusively on the nexus_db_model version of the struct, so removing
the API type is actually quite straightforward.

In addition, I've refactored the sled-agent instance_ensure_registered
code paths a little bit to pass around the InstanceEnsureBody, rather
than unpacking its fields at the HTTP entrypoint and then passing them
all through the chain of method calls that actually gets it to the
instance-runner task. Just passing the struct around means we can remove
a bunch of #[allow(clippy::too_many_arguments)] attributes. It also
makes changing the contents of the instance-ensure payload a bit easier,
as we'll no longer need to change the arguments list in the whole maze
of tiny little functions, all alike, that pass around all the pieces of
the InstanceEnsureBody.

Passing the `InstanceEnsureBody` all the way through to the
instance-runner task, instead of unpacking it and passing its pieces as
arguments, lets us get rid  of the
`#[allow::clippy_too_many_arguments]` that are sprinkled around. It also
means that if a subsequent change adds additional fields to the
instance-ensure payload, we don't need to change all these function
signatures just to add them.
@hawkw hawkw requested a review from gjcolombo September 11, 2024 20:05
@hawkw hawkw enabled auto-merge (squash) September 11, 2024 20:13
@hawkw hawkw merged commit a54bf38 into main Sep 11, 2024
17 checks passed
@hawkw hawkw deleted the eliza/no-more-api-runtime-states branch September 11, 2024 22:50
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.

2 participants