Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
Created using spr 1.3.5
  • Loading branch information
sunshowers committed Nov 17, 2023
1 parent cf49558 commit a6716e3
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions wicketd/src/http_entrypoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,8 @@ async fn post_start_update(
// out of an abundance of caution).
//
// First, get our most-recently-cached inventory view. (Only wait 80% of
// WICKETD_TIMEOUT for this -- if the inventory isn't available, then we
// WICKETD_TIMEOUT for this: if even a cached inventory isn't available,
// it's because we've never established contact with MGS. In that case, we
// should produce a useful error message rather than timing out on the
// client.)
let inventory = match tokio::time::timeout(
Expand All @@ -921,12 +922,16 @@ async fn post_start_update(
));
}
Err(_) => {
// Use 400 Bad Request instead of 503 Service Unavailable so that
// the error message is propagated to the client.
return Err(HttpError::for_bad_request(
None,
"Rack inventory not yet available (is MGS alive?)".into(),
));
// Have to construct an HttpError manually because
// HttpError::for_unavail doesn't accept an external message.
let message =
"Rack inventory not yet available (is MGS alive?)".to_owned();
return Err(HttpError {
status_code: http::StatusCode::SERVICE_UNAVAILABLE,
error_code: None,
external_message: message.clone(),
internal_message: message,
});
}
};

Expand Down

0 comments on commit a6716e3

Please sign in to comment.