Skip to content

Commit 5bc38cc

Browse files
committed
Support bundle: automatic deletion to maintain free dataset buffer
1 parent f507a30 commit 5bc38cc

File tree

11 files changed

+667
-3
lines changed

11 files changed

+667
-3
lines changed

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ use nexus_types::internal_api::background::RegionSnapshotReplacementStartStatus;
7070
use nexus_types::internal_api::background::RegionSnapshotReplacementStepStatus;
7171
use nexus_types::internal_api::background::SitrepGcStatus;
7272
use nexus_types::internal_api::background::SitrepLoadStatus;
73+
use nexus_types::internal_api::background::SupportBundleAutoDeletionReport;
7374
use nexus_types::internal_api::background::SupportBundleCleanupReport;
7475
use nexus_types::internal_api::background::SupportBundleCollectionReport;
7576
use nexus_types::internal_api::background::SupportBundleCollectionStepStatus;
@@ -2557,6 +2558,7 @@ fn print_task_service_firewall_rule_propagation(details: &serde_json::Value) {
25572558
fn print_task_support_bundle_collector(details: &serde_json::Value) {
25582559
#[derive(Deserialize)]
25592560
struct SupportBundleCollectionStatus {
2561+
auto_deletion_report: Option<SupportBundleAutoDeletionReport>,
25602562
cleanup_report: Option<SupportBundleCleanupReport>,
25612563
cleanup_err: Option<String>,
25622564
collection_report: Option<SupportBundleCollectionReport>,
@@ -2571,11 +2573,36 @@ fn print_task_support_bundle_collector(details: &serde_json::Value) {
25712573
error, details
25722574
),
25732575
Ok(SupportBundleCollectionStatus {
2576+
auto_deletion_report,
25742577
cleanup_report,
25752578
cleanup_err,
25762579
collection_report,
25772580
collection_err,
25782581
}) => {
2582+
// Print auto-deletion report first (since it runs first)
2583+
if let Some(SupportBundleAutoDeletionReport {
2584+
bundles_marked_for_deletion,
2585+
free_datasets,
2586+
total_datasets,
2587+
active_bundles,
2588+
errors,
2589+
}) = auto_deletion_report
2590+
{
2591+
println!(" Support Bundle Auto-Deletion Report:");
2592+
println!(" Total debug datasets: {total_datasets}");
2593+
println!(" Active bundles: {active_bundles}");
2594+
println!(" Free datasets: {free_datasets}");
2595+
println!(
2596+
" Bundles marked for deletion: {bundles_marked_for_deletion}"
2597+
);
2598+
if !errors.is_empty() {
2599+
println!(" Errors:");
2600+
for error in errors {
2601+
println!(" {error}");
2602+
}
2603+
}
2604+
}
2605+
25792606
if let Some(cleanup_err) = cleanup_err {
25802607
println!(" failed to perform cleanup: {cleanup_err}");
25812608
}

nexus-config/src/nexus_config.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ use std::collections::HashMap;
3030
use std::fmt;
3131
use std::net::IpAddr;
3232
use std::net::SocketAddr;
33+
use std::num::NonZeroU32;
3334
use std::time::Duration;
3435
use uuid::Uuid;
3536

@@ -489,6 +490,25 @@ pub struct SupportBundleCollectorConfig {
489490
/// Default: Off
490491
#[serde(default)]
491492
pub disable: bool,
493+
494+
/// Target number of free debug datasets to maintain for new allocations.
495+
///
496+
/// When the number of free debug datasets drops below this value, the
497+
/// oldest support bundles will be automatically deleted to free up space.
498+
///
499+
/// Default: None (auto-deletion disabled)
500+
#[serde(default)]
501+
pub target_free_datasets: Option<NonZeroU32>,
502+
503+
/// Minimum number of bundles to retain, even if `target_free_datasets`
504+
/// would otherwise trigger deletion.
505+
///
506+
/// This prevents aggressive cleanup on small systems where the number of
507+
/// debug datasets is less than or equal to `target_free_datasets`.
508+
///
509+
/// Default: None (no minimum, can delete all bundles)
510+
#[serde(default)]
511+
pub min_bundles_to_keep: Option<NonZeroU32>,
492512
}
493513

494514
#[serde_as]
@@ -1407,6 +1427,8 @@ mod test {
14071427
SupportBundleCollectorConfig {
14081428
period_secs: Duration::from_secs(30),
14091429
disable: false,
1430+
target_free_datasets: None,
1431+
min_bundles_to_keep: None,
14101432
},
14111433
physical_disk_adoption: PhysicalDiskAdoptionConfig {
14121434
period_secs: Duration::from_secs(30),

nexus/db-model/src/schema_versions.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use std::{collections::BTreeMap, sync::LazyLock};
1616
///
1717
/// This must be updated when you change the database schema. Refer to
1818
/// schema/crdb/README.adoc in the root of this repository for details.
19-
pub const SCHEMA_VERSION: Version = Version::new(220, 0, 0);
19+
pub const SCHEMA_VERSION: Version = Version::new(221, 0, 0);
2020

2121
/// List of all past database schema versions, in *reverse* order
2222
///
@@ -28,6 +28,7 @@ static KNOWN_VERSIONS: LazyLock<Vec<KnownVersion>> = LazyLock::new(|| {
2828
// | leaving the first copy as an example for the next person.
2929
// v
3030
// KnownVersion::new(next_int, "unique-dirname-with-the-sql-files"),
31+
KnownVersion::new(221, "bundle-state-index"),
3132
KnownVersion::new(220, "multicast-implicit-lifecycle"),
3233
KnownVersion::new(219, "blueprint-sled-last-used-ip"),
3334
KnownVersion::new(218, "measurements"),

0 commit comments

Comments
 (0)