From 4f2e5412c3bc91fb2c655e6cce50f3a3945f3996 Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Fri, 24 May 2024 11:24:35 -0700 Subject: [PATCH] update `delete_v2p_mappings` in light of #5568 --- .../app/sagas/instance_update/destroyed.rs | 27 +++++-------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/nexus/src/app/sagas/instance_update/destroyed.rs b/nexus/src/app/sagas/instance_update/destroyed.rs index 6789a5c1571..77bed8be436 100644 --- a/nexus/src/app/sagas/instance_update/destroyed.rs +++ b/nexus/src/app/sagas/instance_update/destroyed.rs @@ -58,6 +58,9 @@ declare_saga_actions! { DELETE_V2P_MAPPINGS -> "no_result4" { + siud_delete_v2p_mappings + // N.B. that the undo action is the same as the forward action, because + // all this does is kick the V2P manager background task. + // - siud_delete_v2p_mappings } DELETE_NAT_ENTRIES -> "no_result5" { @@ -194,12 +197,9 @@ async fn siud_delete_v2p_mappings( sagactx: NexusActionContext, ) -> Result<(), ActionError> { let osagactx = sagactx.user_data(); - let Params { ref serialized_authn, ref instance, ref vmm, .. } = + let Params { ref instance, ref vmm, .. } = sagactx.saga_params::()?; - let opctx = - crate::context::op_context_for_saga_action(&sagactx, serialized_authn); - info!( osagactx.log(), "instance update (VMM destroyed): deleting V2P mappings"; @@ -208,22 +208,9 @@ async fn siud_delete_v2p_mappings( "instance_update" => %"VMM destroyed", ); - // Per the commentary in instance_network::delete_instance_v2p_mappings`, - // this should be idempotent. - osagactx - .nexus() - .delete_instance_v2p_mappings(&opctx, instance.id()) - .await - .or_else(|err| { - // Necessary for idempotency - match err { - Error::ObjectNotFound { - type_name: ResourceType::Instance, - lookup_type: _, - } => Ok(()), - _ => Err(ActionError::action_failed(err)), - } - }) + let nexus = osagactx.nexus(); + nexus.background_tasks.activate(&nexus.background_tasks.task_v2p_manager); + Ok(()) } async fn siud_delete_nat_entries(