Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions sled-agent/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2210,6 +2210,7 @@ impl InstanceRunner {
state: VmmStateRequested,
) -> Result<SledVmmState, Error> {
use propolis_client::types::InstanceStateRequested as PropolisRequest;

let (propolis_request, next_published) = match state {
VmmStateRequested::MigrationTarget(migration_params) => {
if let Err(e) =
Expand Down Expand Up @@ -2262,25 +2263,23 @@ impl InstanceRunner {
if self.running_state.is_none() {
return Err(Error::VmNotRunning(self.propolis_id));
}

(
Some(PropolisRequest::Reboot),
Some(PublishedVmmState::Rebooting),
)
}
};

// All the arms above should either create a Propolis zone on success or
// check that one already exists. Note that the calls that create the
// zone also send a VM creation request to the new Propolis process, but
// this is trickier to assert without actually calling the Propolis API.
assert!(
self.running_state.is_some(),
"should have an active Propolis zone by now"
);
// If `propolis_request` is Some leaving the above match group, there
// must be a Some `self.running_state`, i.e. if there is a request to
// send to the propolis process, there must be a propolis process.
// `propolis_state_put` unwraps `self.running_state` and will panic the
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

does the unwrap have a useful error message, and if not, should it be changed to an expect() with the message from the old assertion?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yeah:

        let res = self
            .running_state
            .as_ref()
            .expect("Propolis client should be initialized before usage")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

great, looks good to me then!

// sled agent if this is not true.

// Since there's an active Propolis zone with an extant VM, it's
// possible to ask Propolis to drive the VM state machine.
if let Some(p) = propolis_request {
// Since there's an active Propolis zone with an extant VM, it's
// possible to ask Propolis to drive the VM state machine.
if let Err(e) = self.propolis_state_put(p).await {
match propolis_error_code(&self.log, &e) {
Some(
Expand Down Expand Up @@ -2311,9 +2310,11 @@ impl InstanceRunner {
}
}
}

if let Some(s) = next_published {
self.state.transition_vmm(s, Utc::now());
}

Ok(self.state.sled_instance_state())
}

Expand Down
Loading