Skip to content

Commit afb2e9a

Browse files
authored
Oximeter producer registration should be more lax about success (#5340)
As part of #5284, we'd like to change the Nexus API used to register as a metric producer. It currently returns a 204 and no data, and we'd like it to return a 201 and a lease duration. However, if we change the server API first, Progenitor-based clients will see an unexpected response, which the `oximeter-producer` registration method currently returns as an error. This commit relaxes the registration method, so that it still succeeds if it finds an unexpected-but-successful response from Nexus. This will let clients handle the desired changes on the server even before they truly recognize the new response as valid.
1 parent aa671fe commit afb2e9a

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

oximeter/producer/src/lib.rs

+13-5
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,16 @@ pub async fn register(
251251
) -> Result<(), Error> {
252252
let client =
253253
nexus_client::Client::new(&format!("http://{}", address), log.clone());
254-
client.cpapi_producers_post(&server_info.into()).await.map(|_| ()).map_err(
255-
|err| {
254+
match client.cpapi_producers_post(&server_info.into()).await {
255+
Ok(_) => Ok(()),
256+
// Convert any unexpected-but-successful response to an Ok.
257+
// See https://github.com/oxidecomputer/omicron/issues/5284 for details.
258+
Err(nexus_client::Error::UnexpectedResponse(resp))
259+
if resp.status().is_success() =>
260+
{
261+
Ok(())
262+
}
263+
Err(err) => {
256264
let retryable = match &err {
257265
nexus_client::Error::CommunicationError(..) => true,
258266
nexus_client::Error::ErrorResponse(resp) => {
@@ -261,9 +269,9 @@ pub async fn register(
261269
_ => false,
262270
};
263271
let msg = err.to_string();
264-
Error::RegistrationError { retryable, msg }
265-
},
266-
)
272+
Err(Error::RegistrationError { retryable, msg })
273+
}
274+
}
267275
}
268276

269277
/// Handle a request to pull available metric data from a [`ProducerRegistry`].

0 commit comments

Comments
 (0)