Skip to content

Commit

Permalink
get instance id from vmm find-and-update
Browse files Browse the repository at this point in the history
  • Loading branch information
gjcolombo committed Aug 26, 2024
1 parent 6d3d843 commit 9f4156a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
20 changes: 17 additions & 3 deletions nexus/db-queries/src/db/datastore/vmm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,13 @@ use uuid::Uuid;

/// The result of an [`DataStore::vmm_and_migration_update_runtime`] call,
/// indicating which records were updated.
#[derive(Copy, Clone, Debug)]
#[derive(Clone, Debug)]
pub struct VmmStateUpdateResult {
/// The VMM record that the update query found and possibly updated.
///
/// NOTE: This is the record prior to the update!
pub found_vmm: Vmm,

/// `true` if the VMM record was updated, `false` otherwise.
pub vmm_updated: bool,

Expand Down Expand Up @@ -228,13 +233,21 @@ impl DataStore {
.transaction(&conn, |conn| {
let err = err.clone();
async move {
let vmm_updated = self
let vmm_update_result = self
.vmm_update_runtime_on_connection(
&conn,
&vmm_id,
new_runtime,
)
.await.map(|r| match r.status { UpdateStatus::Updated => true, UpdateStatus::NotUpdatedButExists => false })?;
.await?;


let found_vmm = vmm_update_result.found;
let vmm_updated = match vmm_update_result.status {
UpdateStatus::Updated => true,
UpdateStatus::NotUpdatedButExists => false
};

let migration_out_updated = match migration_out {
Some(migration) => {
let r = self.migration_update_source_on_connection(
Expand Down Expand Up @@ -282,6 +295,7 @@ impl DataStore {
None => false,
};
Ok(VmmStateUpdateResult {
found_vmm,
vmm_updated,
migration_in_updated,
migration_out_updated,
Expand Down
5 changes: 2 additions & 3 deletions nexus/src/app/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1881,9 +1881,8 @@ pub(crate) async fn process_vmm_update(
new_runtime_state,
&result,
) {
let instance_id = InstanceUuid::from_untyped_uuid(
datastore.vmm_fetch(&opctx, &propolis_id).await?.instance_id,
);
let instance_id =
InstanceUuid::from_untyped_uuid(result.found_vmm.instance_id);

let (.., authz_instance) = LookupPath::new(&opctx, datastore)
.instance_id(instance_id.into_untyped_uuid())
Expand Down

0 comments on commit 9f4156a

Please sign in to comment.