From 0ac6532eeec8fab4614f7e688fbf864ad42134ec Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Wed, 29 May 2024 14:32:13 -0700 Subject: [PATCH] fix up stuff --- nexus/src/app/mod.rs | 2 ++ .../src/app/sagas/instance_update/destroyed.rs | 18 +----------------- nexus/src/app/sagas/instance_update/mod.rs | 8 +++----- 3 files changed, 6 insertions(+), 22 deletions(-) diff --git a/nexus/src/app/mod.rs b/nexus/src/app/mod.rs index e997fa74172..a658cf254ec 100644 --- a/nexus/src/app/mod.rs +++ b/nexus/src/app/mod.rs @@ -202,6 +202,8 @@ pub struct Nexus { default_region_allocation_strategy: RegionAllocationStrategy, /// Channel for notifying background task of change to opte v2p state + #[allow(dead_code)] + // XXX(eliza) do we need this or can we just activate the background task? v2p_notification_tx: tokio::sync::watch::Sender<()>, } diff --git a/nexus/src/app/sagas/instance_update/destroyed.rs b/nexus/src/app/sagas/instance_update/destroyed.rs index 7aadb1cd1a2..4455dddb2e2 100644 --- a/nexus/src/app/sagas/instance_update/destroyed.rs +++ b/nexus/src/app/sagas/instance_update/destroyed.rs @@ -5,19 +5,15 @@ use super::ActionRegistry; use super::NexusActionContext; use super::NexusSaga; -use super::STATE; use crate::app::sagas::declare_saga_actions; use crate::app::sagas::ActionError; use nexus_db_model::Generation; use nexus_db_model::Instance; use nexus_db_model::InstanceRuntimeState; -use nexus_db_model::Vmm; use nexus_db_queries::authn; use nexus_db_queries::authz; -use nexus_db_queries::db::datastore::InstanceAndVmms; use omicron_common::api::external; use omicron_common::api::external::Error; -use omicron_common::api::external::InstanceState; use serde::{Deserialize, Serialize}; use slog::info; use uuid::Uuid; @@ -81,7 +77,7 @@ pub(super) struct Params { } #[derive(Debug)] -pub(crate) struct SagaVmmDestroyed; +pub(super) struct SagaVmmDestroyed; impl NexusSaga for SagaVmmDestroyed { const NAME: &'static str = "instance-update-vmm-destroyed"; type Params = Params; @@ -106,18 +102,6 @@ impl NexusSaga for SagaVmmDestroyed { } } -fn get_destroyed_vmm( - sagactx: &NexusActionContext, -) -> Result, ActionError> { - let state = sagactx.lookup::(STATE)?; - match state.active_vmm { - Some(vmm) if vmm.runtime.state.state() == &InstanceState::Destroyed => { - Ok(Some((state.instance, vmm))) - } - _ => Ok(None), - } -} - async fn siud_release_sled_resources( sagactx: NexusActionContext, ) -> Result<(), ActionError> { diff --git a/nexus/src/app/sagas/instance_update/mod.rs b/nexus/src/app/sagas/instance_update/mod.rs index 2107c8ca568..cb95003bf58 100644 --- a/nexus/src/app/sagas/instance_update/mod.rs +++ b/nexus/src/app/sagas/instance_update/mod.rs @@ -9,7 +9,6 @@ use super::{ use crate::app::db::datastore::InstanceAndVmms; use crate::app::sagas::declare_saga_actions; use nexus_db_queries::{authn, authz}; -use nexus_types::identity::Resource; use omicron_common::api::external::InstanceState; use serde::{Deserialize, Serialize}; use steno::{ActionError, DagBuilder, Node, SagaName}; @@ -38,7 +37,6 @@ struct RealParams { } const INSTANCE_LOCK_ID: &str = "saga_instance_lock_id"; -const STATE: &str = "state"; // instance update saga: actions @@ -63,7 +61,7 @@ declare_saga_actions! { // Become the instance updater BECOME_UPDATER -> "generation" { + siu_become_updater - - siu_lock_instance_undo + - siu_unbecome_updater } UNLOCK_INSTANCE -> "unlocked" { @@ -84,7 +82,7 @@ impl NexusSaga for SagaInstanceUpdate { } fn make_saga_dag( - params: &Self::Params, + _params: &Self::Params, mut builder: DagBuilder, ) -> Result { builder.append(Node::action( @@ -214,7 +212,7 @@ async fn siu_fetch_state_and_start_real_saga( state, }) .await - .map_err(ActionError::action_failed); + .map_err(ActionError::action_failed)?; Ok(()) }