Skip to content

Commit

Permalink
fix ignore-bad-version code
Browse files Browse the repository at this point in the history
  • Loading branch information
davepacheco committed Nov 16, 2023
1 parent f5bf93d commit 7a22812
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
19 changes: 12 additions & 7 deletions sled-agent/src/rack_setup/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,16 +288,21 @@ impl ServiceInner {
};

if let sled_agent_client::Error::ErrorResponse(response) = &error {
if let Some(code) = &response.error_code {
if code == "RequestedConfigOutdated" {
// XXX-dap is this really how to do this? look at what
// nexus does when propagating DNS maybe? or maybe the
// DNS tests?
return Ok(());
}
if response.status() == http::StatusCode::CONFLICT {
warn!(
self.log,
"ignoring attempt to initialize zones because \
the server seems to be newer";
"attempted_version" => i64::from(&zones_config.version),
"req_id" => &response.request_id,
"server_message" => &response.message,
);

return Ok(());
}
}

// TODO Many other codes here should not be retried.
return Err(BackoffError::transient(error));
};
let log_failure = |error, delay| {
Expand Down
12 changes: 10 additions & 2 deletions sled-agent/src/services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,16 @@ impl Error {

impl From<Error> for omicron_common::api::external::Error {
fn from(err: Error) -> Self {
omicron_common::api::external::Error::InternalError {
internal_message: err.to_string(),
match err {
err @ Error::RequestedConfigOutdated(_, _) => {
omicron_common::api::external::Error::conflict(&format!(
"{:#}",
err
))
}
_ => omicron_common::api::external::Error::InternalError {
internal_message: err.to_string(),
},
}
}
}
Expand Down

0 comments on commit 7a22812

Please sign in to comment.