Skip to content

Commit f77aa55

Browse files
committed
log during sled reservation
1 parent c67d8e9 commit f77aa55

File tree

2 files changed

+49
-7
lines changed

2 files changed

+49
-7
lines changed

nexus/db-queries/src/db/datastore/sled.rs

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,14 @@ impl DataStore {
467467
constraints: db::model::SledReservationConstraints,
468468
) -> Result<db::model::SledResourceVmm, SledReservationTransactionError>
469469
{
470+
let log = opctx.log.new(o!(
471+
"query" => "sled_reservation",
472+
"instance_id" => instance_id.to_string(),
473+
"propolis_id" => propolis_id.to_string(),
474+
));
475+
476+
info!(&log, "sled reservation starting");
477+
470478
let conn = self.pool_connection_authorized(opctx).await?;
471479

472480
// Check if resource ID already exists - if so, return it.
@@ -483,6 +491,7 @@ impl DataStore {
483491
.await?;
484492

485493
if !old_resource.is_empty() {
494+
info!(&log, "sled reservation already occurred, returning");
486495
return Ok(old_resource[0].clone());
487496
}
488497

@@ -510,7 +519,9 @@ impl DataStore {
510519
// arguments to this function.
511520
let maybe_must_use_sleds: Option<HashSet<SledUuid>> =
512521
if let Some(must_select_from) = constraints.must_select_from() {
513-
Some(must_select_from.into_iter().cloned().collect())
522+
let set = must_select_from.into_iter().cloned().collect();
523+
info!(&log, "reservation constrained to sleds {set:?}");
524+
Some(set)
514525
} else {
515526
None
516527
};
@@ -534,8 +545,15 @@ impl DataStore {
534545
if local_storage_allocation_sleds.is_empty() {
535546
// None of this instance's local storage disks have been
536547
// allocated yet.
548+
info!(&log, "no existing local storage allocations");
537549
maybe_must_use_sleds
538550
} else {
551+
info!(
552+
&log,
553+
"existing local storage allocations on sleds
554+
{local_storage_allocation_sleds:?}"
555+
);
556+
539557
if local_storage_allocation_sleds.len() != 1 {
540558
// It's an error for multiple sleds to host local storage
541559
// disks for a single VMM, so return a conflict error here.
@@ -583,18 +601,15 @@ impl DataStore {
583601
} else {
584602
// `local_storage_disks` is empty, so that does not have an impact
585603
// on the existing hash set
604+
info!(&log, "no attached local storage disks");
586605
maybe_must_use_sleds
587606
};
588607

589608
// If filtering has removed all the sleds from the constraint, then we
590609
// cannot satisfy this allocation.
591610
if let Some(must_use_sleds) = &maybe_must_use_sleds {
592611
if must_use_sleds.is_empty() {
593-
error!(
594-
&opctx.log,
595-
"no sleds available after filtering for instance \
596-
{instance_id}",
597-
);
612+
error!(&log, "no sleds available after filtering");
598613

599614
// Nothing will satisfy this allocation, return an error here.
600615
return Err(SledReservationTransactionError::Reservation(
@@ -675,12 +690,20 @@ impl DataStore {
675690
}
676691
}
677692

693+
info!(&log, "sled targets: {sled_targets:?}");
694+
678695
let local_storage_allocation_required: Vec<&LocalStorageDisk> =
679696
local_storage_disks
680697
.iter()
681698
.filter(|disk| disk.local_storage_dataset_allocation.is_none())
682699
.collect();
683700

701+
info!(
702+
&log,
703+
"local_storage_allocation_required: \
704+
{local_storage_allocation_required:?}"
705+
);
706+
684707
// We loop here because our attempts to INSERT may be violated by
685708
// concurrent operations. We'll respond by looking through a slightly
686709
// smaller set of possible sleds.
@@ -699,6 +722,8 @@ impl DataStore {
699722
&preferred,
700723
)?;
701724

725+
info!(&log, "trying sled target {sled_target}");
726+
702727
// Create a SledResourceVmm record, associate it with the target
703728
// sled.
704729
let resource = SledResourceVmm::new(
@@ -709,6 +734,11 @@ impl DataStore {
709734
);
710735

711736
if local_storage_allocation_required.is_empty() {
737+
info!(
738+
&log,
739+
"calling insert (no local storage allocation requred)"
740+
);
741+
712742
// If no local storage allocation is required, then simply try
713743
// allocating a VMM to this sled.
714744
//
@@ -723,8 +753,10 @@ impl DataStore {
723753
.await?;
724754

725755
if rows_inserted > 0 {
756+
info!(&log, "reservation succeeded!");
726757
return Ok(resource);
727758
}
759+
info!(&log, "reservation failed");
728760
} else {
729761
// If local storage allocation is required, match the requests
730762
// with all the zpools of this sled that have available space.
@@ -780,6 +812,8 @@ impl DataStore {
780812
})
781813
.collect();
782814

815+
info!(&log, "filtered zpools for sled: {zpools_for_sled:?}");
816+
783817
if local_storage_allocation_required.len()
784818
> zpools_for_sled.len()
785819
{
@@ -1020,6 +1054,12 @@ impl DataStore {
10201054
for valid_allocation in validated_allocations {
10211055
let ValidatedAllocations { allocations } = valid_allocation;
10221056

1057+
info!(
1058+
&log,
1059+
"calling insert with local storage allocations";
1060+
"allocations" => ?allocations,
1061+
);
1062+
10231063
// Try to INSERT the record plus the new local storage
10241064
// allocations. If this is still a valid target and the new
10251065
// local storage allocations still fit, we'll use it. If it
@@ -1033,8 +1073,10 @@ impl DataStore {
10331073
.await?;
10341074

10351075
if rows_inserted > 0 {
1076+
info!(&log, "reservation succeeded!");
10361077
return Ok(resource);
10371078
}
1079+
info!(&log, "reservation failed");
10381080
}
10391081
}
10401082

nexus/db-queries/src/db/queries/sled_reservation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use omicron_uuid_kinds::SledUuid;
2020
use omicron_uuid_kinds::ZpoolUuid;
2121
use uuid::Uuid;
2222

23-
#[derive(Clone)]
23+
#[derive(Debug, Clone)]
2424
pub struct LocalStorageAllocation {
2525
pub disk_id: Uuid,
2626
pub local_storage_dataset_allocation_id: DatasetUuid,

0 commit comments

Comments
 (0)