Skip to content

Commit

Permalink
Make PUT /instance/state 503 when waiting to init
Browse files Browse the repository at this point in the history
Also, I noticed that the `PUT /instance/state` API route would return a
`NoInstance` error when trying to change the state returned a
`VmError::WaitingToInitialize`, which seemed potentially bad: this would
result in a sled-agent that tries to send a state change request to a
still-initializing VM to believe it's Permanently Gone, and mark it as
`Failed`, tear down the zone, and so on. Which seems rude of it!

I don't think this is likely to be a problem in practice since IIRC both
sled-agent and Nexus will not try to send state change requests to
instances that they understand to be still initializing, but it seemed
good to not return the INSTANCE IS PERMANENTLY GONE error code here.
Now, we return a 503, so the sled-agent will just know it needs to wait
for a bit.
  • Loading branch information
hawkw committed Sep 30, 2024
1 parent de22049 commit 7e2a3ca
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion bin/propolis-server/src/lib/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,10 @@ async fn instance_state_put(
.put_state(requested_state)
.map(|_| HttpResponseUpdatedNoContent {})
.map_err(|e| match e {
VmError::WaitingToInitialize => not_created_error(),
VmError::WaitingToInitialize => HttpError::for_unavail(
None,
"instance is still initializing".to_string(),
),
VmError::ForbiddenStateChange(reason) => HttpError::for_status(
Some(format!("instance state change not allowed: {}", reason)),
hyper::StatusCode::FORBIDDEN,
Expand Down

0 comments on commit 7e2a3ca

Please sign in to comment.