From 18ccc7e0bb376c8074eb22bf1a9a971602a6b42d Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Tue, 11 Jun 2024 16:02:24 -0700 Subject: [PATCH] rm code from other branch --- nexus/db-queries/src/db/datastore/instance.rs | 64 ------------------- 1 file changed, 64 deletions(-) diff --git a/nexus/db-queries/src/db/datastore/instance.rs b/nexus/db-queries/src/db/datastore/instance.rs index 234158f094..5d4b7ad483 100644 --- a/nexus/db-queries/src/db/datastore/instance.rs +++ b/nexus/db-queries/src/db/datastore/instance.rs @@ -120,16 +120,6 @@ impl From for omicron_common::api::external::Instance { } } -/// Wraps a record of an [`Instance`] along with its active [`Vmm`], migration -/// target [`Vmm`], and [`Migration`] record, if a migration exists. -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -pub struct InstanceSnapshot { - pub instance: Instance, - pub active_vmm: Option, - pub target_vmm: Option, - pub migration: Option, -} - /// A token which represents that a saga holds the instance-updater lock on a /// particular instance. /// @@ -341,60 +331,6 @@ impl DataStore { Ok(InstanceAndActiveVmm { instance, vmm }) } - pub async fn instance_fetch_all( - &self, - opctx: &OpContext, - authz_instance: &authz::Instance, - ) -> LookupResult { - opctx.authorize(authz::Action::Read, authz_instance).await?; - - use db::schema::instance::dsl as instance_dsl; - use db::schema::migration::dsl as migration_dsl; - use db::schema::vmm::dsl as vmm_dsl; - - let (instance, active_vmm, target_vmm, migration) = instance_dsl::instance - .filter(instance_dsl::id.eq(authz_instance.id())) - .filter(instance_dsl::time_deleted.is_null()) - .left_join( - vmm_dsl::vmm.on((vmm_dsl::id - .nullable() - .eq(instance_dsl::active_propolis_id)) - .and(vmm_dsl::time_deleted.is_null())), - ) - .left_join( - vmm_dsl::vmm.on((vmm_dsl::id - .nullable() - .eq(instance_dsl::target_propolis_id)) - .and(vmm_dsl::time_deleted.is_null())), - ) - .left_join( - migration_dsl::migration - .on(migration_dsl::id - .nullable() - .eq(instance_dsl::migration_id)), - ) - .select(( - Instance::as_select(), - Option::::as_select(), - Option::::as_select(), - Option::::as_select(), - )) - .get_result_async::<(Instance, Option, Option, Option)>( - &*self.pool_connection_authorized(opctx).await?, - ) - .await - .map_err(|e| { - public_error_from_diesel( - e, - ErrorHandler::NotFoundByLookup( - ResourceType::Instance, - LookupType::ById(authz_instance.id()), - ), - ) - })?; - Ok(InstanceSnapshot { instance, active_vmm, target_vmm, migration }) - } - // TODO-design It's tempting to return the updated state of the Instance // here because it's convenient for consumers and by using a RETURNING // clause, we could ensure that the "update" and "fetch" are atomic.