Skip to content

Commit

Permalink
rm code from other branch
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkw committed Jun 11, 2024
1 parent 29eae36 commit 18ccc7e
Showing 1 changed file with 0 additions and 64 deletions.
64 changes: 0 additions & 64 deletions nexus/db-queries/src/db/datastore/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,6 @@ impl From<InstanceAndActiveVmm> 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<Vmm>,
pub target_vmm: Option<Vmm>,
pub migration: Option<Migration>,
}

/// A token which represents that a saga holds the instance-updater lock on a
/// particular instance.
///
Expand Down Expand Up @@ -341,60 +331,6 @@ impl DataStore {
Ok(InstanceAndActiveVmm { instance, vmm })
}

pub async fn instance_fetch_all(
&self,
opctx: &OpContext,
authz_instance: &authz::Instance,
) -> LookupResult<InstanceSnapshot> {
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::<Vmm>::as_select(),
Option::<Vmm>::as_select(),
Option::<Migration>::as_select(),
))
.get_result_async::<(Instance, Option<Vmm>, Option<Vmm>, Option<Migration>)>(
&*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.
Expand Down

0 comments on commit 18ccc7e

Please sign in to comment.