Skip to content

Commit

Permalink
defer returning from error until instance state is updated
Browse files Browse the repository at this point in the history
  • Loading branch information
gjcolombo committed Apr 12, 2023
1 parent c1089f3 commit 7672fcf
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions sled-agent/src/instance.rs
Expand Up @@ -554,23 +554,28 @@ impl Instance {
)
.await?;
} else {
// If there's no Propolis yet, and this instance is not being
// initialized via migration, immediately send a state update to
// Nexus to reflect that the instance is starting (so that the
// external API will display this state while the zone is being
// started).
//
// Migration targets don't do this because the instance is still
// logically running (on the source) while the target Propolis is
// being launched.
if migration_params.is_none() {
inner.state.transition(InstanceState::Starting);
inner.publish_state_to_nexus().await?;
}
let setup_result: Result<(), Error> = 'setup: {
// If there's no Propolis yet, and this instance is not being
// initialized via migration, immediately send a state update to
// Nexus to reflect that the instance is starting (so that the
// external API will display this state while the zone is being
// started).
//
// Migration targets don't do this because the instance is still
// logically running (on the source) while the target Propolis
// is being launched.
if migration_params.is_none() {
inner.state.transition(InstanceState::Starting);
if let Err(e) = inner.publish_state_to_nexus().await {
break 'setup Err(e);
}
}

let setup_result: Result<(), Error> = {
// Set up the Propolis zone and the objects associated with it.
let setup = self.setup_propolis_locked(inner).await?;
let setup = match self.setup_propolis_locked(inner).await {
Ok(setup) => setup,
Err(e) => break 'setup Err(e),
};

// Direct the Propolis server to create its VM and the tasks
// associated with it. On success, the zone handle moves into
Expand All @@ -581,9 +586,7 @@ impl Instance {
setup,
migration_params,
)
.await?;

Ok(())
.await
};

// If this instance started from scratch, and startup failed, move
Expand Down

0 comments on commit 7672fcf

Please sign in to comment.