Skip to content

Commit

Permalink
Add structured output for support bundle task (#7360)
Browse files Browse the repository at this point in the history
Depends on #7357
  • Loading branch information
smklein authored Jan 25, 2025
1 parent bcdfe14 commit 888f90d
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 2 deletions.
65 changes: 65 additions & 0 deletions dev-tools/omdb/src/bin/omdb/nexus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ use nexus_types::internal_api::background::RegionSnapshotReplacementFinishStatus
use nexus_types::internal_api::background::RegionSnapshotReplacementGarbageCollectStatus;
use nexus_types::internal_api::background::RegionSnapshotReplacementStartStatus;
use nexus_types::internal_api::background::RegionSnapshotReplacementStepStatus;
use nexus_types::internal_api::background::SupportBundleCleanupReport;
use nexus_types::internal_api::background::SupportBundleCollectionReport;
use nexus_types::inventory::BaseboardId;
use omicron_uuid_kinds::BlueprintUuid;
use omicron_uuid_kinds::CollectionUuid;
Expand Down Expand Up @@ -943,6 +945,9 @@ fn print_task_details(bgtask: &BackgroundTask, details: &serde_json::Value) {
"service_firewall_rule_propagation" => {
print_task_service_firewall_rule_propagation(details);
}
"support_bundle_collector" => {
print_task_support_bundle_collector(details);
}
_ => {
println!(
"warning: unknown background task: {:?} \
Expand Down Expand Up @@ -2024,6 +2029,66 @@ fn print_task_service_firewall_rule_propagation(details: &serde_json::Value) {
};
}

fn print_task_support_bundle_collector(details: &serde_json::Value) {
#[derive(Deserialize)]
struct SupportBundleCollectionStatus {
cleanup_report: Option<SupportBundleCleanupReport>,
cleanup_err: Option<String>,
collection_report: Option<SupportBundleCollectionReport>,
collection_err: Option<String>,
}

match serde_json::from_value::<SupportBundleCollectionStatus>(
details.clone(),
) {
Err(error) => eprintln!(
"warning: failed to interpret task details: {:?}: {:?}",
error, details
),
Ok(SupportBundleCollectionStatus {
cleanup_report,
cleanup_err,
collection_report,
collection_err,
}) => {
if let Some(cleanup_err) = cleanup_err {
println!(" failed to perform cleanup: {cleanup_err}");
}
if let Some(SupportBundleCleanupReport {
sled_bundles_deleted_ok,
sled_bundles_deleted_not_found,
sled_bundles_delete_failed,
db_destroying_bundles_removed,
db_failing_bundles_updated,
}) = cleanup_report
{
println!(" Support Bundle Cleanup Report:");
println!(" Bundles deleted from sleds: {sled_bundles_deleted_ok}");
println!(" Bundles not found on sleds: {sled_bundles_deleted_not_found}");
println!(" Bundles delete failed on sleds: {sled_bundles_delete_failed}");
println!(" Bundles deleted from database: {db_destroying_bundles_removed}");
println!(" Bundles marked failed in database: {db_failing_bundles_updated}");
}

if let Some(collection_err) = collection_err {
println!(" failed to perform collection: {collection_err}");
}

if let Some(SupportBundleCollectionReport {
bundle,
listed_in_service_sleds,
activated_in_db_ok,
}) = collection_report
{
println!(" Support Bundle Collection Report:");
println!(" Bundle ID: {bundle}");
println!(" Bundle was able to list in-service sleds: {listed_in_service_sleds}");
println!(" Bundle was activated in the database: {activated_in_db_ok}");
}
}
}
}

/// Summarizes an `ActivationReason`
fn reason_str(reason: &ActivationReason) -> &'static str {
match reason {
Expand Down
14 changes: 12 additions & 2 deletions dev-tools/omdb/tests/successes.out
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,12 @@ task: "support_bundle_collector"
currently executing: no
last completed activation: <REDACTED ITERATIONS>, triggered by a periodic timer firing
started at <REDACTED_TIMESTAMP> (<REDACTED DURATION>s ago) and ran for <REDACTED DURATION>ms
warning: unknown background task: "support_bundle_collector" (don't know how to interpret details: Object {"cleanup_err": Null, "cleanup_report": Object {"db_destroying_bundles_removed": Number(0), "db_failing_bundles_updated": Number(0), "sled_bundles_delete_failed": Number(0), "sled_bundles_deleted_not_found": Number(0), "sled_bundles_deleted_ok": Number(0)}, "collection_err": Null, "collection_report": Null})
Support Bundle Cleanup Report:
Bundles deleted from sleds: 0
Bundles not found on sleds: 0
Bundles delete failed on sleds: 0
Bundles deleted from database: 0
Bundles marked failed in database: 0

task: "switch_port_config_manager"
configured period: every <REDACTED_DURATION>s
Expand Down Expand Up @@ -1174,7 +1179,12 @@ task: "support_bundle_collector"
currently executing: no
last completed activation: <REDACTED ITERATIONS>, triggered by a periodic timer firing
started at <REDACTED_TIMESTAMP> (<REDACTED DURATION>s ago) and ran for <REDACTED DURATION>ms
warning: unknown background task: "support_bundle_collector" (don't know how to interpret details: Object {"cleanup_err": Null, "cleanup_report": Object {"db_destroying_bundles_removed": Number(0), "db_failing_bundles_updated": Number(0), "sled_bundles_delete_failed": Number(0), "sled_bundles_deleted_not_found": Number(0), "sled_bundles_deleted_ok": Number(0)}, "collection_err": Null, "collection_report": Null})
Support Bundle Cleanup Report:
Bundles deleted from sleds: 0
Bundles not found on sleds: 0
Bundles delete failed on sleds: 0
Bundles deleted from database: 0
Bundles marked failed in database: 0

task: "switch_port_config_manager"
configured period: every <REDACTED_DURATION>s
Expand Down

0 comments on commit 888f90d

Please sign in to comment.