Skip to content

Commit

Permalink
[WIP] update to oxidecomputer/dropshot#1180
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkw committed Dec 3, 2024
1 parent 41d7c9b commit 1994534
Show file tree
Hide file tree
Showing 35 changed files with 7,810 additions and 2,466 deletions.
12 changes: 5 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -886,3 +886,8 @@ path = "workspace-hack"
[patch."https://github.com/oxidecomputer/omicron"]
omicron-uuid-kinds = { path = "uuid-kinds" }
omicron-common = { path = "common" }

# /!\ REMOVE BEFORE FLIGHT: Temporary patch to test dropshot breaking changes
[patch.crates-io.dropshot]
git = 'https://github.com/oxidecomputer/dropshot'
branch = 'eliza/custom-error-httpresponse-result'
3 changes: 2 additions & 1 deletion clickhouse-admin/src/clickhouse_cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ impl From<ClickhouseCliError> for HttpError {
| ClickhouseCliError::ExecutionError(_) => {
let message = InlineErrorChain::new(&err).to_string();
HttpError {
status_code: http::StatusCode::INTERNAL_SERVER_ERROR,
status_code:
dropshot::ErrorStatusCode::INTERNAL_SERVER_ERROR,
error_code: Some(String::from("Internal")),
external_message: message.clone(),
internal_message: message,
Expand Down
3 changes: 2 additions & 1 deletion clickhouse-admin/src/clickward.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ impl From<ClickwardError> for HttpError {
ClickwardError::Failure { .. } => {
let message = InlineErrorChain::new(&err).to_string();
HttpError {
status_code: http::StatusCode::INTERNAL_SERVER_ERROR,
status_code:
dropshot::ErrorStatusCode::INTERNAL_SERVER_ERROR,
error_code: Some(String::from("Internal")),
external_message: message.clone(),
internal_message: message,
Expand Down
3 changes: 2 additions & 1 deletion cockroach-admin/src/cockroach_cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ impl From<CockroachCliError> for HttpError {
| CockroachCliError::ParseOutput { .. } => {
let message = InlineErrorChain::new(&err).to_string();
HttpError {
status_code: http::StatusCode::INTERNAL_SERVER_ERROR,
status_code:
dropshot::ErrorStatusCode::INTERNAL_SERVER_ERROR,
error_code: Some(String::from("Internal")),
external_message: message.clone(),
internal_message: message,
Expand Down
2 changes: 1 addition & 1 deletion cockroach-admin/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl ServerContext {
{err:#}",
);
Err(HttpError {
status_code: http::StatusCode::SERVICE_UNAVAILABLE,
status_code: dropshot::ErrorStatusCode::SERVICE_UNAVAILABLE,
error_code: None,
external_message: message.clone(),
internal_message: message,
Expand Down
19 changes: 10 additions & 9 deletions common/src/api/external/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ impl From<Error> for HttpError {
};
HttpError::for_client_error(
Some(String::from("ObjectNotFound")),
http::StatusCode::NOT_FOUND,
dropshot::ClientErrorStatusCode::NOT_FOUND,
format!("not found: {}", message),
)
}
Expand All @@ -427,7 +427,7 @@ impl From<Error> for HttpError {
}

Error::Unauthenticated { internal_message } => HttpError {
status_code: http::StatusCode::UNAUTHORIZED,
status_code: dropshot::ErrorStatusCode::UNAUTHORIZED,
// TODO-polish We may want to rethink this error code. This is
// what HTTP calls it, but it's confusing.
error_code: Some(String::from("Unauthorized")),
Expand All @@ -441,7 +441,7 @@ impl From<Error> for HttpError {
let (internal_message, external_message) =
message.into_internal_external();
HttpError {
status_code: http::StatusCode::BAD_REQUEST,
status_code: dropshot::ErrorStatusCode::BAD_REQUEST,
error_code: Some(String::from("InvalidRequest")),
external_message,
internal_message,
Expand All @@ -452,7 +452,7 @@ impl From<Error> for HttpError {
let (internal_message, external_message) =
message.into_internal_external();
HttpError {
status_code: http::StatusCode::BAD_REQUEST,
status_code: dropshot::ErrorStatusCode::BAD_REQUEST,
error_code: Some(String::from("InvalidValue")),
external_message: format!(
"unsupported value for \"{}\": {}",
Expand All @@ -464,7 +464,7 @@ impl From<Error> for HttpError {

Error::Forbidden => HttpError::for_client_error(
Some(String::from("Forbidden")),
http::StatusCode::FORBIDDEN,
dropshot::ClientErrorStatusCode::FORBIDDEN,
String::from("Forbidden"),
),

Expand All @@ -485,7 +485,8 @@ impl From<Error> for HttpError {
// Need to construct an `HttpError` explicitly to present both
// an internal and an external message.
HttpError {
status_code: http::StatusCode::INSUFFICIENT_STORAGE,
status_code:
dropshot::ErrorStatusCode::INSUFFICIENT_STORAGE,
error_code: Some(String::from("InsufficientCapacity")),
external_message: format!(
"Insufficient capacity: {}",
Expand All @@ -503,7 +504,7 @@ impl From<Error> for HttpError {
let (internal_message, external_message) =
message.into_internal_external();
HttpError {
status_code: http::StatusCode::CONFLICT,
status_code: dropshot::ErrorStatusCode::CONFLICT,
error_code: Some(String::from("Conflict")),
external_message,
internal_message,
Expand All @@ -514,7 +515,7 @@ impl From<Error> for HttpError {
let (internal_message, external_message) =
message.into_internal_external();
HttpError {
status_code: http::StatusCode::NOT_FOUND,
status_code: dropshot::ErrorStatusCode::NOT_FOUND,
error_code: Some(String::from("Not Found")),
external_message,
internal_message,
Expand All @@ -523,7 +524,7 @@ impl From<Error> for HttpError {

Error::Gone => HttpError::for_client_error(
Some(String::from("Gone")),
http::StatusCode::GONE,
dropshot::ClientErrorStatusCode::GONE,
String::from("Gone"),
),
}
Expand Down
4 changes: 2 additions & 2 deletions dns-server/src/http_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl From<UpdateError> for dropshot::HttpError {
let message = format!("{:#}", error);
match &error {
UpdateError::BadUpdateGeneration { .. } => dropshot::HttpError {
status_code: http::StatusCode::CONFLICT,
status_code: dropshot::ErrorStatusCode::CONFLICT,
error_code: Some(String::from(
ERROR_CODE_BAD_UPDATE_GENERATION,
)),
Expand All @@ -73,7 +73,7 @@ impl From<UpdateError> for dropshot::HttpError {
},

UpdateError::UpdateInProgress { .. } => dropshot::HttpError {
status_code: http::StatusCode::CONFLICT,
status_code: dropshot::ErrorStatusCode::CONFLICT,
error_code: Some(String::from(ERROR_CODE_UPDATE_IN_PROGRESS)),
external_message: message.clone(),
internal_message: message,
Expand Down
2 changes: 1 addition & 1 deletion dns-server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ impl TransientServer {
&dns_server::Config { bind_address: dns_bind_address },
&dropshot::ConfigDropshot {
bind_address: "[::1]:0".parse().unwrap(),
request_body_max_bytes: 4 * 1024 * 1024,
default_request_body_max_bytes: 4 * 1024 * 1024,
default_handler_task_mode: dropshot::HandlerTaskMode::Detached,
log_headers: vec![],
},
Expand Down
2 changes: 1 addition & 1 deletion dns-server/tests/basic_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ fn test_config(
dns_server::storage::Config { storage_path, keep_old_generations: 3 };
let config_dropshot = dropshot::ConfigDropshot {
bind_address: "[::1]:0".to_string().parse().unwrap(),
request_body_max_bytes: 1024,
default_request_body_max_bytes: 1024,
default_handler_task_mode: HandlerTaskMode::Detached,
log_headers: vec![],
};
Expand Down
18 changes: 9 additions & 9 deletions gateway/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl From<SpCommsError> for HttpError {
)),
..
} => http_err_with_message(
http::StatusCode::SERVICE_UNAVAILABLE,
dropshot::ErrorStatusCode::SERVICE_UNAVAILABLE,
"UpdateSlotBusy",
InlineErrorChain::new(&error).to_string(),
),
Expand All @@ -125,29 +125,29 @@ impl From<SpCommsError> for HttpError {
)),
..
} => http_err_with_message(
http::StatusCode::SERVICE_UNAVAILABLE,
dropshot::ErrorStatusCode::SERVICE_UNAVAILABLE,
"UpdateInProgress",
InlineErrorChain::new(&error).to_string(),
),
SpCommsError::SpAddressUnknown(_) => http_err_with_message(
http::StatusCode::SERVICE_UNAVAILABLE,
dropshot::ErrorStatusCode::SERVICE_UNAVAILABLE,
"SpAddressUnknown",
InlineErrorChain::new(&error).to_string(),
),
SpCommsError::Timeout { .. } => http_err_with_message(
http::StatusCode::SERVICE_UNAVAILABLE,
dropshot::ErrorStatusCode::SERVICE_UNAVAILABLE,
"Timeout ",
InlineErrorChain::new(&error).to_string(),
),
SpCommsError::SpCommunicationFailed { .. } => {
http_err_with_message(
http::StatusCode::SERVICE_UNAVAILABLE,
dropshot::ErrorStatusCode::SERVICE_UNAVAILABLE,
"SpCommunicationFailed",
InlineErrorChain::new(&error).to_string(),
)
}
SpCommsError::UpdateFailed { .. } => http_err_with_message(
http::StatusCode::SERVICE_UNAVAILABLE,
dropshot::ErrorStatusCode::SERVICE_UNAVAILABLE,
"UpdateFailed",
InlineErrorChain::new(&error).to_string(),
),
Expand All @@ -163,12 +163,12 @@ impl From<SpLookupError> for HttpError {
InlineErrorChain::new(&error).to_string(),
),
SpLookupError::DiscoveryNotYetComplete => http_err_with_message(
http::StatusCode::SERVICE_UNAVAILABLE,
dropshot::ErrorStatusCode::SERVICE_UNAVAILABLE,
"DiscoveryNotYetComplete",
InlineErrorChain::new(&error).to_string(),
),
SpLookupError::DiscoveryFailed { .. } => http_err_with_message(
http::StatusCode::SERVICE_UNAVAILABLE,
dropshot::ErrorStatusCode::SERVICE_UNAVAILABLE,
"DiscoveryFailed ",
InlineErrorChain::new(&error).to_string(),
),
Expand All @@ -181,7 +181,7 @@ impl From<SpLookupError> for HttpError {
// status code, we want to give our caller some information about what is going
// wrong (e.g., we timed out waiting for an SP).
pub(crate) fn http_err_with_message(
status_code: http::StatusCode,
status_code: dropshot::ErrorStatusCode,
error_code: &str,
message: String,
) -> HttpError {
Expand Down
2 changes: 1 addition & 1 deletion gateway/src/http_entrypoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ impl GatewayApi for GatewayImpl {
let key = str::from_utf8(key).unwrap();
String::from_utf8(bytes).map_err(|_| {
http_err_with_message(
http::StatusCode::SERVICE_UNAVAILABLE,
dropshot::ErrorStatusCode::SERVICE_UNAVAILABLE,
"InvalidCaboose",
format!("non-utf8 data returned for caboose key {key}"),
)
Expand Down
2 changes: 1 addition & 1 deletion gateway/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ fn start_dropshot_server(
Entry::Vacant(slot) => {
let dropshot = ConfigDropshot {
bind_address: SocketAddr::V6(addr),
request_body_max_bytes,
default_request_body_max_bytes: request_body_max_bytes,
default_handler_task_mode: HandlerTaskMode::Detached,
log_headers: vec![],
};
Expand Down
2 changes: 1 addition & 1 deletion illumos-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl From<ExecutionError> for HttpError {
fn from(err: ExecutionError) -> Self {
let message = InlineErrorChain::new(&err).to_string();
HttpError {
status_code: http::StatusCode::INTERNAL_SERVER_ERROR,
status_code: dropshot::ErrorStatusCode::INTERNAL_SERVER_ERROR,
error_code: Some(String::from("Internal")),
external_message: message.clone(),
internal_message: message,
Expand Down
8 changes: 4 additions & 4 deletions installinator-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use dropshot::{
HttpResponseHeaders, HttpResponseOk, HttpResponseUpdatedNoContent, Path,
RequestContext, TypedBody,
};
use hyper::{header, StatusCode};
use hyper::header;
use installinator_common::EventReport;
use omicron_common::update::ArtifactHashId;
use schemars::JsonSchema;
Expand Down Expand Up @@ -99,7 +99,7 @@ impl EventReportStatus {
EventReportStatus::UnrecognizedUpdateId => {
Err(HttpError::for_client_error(
None,
StatusCode::UNPROCESSABLE_ENTITY,
dropshot::ClientErrorStatusCode::UNPROCESSABLE_ENTITY,
format!(
"update ID {update_id} unrecognized by this server"
),
Expand All @@ -108,7 +108,7 @@ impl EventReportStatus {
EventReportStatus::ReceiverClosed => {
Err(HttpError::for_client_error(
None,
StatusCode::GONE,
dropshot::ClientErrorStatusCode::GONE,
format!("update ID {update_id}: receiver closed"),
))
}
Expand All @@ -129,7 +129,7 @@ pub fn default_config(bind_address: std::net::SocketAddr) -> ConfigDropshot {
// TODO: replace with an endpoint-specific option once
// https://github.com/oxidecomputer/dropshot/pull/618 lands and is
// available in omicron.
request_body_max_bytes: 4 * 1024 * 1024,
default_request_body_max_bytes: 4 * 1024 * 1024,
default_handler_task_mode: HandlerTaskMode::Detached,
log_headers: vec![],
}
Expand Down
2 changes: 1 addition & 1 deletion internal-dns/resolver/src/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ mod test {
},
&dropshot::ConfigDropshot {
bind_address: "[::1]:0".parse().unwrap(),
request_body_max_bytes: 8 * 1024,
default_request_body_max_bytes: 8 * 1024,
default_handler_task_mode: HandlerTaskMode::Detached,
log_headers: vec![],
},
Expand Down
Loading

0 comments on commit 1994534

Please sign in to comment.