Skip to content

Commit

Permalink
return 503 when instance is wayyyyy gone
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkw committed Aug 30, 2024
1 parent a2e6c99 commit ef11b93
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
10 changes: 8 additions & 2 deletions nexus/src/app/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,14 @@ impl From<SledAgentInstanceError> for dropshot::HttpError {
HttpError::for_internal_error(s)
}
// Error responses from sled-agent that indicate the instance is
// unhealthy should be mapped to a 500 error.
e if e.vmm_gone() => HttpError::for_internal_error(e.to_string()),
// unhealthy should be mapped to a 503 error.
e if e.vmm_gone() => {
let mut error = HttpError::for_unavail(None, e.to_string());
error.external_message = "The instance was running but is no \
longer reachable. It is being moved to the Failed state."
.to_string();
error
}
// Other client errors can be handled by the normal
// `external::Error` to `HttpError` conversions.
SledAgentInstanceError(e) => HttpError::from(Error::from(e)),
Expand Down
8 changes: 4 additions & 4 deletions nexus/tests/integration_tests/instances.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1118,11 +1118,11 @@ async fn test_instance_failed_after_sled_agent_forgets_vmm_can_be_restarted(
let instance_id = make_forgotten_instance(&cptestctx, instance_name).await;

// Attempting to reboot the forgotten instance will result in a 404
// NO_SUCH_INSTANCE from the sled-agent, which Nexus turns into a 500.
// NO_SUCH_INSTANCE from the sled-agent, which Nexus turns into a 503.
expect_instance_reboot_fail(
client,
instance_name,
http::StatusCode::INTERNAL_SERVER_ERROR,
http::StatusCode::SERVICE_UNAVAILABLE,
)
.await;

Expand All @@ -1146,11 +1146,11 @@ async fn test_instance_failed_after_sled_agent_forgets_vmm_can_be_deleted(
let instance_id = make_forgotten_instance(&cptestctx, instance_name).await;

// Attempting to reboot the forgotten instance will result in a 404
// NO_SUCH_INSTANCE from the sled-agent, which Nexus turns into a 500.
// NO_SUCH_INSTANCE from the sled-agent, which Nexus turns into a 503.
expect_instance_reboot_fail(
client,
instance_name,
http::StatusCode::INTERNAL_SERVER_ERROR,
http::StatusCode::SERVICE_UNAVAILABLE,
)
.await;

Expand Down

0 comments on commit ef11b93

Please sign in to comment.