Skip to content

Commit e69f392

Browse files
committed
[support bundle] Simplify report, relying on new 'steps' infrastructure
1 parent 4d59114 commit e69f392

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
@@ -2610,21 +2610,13 @@ fn print_task_support_bundle_collector(details: &serde_json::Value) {
26102610

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

26292621
#[derive(Tabled)]
26302622
#[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
@@ -629,15 +629,6 @@ impl CompletedCollectionStep {
629629
report.ereports = Some(status);
630630
Status::Ok
631631
}
632-
CollectionStepOutput::SavingSpDumps { listed_sps } => {
633-
report.listed_sps = listed_sps;
634-
Status::Ok
635-
}
636-
CollectionStepOutput::SpawnSleds { extra_steps } => {
637-
report.listed_in_service_sleds = true;
638-
steps.extend(extra_steps);
639-
Status::Ok
640-
}
641632
CollectionStepOutput::Spawn { extra_steps } => {
642633
steps.extend(extra_steps);
643634
Status::Ok
@@ -664,14 +655,7 @@ enum CollectionStepOutput {
664655
// It may have still saved a partial set of data to the bundle.
665656
Failed(anyhow::Error),
666657
Ereports(SupportBundleEreportStatus),
667-
SavingSpDumps { listed_sps: bool },
668-
// NOTE: The distinction between this and "Spawn" is pretty artificial -
669-
// it's just to preserve a part of the report which says "we tried to
670-
// list in-service sleds".
671-
//
672-
// If we changed the collection report, this could easily be combined
673-
// with the "Spawn" variant.
674-
SpawnSleds { extra_steps: Vec<CollectionStep> },
658+
// The step spawned additional steps to execute
675659
Spawn { extra_steps: Vec<CollectionStep> },
676660
// The step completed with nothing to report, and no follow-up steps
677661
None,
@@ -1149,7 +1133,7 @@ impl BundleCollection {
11491133
format!("failed to save SP dump from: {} {}", sp.type_, sp.slot)
11501134
})?;
11511135

1152-
Ok(CollectionStepOutput::SavingSpDumps { listed_sps: true })
1136+
Ok(CollectionStepOutput::None)
11531137
}
11541138

11551139
// Perform the work of collecting the support bundle into a temporary directory
@@ -1185,25 +1169,25 @@ impl BundleCollection {
11851169

11861170
let steps: Vec<CollectionStep> = vec![
11871171
CollectionStep::new(
1188-
"bundle id",
1172+
SupportBundleCollectionStep::STEP_BUNDLE_ID,
11891173
Box::new(|collection, dir| {
11901174
collection.collect_bundle_id(dir).boxed()
11911175
}),
11921176
),
11931177
CollectionStep::new(
1194-
"reconfigurator state",
1178+
SupportBundleCollectionStep::STEP_RECONFIGURATOR_STATE,
11951179
Box::new(|collection, dir| {
11961180
collection.collect_reconfigurator_state(dir).boxed()
11971181
}),
11981182
),
11991183
CollectionStep::new(
1200-
"ereports",
1184+
SupportBundleCollectionStep::STEP_EREPORTS,
12011185
Box::new(|collection, dir| {
12021186
collection.collect_ereports(dir).boxed()
12031187
}),
12041188
),
12051189
CollectionStep::new(
1206-
"sled cubby info",
1190+
SupportBundleCollectionStep::STEP_SLED_CUBBY_INFO,
12071191
Box::new({
12081192
let all_sleds = all_sleds.clone();
12091193
let mgs_client = mgs_client.clone();
@@ -1222,7 +1206,7 @@ impl BundleCollection {
12221206
}),
12231207
),
12241208
CollectionStep::new(
1225-
"spawn steps to query all SP dumps",
1209+
SupportBundleCollectionStep::STEP_SPAWN_SP_DUMPS,
12261210
Box::new({
12271211
let mgs_client = mgs_client.clone();
12281212
move |collection, dir| {
@@ -1236,7 +1220,7 @@ impl BundleCollection {
12361220
}),
12371221
),
12381222
CollectionStep::new(
1239-
"spawn steps to query all sleds",
1223+
SupportBundleCollectionStep::STEP_SPAWN_SLEDS,
12401224
Box::new({
12411225
let all_sleds = all_sleds.clone();
12421226
move |collection, _| {
@@ -1286,7 +1270,7 @@ impl BundleCollection {
12861270
));
12871271
}
12881272

1289-
return Ok(CollectionStepOutput::SpawnSleds { extra_steps });
1273+
return Ok(CollectionStepOutput::Spawn { extra_steps });
12901274
}
12911275

12921276
// Collect data from a sled, storing it into a directory that will
@@ -2425,8 +2409,16 @@ mod test {
24252409
.expect("Collection should have succeeded under test")
24262410
.expect("Collecting the bundle should have generated a report");
24272411
assert_eq!(report.bundle, bundle.id.into());
2428-
assert!(report.listed_in_service_sleds);
2429-
assert!(report.listed_sps);
2412+
// Verify that we spawned steps to query sleds and SPs
2413+
let step_names: Vec<_> =
2414+
report.steps.iter().map(|s| s.name.as_str()).collect();
2415+
assert!(
2416+
step_names.contains(&SupportBundleCollectionStep::STEP_SPAWN_SLEDS)
2417+
);
2418+
assert!(
2419+
step_names
2420+
.contains(&SupportBundleCollectionStep::STEP_SPAWN_SP_DUMPS)
2421+
);
24302422
assert!(report.activated_in_db_ok);
24312423
assert_eq!(
24322424
report.ereports,
@@ -2502,8 +2494,16 @@ mod test {
25022494
.expect("Collection should have succeeded under test")
25032495
.expect("Collecting the bundle should have generated a report");
25042496
assert_eq!(report.bundle, bundle.id.into());
2505-
assert!(report.listed_in_service_sleds);
2506-
assert!(report.listed_sps);
2497+
// Verify that we spawned steps to query sleds and SPs
2498+
let step_names: Vec<_> =
2499+
report.steps.iter().map(|s| s.name.as_str()).collect();
2500+
assert!(
2501+
step_names.contains(&SupportBundleCollectionStep::STEP_SPAWN_SLEDS)
2502+
);
2503+
assert!(
2504+
step_names
2505+
.contains(&SupportBundleCollectionStep::STEP_SPAWN_SP_DUMPS)
2506+
);
25072507
assert!(report.activated_in_db_ok);
25082508

25092509
let observed_bundle = datastore
@@ -2591,8 +2591,16 @@ mod test {
25912591
.expect("Collection should have succeeded under test")
25922592
.expect("Collecting the bundle should have generated a report");
25932593
assert_eq!(report.bundle, bundle1.id.into());
2594-
assert!(report.listed_in_service_sleds);
2595-
assert!(report.listed_sps);
2594+
// Verify that we spawned steps to query sleds and SPs
2595+
let step_names: Vec<_> =
2596+
report.steps.iter().map(|s| s.name.as_str()).collect();
2597+
assert!(
2598+
step_names.contains(&SupportBundleCollectionStep::STEP_SPAWN_SLEDS)
2599+
);
2600+
assert!(
2601+
step_names
2602+
.contains(&SupportBundleCollectionStep::STEP_SPAWN_SP_DUMPS)
2603+
);
25962604
assert!(report.activated_in_db_ok);
25972605

25982606
// This is observable by checking the state of bundle1 and bundle2:
@@ -2614,8 +2622,16 @@ mod test {
26142622
.expect("Collection should have succeeded under test")
26152623
.expect("Collecting the bundle should have generated a report");
26162624
assert_eq!(report.bundle, bundle2.id.into());
2617-
assert!(report.listed_in_service_sleds);
2618-
assert!(report.listed_sps);
2625+
// Verify that we spawned steps to query sleds and SPs
2626+
let step_names: Vec<_> =
2627+
report.steps.iter().map(|s| s.name.as_str()).collect();
2628+
assert!(
2629+
step_names.contains(&SupportBundleCollectionStep::STEP_SPAWN_SLEDS)
2630+
);
2631+
assert!(
2632+
step_names
2633+
.contains(&SupportBundleCollectionStep::STEP_SPAWN_SP_DUMPS)
2634+
);
26192635
assert!(report.activated_in_db_ok);
26202636

26212637
// After another collection request, we'll see that both bundles have
@@ -2742,8 +2758,16 @@ mod test {
27422758
.expect("Collection should have succeeded under test")
27432759
.expect("Collecting the bundle should have generated a report");
27442760
assert_eq!(report.bundle, bundle.id.into());
2745-
assert!(report.listed_in_service_sleds);
2746-
assert!(report.listed_sps);
2761+
// Verify that we spawned steps to query sleds and SPs
2762+
let step_names: Vec<_> =
2763+
report.steps.iter().map(|s| s.name.as_str()).collect();
2764+
assert!(
2765+
step_names.contains(&SupportBundleCollectionStep::STEP_SPAWN_SLEDS)
2766+
);
2767+
assert!(
2768+
step_names
2769+
.contains(&SupportBundleCollectionStep::STEP_SPAWN_SP_DUMPS)
2770+
);
27472771
assert!(report.activated_in_db_ok);
27482772

27492773
// 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)