Skip to content

Commit def7d0a

Browse files
authored
[support bundle] Simplify report, relying on new 'steps' infrastructure (#9466)
Built on top of #9463 This PR simplifies the support bundle collection report by removing the redundant listed_in_service_sleds and listed_sps boolean fields from `SupportBundleCollectionReport`. These fields were tracking whether certain operations succeeded, but that information is now captured by the per-step status tracking added in #9463. The PR also consolidates `CollectionStepOutput::SpawnSleds` and `CollectionStepOutput::SavingSpDumps` into the generic `CollectionStepOutput::Spawn` variant, removing artificial distinctions that only existed to set those boolean flags.
1 parent bd5f636 commit def7d0a

File tree

4 files changed

+97
-55
lines changed

4 files changed

+97
-55
lines changed

dev-tools/omdb/src/bin/omdb/nexus.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2611,21 +2611,13 @@ fn print_task_support_bundle_collector(details: &serde_json::Value) {
26112611

26122612
if let Some(SupportBundleCollectionReport {
26132613
bundle,
2614-
listed_in_service_sleds,
2615-
listed_sps,
26162614
activated_in_db_ok,
26172615
mut steps,
26182616
ereports,
26192617
}) = collection_report
26202618
{
26212619
println!(" Support Bundle Collection Report:");
26222620
println!(" Bundle ID: {bundle}");
2623-
println!(
2624-
" Bundle was able to list in-service sleds: {listed_in_service_sleds}"
2625-
);
2626-
println!(
2627-
" Bundle was able to list service processors: {listed_sps}"
2628-
);
26292621

26302622
#[derive(Tabled)]
26312623
#[tabled(rename_all = "SCREAMING_SNAKE_CASE")]

nexus/src/app/background/tasks/support_bundle_collector.rs

Lines changed: 59 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -712,15 +712,6 @@ impl CompletedCollectionStep {
712712
report.ereports = Some(status);
713713
Status::Ok
714714
}
715-
CollectionStepOutput::SavingSpDumps { listed_sps } => {
716-
report.listed_sps = listed_sps;
717-
Status::Ok
718-
}
719-
CollectionStepOutput::SpawnSleds { extra_steps } => {
720-
report.listed_in_service_sleds = true;
721-
steps.extend(extra_steps);
722-
Status::Ok
723-
}
724715
CollectionStepOutput::Spawn { extra_steps } => {
725716
steps.extend(extra_steps);
726717
Status::Ok
@@ -747,14 +738,7 @@ enum CollectionStepOutput {
747738
// It may have still saved a partial set of data to the bundle.
748739
Failed(anyhow::Error),
749740
Ereports(SupportBundleEreportStatus),
750-
SavingSpDumps { listed_sps: bool },
751-
// NOTE: The distinction between this and "Spawn" is pretty artificial -
752-
// it's just to preserve a part of the report which says "we tried to
753-
// list in-service sleds".
754-
//
755-
// If we changed the collection report, this could easily be combined
756-
// with the "Spawn" variant.
757-
SpawnSleds { extra_steps: Vec<CollectionStep> },
741+
// The step spawned additional steps to execute
758742
Spawn { extra_steps: Vec<CollectionStep> },
759743
// The step completed with nothing to report, and no follow-up steps
760744
None,
@@ -1232,7 +1216,7 @@ impl BundleCollection {
12321216
format!("failed to save SP dump from: {} {}", sp.type_, sp.slot)
12331217
})?;
12341218

1235-
Ok(CollectionStepOutput::SavingSpDumps { listed_sps: true })
1219+
Ok(CollectionStepOutput::None)
12361220
}
12371221

12381222
// Perform the work of collecting the support bundle into a temporary directory
@@ -1268,25 +1252,25 @@ impl BundleCollection {
12681252

12691253
let steps: Vec<CollectionStep> = vec![
12701254
CollectionStep::new(
1271-
"bundle id",
1255+
SupportBundleCollectionStep::STEP_BUNDLE_ID,
12721256
Box::new(|collection, dir| {
12731257
collection.collect_bundle_id(dir).boxed()
12741258
}),
12751259
),
12761260
CollectionStep::new(
1277-
"reconfigurator state",
1261+
SupportBundleCollectionStep::STEP_RECONFIGURATOR_STATE,
12781262
Box::new(|collection, dir| {
12791263
collection.collect_reconfigurator_state(dir).boxed()
12801264
}),
12811265
),
12821266
CollectionStep::new(
1283-
"ereports",
1267+
SupportBundleCollectionStep::STEP_EREPORTS,
12841268
Box::new(|collection, dir| {
12851269
collection.collect_ereports(dir).boxed()
12861270
}),
12871271
),
12881272
CollectionStep::new(
1289-
"sled cubby info",
1273+
SupportBundleCollectionStep::STEP_SLED_CUBBY_INFO,
12901274
Box::new({
12911275
let all_sleds = all_sleds.clone();
12921276
let mgs_client = mgs_client.clone();
@@ -1305,7 +1289,7 @@ impl BundleCollection {
13051289
}),
13061290
),
13071291
CollectionStep::new(
1308-
"spawn steps to query all SP dumps",
1292+
SupportBundleCollectionStep::STEP_SPAWN_SP_DUMPS,
13091293
Box::new({
13101294
let mgs_client = mgs_client.clone();
13111295
move |collection, dir| {
@@ -1319,7 +1303,7 @@ impl BundleCollection {
13191303
}),
13201304
),
13211305
CollectionStep::new(
1322-
"spawn steps to query all sleds",
1306+
SupportBundleCollectionStep::STEP_SPAWN_SLEDS,
13231307
Box::new({
13241308
let all_sleds = all_sleds.clone();
13251309
move |collection, _| {
@@ -1369,7 +1353,7 @@ impl BundleCollection {
13691353
));
13701354
}
13711355

1372-
return Ok(CollectionStepOutput::SpawnSleds { extra_steps });
1356+
return Ok(CollectionStepOutput::Spawn { extra_steps });
13731357
}
13741358

13751359
// Collect data from a sled, storing it into a directory that will
@@ -2509,8 +2493,16 @@ mod test {
25092493
.expect("Collection should have succeeded under test")
25102494
.expect("Collecting the bundle should have generated a report");
25112495
assert_eq!(report.bundle, bundle.id.into());
2512-
assert!(report.listed_in_service_sleds);
2513-
assert!(report.listed_sps);
2496+
// Verify that we spawned steps to query sleds and SPs
2497+
let step_names: Vec<_> =
2498+
report.steps.iter().map(|s| s.name.as_str()).collect();
2499+
assert!(
2500+
step_names.contains(&SupportBundleCollectionStep::STEP_SPAWN_SLEDS)
2501+
);
2502+
assert!(
2503+
step_names
2504+
.contains(&SupportBundleCollectionStep::STEP_SPAWN_SP_DUMPS)
2505+
);
25142506
assert!(report.activated_in_db_ok);
25152507
assert_eq!(
25162508
report.ereports,
@@ -2591,8 +2583,16 @@ mod test {
25912583
.expect("Collection should have succeeded under test")
25922584
.expect("Collecting the bundle should have generated a report");
25932585
assert_eq!(report.bundle, bundle.id.into());
2594-
assert!(report.listed_in_service_sleds);
2595-
assert!(report.listed_sps);
2586+
// Verify that we spawned steps to query sleds and SPs
2587+
let step_names: Vec<_> =
2588+
report.steps.iter().map(|s| s.name.as_str()).collect();
2589+
assert!(
2590+
step_names.contains(&SupportBundleCollectionStep::STEP_SPAWN_SLEDS)
2591+
);
2592+
assert!(
2593+
step_names
2594+
.contains(&SupportBundleCollectionStep::STEP_SPAWN_SP_DUMPS)
2595+
);
25962596
assert!(report.activated_in_db_ok);
25972597

25982598
let observed_bundle = datastore
@@ -2678,8 +2678,16 @@ mod test {
26782678
.expect("Collection should have succeeded under test")
26792679
.expect("Collecting the bundle should have generated a report");
26802680
assert_eq!(report.bundle, bundle1.id.into());
2681-
assert!(report.listed_in_service_sleds);
2682-
assert!(report.listed_sps);
2681+
// Verify that we spawned steps to query sleds and SPs
2682+
let step_names: Vec<_> =
2683+
report.steps.iter().map(|s| s.name.as_str()).collect();
2684+
assert!(
2685+
step_names.contains(&SupportBundleCollectionStep::STEP_SPAWN_SLEDS)
2686+
);
2687+
assert!(
2688+
step_names
2689+
.contains(&SupportBundleCollectionStep::STEP_SPAWN_SP_DUMPS)
2690+
);
26832691
assert!(report.activated_in_db_ok);
26842692

26852693
// This is observable by checking the state of bundle1 and bundle2:
@@ -2701,8 +2709,16 @@ mod test {
27012709
.expect("Collection should have succeeded under test")
27022710
.expect("Collecting the bundle should have generated a report");
27032711
assert_eq!(report.bundle, bundle2.id.into());
2704-
assert!(report.listed_in_service_sleds);
2705-
assert!(report.listed_sps);
2712+
// Verify that we spawned steps to query sleds and SPs
2713+
let step_names: Vec<_> =
2714+
report.steps.iter().map(|s| s.name.as_str()).collect();
2715+
assert!(
2716+
step_names.contains(&SupportBundleCollectionStep::STEP_SPAWN_SLEDS)
2717+
);
2718+
assert!(
2719+
step_names
2720+
.contains(&SupportBundleCollectionStep::STEP_SPAWN_SP_DUMPS)
2721+
);
27062722
assert!(report.activated_in_db_ok);
27072723

27082724
// After another collection request, we'll see that both bundles have
@@ -2827,8 +2843,16 @@ mod test {
28272843
.expect("Collection should have succeeded under test")
28282844
.expect("Collecting the bundle should have generated a report");
28292845
assert_eq!(report.bundle, bundle.id.into());
2830-
assert!(report.listed_in_service_sleds);
2831-
assert!(report.listed_sps);
2846+
// Verify that we spawned steps to query sleds and SPs
2847+
let step_names: Vec<_> =
2848+
report.steps.iter().map(|s| s.name.as_str()).collect();
2849+
assert!(
2850+
step_names.contains(&SupportBundleCollectionStep::STEP_SPAWN_SLEDS)
2851+
);
2852+
assert!(
2853+
step_names
2854+
.contains(&SupportBundleCollectionStep::STEP_SPAWN_SP_DUMPS)
2855+
);
28322856
assert!(report.activated_in_db_ok);
28332857

28342858
// Cancel the bundle after collection has completed

nexus/tests/integration_tests/support_bundles.rs

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use nexus_types::external_api::shared::SupportBundleInfo;
1919
use nexus_types::external_api::shared::SupportBundleState;
2020
use nexus_types::internal_api::background::SupportBundleCleanupReport;
2121
use nexus_types::internal_api::background::SupportBundleCollectionReport;
22+
use nexus_types::internal_api::background::SupportBundleCollectionStep;
2223
use nexus_types::internal_api::background::SupportBundleEreportStatus;
2324
use omicron_uuid_kinds::SupportBundleUuid;
2425
use serde::Deserialize;
@@ -489,8 +490,6 @@ async fn test_support_bundle_lifecycle(cptestctx: &ControlPlaneTestContext) {
489490

490491
let report = output.collection_report.as_ref().expect("Missing report");
491492
assert_eq!(report.bundle, bundle.id);
492-
assert!(report.listed_in_service_sleds);
493-
assert!(report.listed_sps);
494493
assert!(report.activated_in_db_ok);
495494
assert_eq!(
496495
report.ereports,
@@ -511,6 +510,18 @@ async fn test_support_bundle_lifecycle(cptestctx: &ControlPlaneTestContext) {
511510
);
512511
}
513512

513+
// Verify that we successfully spawned steps to query sleds and SPs
514+
let step_names: Vec<_> =
515+
report.steps.iter().map(|s| s.name.as_str()).collect();
516+
assert!(
517+
step_names.contains(&SupportBundleCollectionStep::STEP_SPAWN_SLEDS),
518+
"Should have attempted to list in-service sleds"
519+
);
520+
assert!(
521+
step_names.contains(&SupportBundleCollectionStep::STEP_SPAWN_SP_DUMPS),
522+
"Should have attempted to list service processors"
523+
);
524+
514525
let bundle = bundle_get(&client, bundle.id).await.unwrap();
515526
assert_eq!(bundle.state, SupportBundleState::Active);
516527

@@ -601,8 +612,6 @@ async fn test_support_bundle_range_requests(
601612
assert_eq!(output.collection_err, None);
602613
let report = output.collection_report.as_ref().expect("Missing report");
603614
assert_eq!(report.bundle, bundle.id);
604-
assert!(report.listed_in_service_sleds);
605-
assert!(report.listed_sps);
606615
assert!(report.activated_in_db_ok);
607616
assert_eq!(
608617
report.ereports,
@@ -623,6 +632,18 @@ async fn test_support_bundle_range_requests(
623632
);
624633
}
625634

635+
// Verify that we successfully spawned steps to query sleds and SPs
636+
let step_names: Vec<_> =
637+
report.steps.iter().map(|s| s.name.as_str()).collect();
638+
assert!(
639+
step_names.contains(&SupportBundleCollectionStep::STEP_SPAWN_SLEDS),
640+
"Should have attempted to list in-service sleds"
641+
);
642+
assert!(
643+
step_names.contains(&SupportBundleCollectionStep::STEP_SPAWN_SP_DUMPS),
644+
"Should have attempted to list service processors"
645+
);
646+
626647
let bundle = bundle_get(&client, bundle.id).await.unwrap();
627648
assert_eq!(bundle.state, SupportBundleState::Active);
628649

nexus/types/src/internal_api/background.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -272,12 +272,6 @@ pub struct SupportBundleCleanupReport {
272272
pub struct SupportBundleCollectionReport {
273273
pub bundle: SupportBundleUuid,
274274

275-
/// True iff we could list in-service sleds
276-
pub listed_in_service_sleds: bool,
277-
278-
/// True iff we could list the service processors.
279-
pub listed_sps: bool,
280-
281275
/// True iff the bundle was successfully made 'active' in the database.
282276
pub activated_in_db_ok: bool,
283277

@@ -298,6 +292,19 @@ pub struct SupportBundleCollectionStep {
298292
pub status: SupportBundleCollectionStepStatus,
299293
}
300294

295+
impl SupportBundleCollectionStep {
296+
/// Step name constants for the main collection steps.
297+
///
298+
/// These are used both when creating steps and when validating in tests.
299+
pub const STEP_BUNDLE_ID: &'static str = "bundle id";
300+
pub const STEP_RECONFIGURATOR_STATE: &'static str = "reconfigurator state";
301+
pub const STEP_EREPORTS: &'static str = "ereports";
302+
pub const STEP_SLED_CUBBY_INFO: &'static str = "sled cubby info";
303+
pub const STEP_SPAWN_SP_DUMPS: &'static str =
304+
"spawn steps to query all SP dumps";
305+
pub const STEP_SPAWN_SLEDS: &'static str = "spawn steps to query all sleds";
306+
}
307+
301308
#[derive(Debug, Deserialize, Serialize, PartialEq, Eq)]
302309
pub enum SupportBundleCollectionStepStatus {
303310
Ok,
@@ -336,8 +343,6 @@ impl SupportBundleCollectionReport {
336343
pub fn new(bundle: SupportBundleUuid) -> Self {
337344
Self {
338345
bundle,
339-
listed_in_service_sleds: false,
340-
listed_sps: false,
341346
activated_in_db_ok: false,
342347
steps: vec![],
343348
ereports: None,

0 commit comments

Comments
 (0)