Skip to content

Commit 4bd9ebb

Browse files
authored
dev/test: fix race in switch port insertion (#10469)
This should fix a panic @benjaminleonard hit on macos with `omicron-dev run-all`.
1 parent 412a27a commit 4bd9ebb

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

nexus/src/lib.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,15 +406,23 @@ impl nexus_test_interface::NexusServer for Server {
406406
// completely uninterested in switch port interaction), we'll insert a
407407
// single qsfp0 for each switch to the db directly.
408408
for which_switch in SwitchSlot::iter() {
409-
datastore
409+
match datastore
410410
.switch_port_create(
411411
&opctx,
412412
config.deployment.rack_id,
413413
which_switch,
414414
nexus_db_model::Name("qsfp0".parse().unwrap()),
415415
)
416416
.await
417-
.expect("inserted qsfp0");
417+
{
418+
// We're racing with the background task - it may have already
419+
// contacted dpd and inserted qsfp0. That's fine.
420+
Ok(_) | Err(Error::ObjectAlreadyExists { .. }) => (),
421+
Err(err) => panic!(
422+
"failed to insert qsfp0 for {which_switch:?}: {}",
423+
InlineErrorChain::new(&err)
424+
),
425+
}
418426
}
419427

420428
// Allocation of initial external IP addresses is a little funny. In

0 commit comments

Comments
 (0)