Skip to content

Commit 0dad016

Browse files
authored
[reconfigurator-execution] switch to async closures (#7811)
Similar to #7810 -- see that PR's description for more information.
1 parent 6019c64 commit 0dad016

File tree

4 files changed

+28
-35
lines changed

4 files changed

+28
-35
lines changed

nexus/reconfigurator/execution/src/lib.rs

Lines changed: 25 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ fn register_zone_external_networking_step<'a>(
301301
.new_step(
302302
ExecutionStepId::Ensure,
303303
"Ensure external networking resources",
304-
move |_cx| async move {
304+
async move |_cx| {
305305
datastore
306306
.blueprint_ensure_external_networking_resources(
307307
opctx, blueprint,
@@ -327,7 +327,7 @@ fn register_support_bundle_failure_step<'a>(
327327
ExecutionStepId::Cleanup,
328328
"Mark support bundles as failed if they rely on \
329329
an expunged disk or sled",
330-
move |_cx| async move {
330+
async move |_cx| {
331331
let Some(nexus_id) = nexus_id else {
332332
return StepSkipped::new((), "not running as Nexus").into();
333333
};
@@ -355,26 +355,19 @@ fn register_sled_list_step<'a>(
355355
datastore: &'a DataStore,
356356
) -> StepHandle<Arc<BTreeMap<SledUuid, Sled>>> {
357357
registrar
358-
.new_step(
359-
ExecutionStepId::Fetch,
360-
"Fetch sled list",
361-
move |_cx| async move {
362-
let sleds_by_id: BTreeMap<SledUuid, _> = datastore
363-
.sled_list_all_batched(opctx, SledFilter::InService)
364-
.await
365-
.context("listing all sleds")?
366-
.into_iter()
367-
.map(|db_sled| {
368-
(
369-
SledUuid::from_untyped_uuid(db_sled.id()),
370-
db_sled.into(),
371-
)
372-
})
373-
.collect();
374-
375-
StepSuccess::new(Arc::new(sleds_by_id)).into()
376-
},
377-
)
358+
.new_step(ExecutionStepId::Fetch, "Fetch sled list", async move |_cx| {
359+
let sleds_by_id: BTreeMap<SledUuid, _> = datastore
360+
.sled_list_all_batched(opctx, SledFilter::InService)
361+
.await
362+
.context("listing all sleds")?
363+
.into_iter()
364+
.map(|db_sled| {
365+
(SledUuid::from_untyped_uuid(db_sled.id()), db_sled.into())
366+
})
367+
.collect();
368+
369+
StepSuccess::new(Arc::new(sleds_by_id)).into()
370+
})
378371
.register()
379372
}
380373

@@ -388,7 +381,7 @@ fn register_deploy_sled_configs_step<'a>(
388381
.new_step(
389382
ExecutionStepId::Ensure,
390383
"Deploy sled configs",
391-
move |cx| async move {
384+
async move |cx| {
392385
let sleds_by_id = sleds.into_value(cx.token()).await;
393386
let res = omicron_sled_config::deploy_sled_configs(
394387
opctx,
@@ -419,7 +412,7 @@ fn register_plumb_firewall_rules_step<'a>(
419412
.new_step(
420413
ExecutionStepId::Ensure,
421414
"Plumb service firewall rules",
422-
move |_cx| async move {
415+
async move |_cx| {
423416
let res = nexus_networking::plumb_service_firewall_rules(
424417
datastore,
425418
opctx,
@@ -448,7 +441,7 @@ fn register_dns_records_step<'a>(
448441
.new_step(
449442
ExecutionStepId::Ensure,
450443
"Deploy DNS records",
451-
move |cx| async move {
444+
async move |cx| {
452445
let sleds_by_id = sleds.into_value(cx.token()).await;
453446

454447
let res = dns::deploy_dns(
@@ -478,7 +471,7 @@ fn register_cleanup_expunged_zones_step<'a>(
478471
.new_step(
479472
ExecutionStepId::Cleanup,
480473
"Cleanup expunged zones",
481-
move |_cx| async move {
474+
async move |_cx| {
482475
let res = omicron_zones::clean_up_expunged_zones(
483476
opctx, datastore, resolver, blueprint,
484477
)
@@ -500,7 +493,7 @@ fn register_decommission_sleds_step<'a>(
500493
.new_step(
501494
ExecutionStepId::Cleanup,
502495
"Decommission sleds",
503-
move |_cx| async move {
496+
async move |_cx| {
504497
let res =
505498
sled_state::decommission_sleds(opctx, datastore, blueprint)
506499
.await
@@ -521,7 +514,7 @@ fn register_decommission_disks_step<'a>(
521514
.new_step(
522515
ExecutionStepId::Cleanup,
523516
"Decommission expunged disks",
524-
move |_cx| async move {
517+
async move |_cx| {
525518
let res = omicron_physical_disks::decommission_expunged_disks(
526519
opctx, datastore, blueprint,
527520
)
@@ -542,7 +535,7 @@ fn register_deploy_clickhouse_cluster_nodes_step<'a>(
542535
.new_step(
543536
ExecutionStepId::Ensure,
544537
"Deploy clickhouse cluster nodes",
545-
move |_cx| async move {
538+
async move |_cx| {
546539
if let Some(clickhouse_cluster_config) =
547540
&blueprint.clickhouse_cluster_config
548541
{
@@ -571,7 +564,7 @@ fn register_deploy_clickhouse_single_node_step<'a>(
571564
.new_step(
572565
ExecutionStepId::Ensure,
573566
"Deploy single-node clickhouse cluster",
574-
move |_cx| async move {
567+
async move |_cx| {
575568
let res =
576569
clickhouse::deploy_single_node(opctx, blueprint).await;
577570
Ok(map_err_to_step_warning(res))
@@ -592,7 +585,7 @@ fn register_reassign_sagas_step<'a>(
592585
.new_step(
593586
ExecutionStepId::Cleanup,
594587
"Reassign sagas",
595-
move |_cx| async move {
588+
async move |_cx| {
596589
let Some(nexus_id) = nexus_id else {
597590
return StepSkipped::new(false, "not running as Nexus")
598591
.into();
@@ -630,7 +623,7 @@ fn register_cockroachdb_settings_step<'a>(
630623
.new_step(
631624
ExecutionStepId::Ensure,
632625
"Ensure CockroachDB settings",
633-
move |_cx| async move {
626+
async move |_cx| {
634627
let res =
635628
cockroachdb::ensure_settings(opctx, datastore, blueprint)
636629
.await;

nexus/reconfigurator/execution/src/omicron_physical_disks.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ async fn decommission_expunged_disks_impl(
4040
expunged_disks: impl Iterator<Item = (SledUuid, PhysicalDiskUuid)>,
4141
) -> Result<(), Vec<anyhow::Error>> {
4242
let errors: Vec<anyhow::Error> = stream::iter(expunged_disks)
43-
.filter_map(|(sled_id, disk_id)| async move {
43+
.filter_map(async |(sled_id, disk_id)| {
4444
let log = opctx.log.new(slog::o!(
4545
"sled_id" => sled_id.to_string(),
4646
"disk_id" => disk_id.to_string(),

nexus/reconfigurator/execution/src/omicron_sled_config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub(crate) async fn deploy_sled_configs(
2828
sled_configs: &BTreeMap<SledUuid, BlueprintSledConfig>,
2929
) -> Result<(), Vec<anyhow::Error>> {
3030
let errors: Vec<_> = stream::iter(sled_configs)
31-
.filter_map(|(sled_id, config)| async move {
31+
.filter_map(async |(sled_id, config)| {
3232
let log = opctx.log.new(slog::o!(
3333
"sled_id" => sled_id.to_string(),
3434
"generation" => i64::from(&config.sled_agent_generation),

nexus/reconfigurator/execution/src/omicron_zones.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ async fn clean_up_expunged_zones_impl<R: CleanupResolver>(
5454
zones_to_clean_up: impl Iterator<Item = (SledUuid, &BlueprintZoneConfig)>,
5555
) -> Result<(), Vec<anyhow::Error>> {
5656
let errors: Vec<anyhow::Error> = stream::iter(zones_to_clean_up)
57-
.filter_map(|(sled_id, config)| async move {
57+
.filter_map(async |(sled_id, config)| {
5858
let log = opctx.log.new(slog::o!(
5959
"sled_id" => sled_id.to_string(),
6060
"zone_id" => config.id.to_string(),

0 commit comments

Comments
 (0)