Skip to content

Commit

Permalink
missed a pantry retry_until_known_result
Browse files Browse the repository at this point in the history
  • Loading branch information
jgallagher committed Oct 14, 2024
1 parent 2d24652 commit 4012296
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion nexus/src/app/sagas/common_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub(crate) async fn get_pantry_address(
// DNS, we can't go back and choose another pantry anyway, so we'll just keep
// retrying until DNS comes back. All that to say: a failure to resolve DNS is
// treated as "the pantry is not gone".
async fn is_pantry_gone(
pub(super) async fn is_pantry_gone(
nexus: &Nexus,
pantry_address: SocketAddrV6,
log: &Logger,
Expand Down
24 changes: 16 additions & 8 deletions nexus/src/app/sagas/snapshot_create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
use super::{
common_storage::{
call_pantry_attach_for_disk, call_pantry_detach_for_disk,
get_pantry_address,
get_pantry_address, is_pantry_gone,
},
ActionRegistry, NexusActionContext, NexusSaga, SagaInitError,
ACTION_GENERATE_ID,
Expand All @@ -103,9 +103,11 @@ use anyhow::anyhow;
use nexus_db_model::Generation;
use nexus_db_queries::db::identity::{Asset, Resource};
use nexus_db_queries::db::lookup::LookupPath;
use omicron_common::api::external;
use omicron_common::api::external::Error;
use omicron_common::retry_until_known_result;
use omicron_common::{
api::external, progenitor_operation_retry::ProgenitorOperationRetry,
};
use omicron_uuid_kinds::{GenericUuid, PropolisUuid, SledUuid};
use rand::{rngs::StdRng, RngCore, SeedableRng};
use serde::Deserialize;
Expand Down Expand Up @@ -1167,6 +1169,7 @@ async fn ssc_call_pantry_snapshot_for_disk(
sagactx: NexusActionContext,
) -> Result<(), ActionError> {
let log = sagactx.user_data().log();
let nexus = sagactx.user_data().nexus();
let params = sagactx.saga_params::<Params>()?;

let (pantry_address, _) =
Expand All @@ -1185,7 +1188,7 @@ async fn ssc_call_pantry_snapshot_for_disk(

let client = crucible_pantry_client::Client::new(&endpoint);

retry_until_known_result(log, || async {
let snapshot_operation = || async {
client
.snapshot(
&params.disk_id.to_string(),
Expand All @@ -1194,11 +1197,16 @@ async fn ssc_call_pantry_snapshot_for_disk(
},
)
.await
})
.await
.map_err(|e| {
ActionError::action_failed(Error::internal_error(&e.to_string()))
})?;
};
let gone_check =
|| async { Ok(is_pantry_gone(nexus, pantry_address, log).await) };

ProgenitorOperationRetry::new(snapshot_operation, gone_check)
.run(log)
.await
.map_err(|e| {
ActionError::action_failed(Error::internal_error(&e.to_string()))
})?;

Ok(())
}
Expand Down

0 comments on commit 4012296

Please sign in to comment.