Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions dev-tools/omdb/src/bin/omdb/nexus/reconfigurator_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ pub struct ReconfiguratorConfigOpts {

#[clap(long, action = ArgAction::Set)]
add_zones_with_mupdate_override: Option<bool>,

#[clap(long, action = ArgAction::Set)]
tuf_repo_pruner_enabled: Option<bool>,
}

impl ReconfiguratorConfigOpts {
Expand All @@ -69,6 +72,9 @@ impl ReconfiguratorConfigOpts {
current.planner_config.add_zones_with_mupdate_override,
),
},
tuf_repo_pruner_enabled: self
.tuf_repo_pruner_enabled
.unwrap_or(current.tuf_repo_pruner_enabled),
}
}

Expand Down
3 changes: 3 additions & 0 deletions dev-tools/omdb/src/bin/omdb/reconfigurator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ async fn cmd_reconfigurator_config_history(
version: String,
planner_enabled: String,
add_zones_with_mupdate_override: String,
tuf_repo_pruner_enabled: String,
time_modified: String,
}

Expand All @@ -441,6 +442,7 @@ async fn cmd_reconfigurator_config_history(
planner_enabled,
planner_config:
PlannerConfig { add_zones_with_mupdate_override },
tuf_repo_pruner_enabled,
},
time_modified,
} = s;
Expand All @@ -449,6 +451,7 @@ async fn cmd_reconfigurator_config_history(
planner_enabled: planner_enabled.to_string(),
add_zones_with_mupdate_override:
add_zones_with_mupdate_override.to_string(),
tuf_repo_pruner_enabled: tuf_repo_pruner_enabled.to_string(),
time_modified: time_modified.to_string(),
}
})
Expand Down
10 changes: 8 additions & 2 deletions dev-tools/omdb/tests/successes.out
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,7 @@ task: "tuf_repo_pruner"
configured period: every <REDACTED_DURATION>m
last completed activation: <REDACTED ITERATIONS>, triggered by <TRIGGERED_BY_REDACTED>
started at <REDACTED_TIMESTAMP> (<REDACTED DURATION>s ago) and ran for <REDACTED DURATION>ms
status: enabled
configuration:
nkeep_recent_releases: 3
nkeep_recent_uploads: 3
Expand Down Expand Up @@ -1437,6 +1438,7 @@ task: "tuf_repo_pruner"
configured period: every <REDACTED_DURATION>m
last completed activation: <REDACTED ITERATIONS>, triggered by <TRIGGERED_BY_REDACTED>
started at <REDACTED_TIMESTAMP> (<REDACTED DURATION>s ago) and ran for <REDACTED DURATION>ms
status: enabled
configuration:
nkeep_recent_releases: 3
nkeep_recent_uploads: 3
Expand Down Expand Up @@ -1816,6 +1818,7 @@ stdout:
Reconfigurator config:
version: 1
modified time: <REDACTED_TIMESTAMP>
tuf repo pruner enabled: true
planner enabled: false
planner config:
add zones with mupdate override: false
Expand Down Expand Up @@ -1896,7 +1899,8 @@ termination: Exited(0)
---------------------------------------------
stdout:
reconfigurator config updated to version 2:
* planner enabled: false -> true
tuf repo pruner enabled: true (unchanged)
* planner enabled::::::::: false -> true
planner config:
add zones with mupdate override: false (unchanged)
---------------------------------------------
Expand All @@ -1908,7 +1912,8 @@ termination: Exited(0)
---------------------------------------------
stdout:
reconfigurator config updated to version 3:
planner enabled: true (unchanged)
tuf repo pruner enabled: true (unchanged)
planner enabled::::::::: true (unchanged)
planner config:
* add zones with mupdate override: false -> true
---------------------------------------------
Expand All @@ -1922,6 +1927,7 @@ stdout:
Reconfigurator config:
version: 3
modified time: <REDACTED_TIMESTAMP>
tuf repo pruner enabled: true
planner enabled: true
planner config:
add zones with mupdate override: true
Expand Down
2 changes: 2 additions & 0 deletions nexus-config/src/nexus_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1154,6 +1154,7 @@ mod test {
[initial_reconfigurator_config]
planner_enabled = true
planner_config.add_zones_with_mupdate_override = true
tuf_repo_pruner_enabled = false
[background_tasks]
dns_internal.period_secs_config = 1
dns_internal.period_secs_servers = 2
Expand Down Expand Up @@ -1314,6 +1315,7 @@ mod test {
planner_config: PlannerConfig {
add_zones_with_mupdate_override: true,
},
tuf_repo_pruner_enabled: false,
}),
background_tasks: BackgroundTaskConfig {
dns_internal: DnsTasksConfig {
Expand Down
3 changes: 3 additions & 0 deletions nexus/db-model/src/reconfigurator_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub struct ReconfiguratorConfig {
pub planner_enabled: bool,
pub time_modified: DateTime<Utc>,
pub add_zones_with_mupdate_override: bool,
pub tuf_repo_pruner_enabled: bool,
}

impl From<deployment::ReconfiguratorConfigView> for ReconfiguratorConfig {
Expand All @@ -28,6 +29,7 @@ impl From<deployment::ReconfiguratorConfigView> for ReconfiguratorConfig {
.config
.planner_config
.add_zones_with_mupdate_override,
tuf_repo_pruner_enabled: value.config.tuf_repo_pruner_enabled,
}
}
}
Expand All @@ -42,6 +44,7 @@ impl From<ReconfiguratorConfig> for deployment::ReconfiguratorConfigView {
add_zones_with_mupdate_override: value
.add_zones_with_mupdate_override,
},
tuf_repo_pruner_enabled: value.tuf_repo_pruner_enabled,
},
time_modified: value.time_modified,
}
Expand Down
3 changes: 2 additions & 1 deletion nexus/db-model/src/schema_versions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use std::{collections::BTreeMap, sync::LazyLock};
///
/// This must be updated when you change the database schema. Refer to
/// schema/crdb/README.adoc in the root of this repository for details.
pub const SCHEMA_VERSION: Version = Version::new(207, 0, 0);
pub const SCHEMA_VERSION: Version = Version::new(208, 0, 0);

/// List of all past database schema versions, in *reverse* order
///
Expand All @@ -28,6 +28,7 @@ static KNOWN_VERSIONS: LazyLock<Vec<KnownVersion>> = LazyLock::new(|| {
// | leaving the first copy as an example for the next person.
// v
// KnownVersion::new(next_int, "unique-dirname-with-the-sql-files"),
KnownVersion::new(208, "disable-tuf-repo-pruner"),
KnownVersion::new(207, "disk-types"),
KnownVersion::new(206, "fm-sitreps-by-parent-id-index"),
KnownVersion::new(205, "fm-sitrep"),
Expand Down
37 changes: 28 additions & 9 deletions nexus/db-queries/src/db/datastore/reconfigurator_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ use nexus_db_errors::public_error_from_diesel;
use nexus_db_lookup::DbConnection;
use nexus_db_model::ReconfiguratorConfig as DbReconfiguratorConfig;
use nexus_db_model::SqlU32;
use nexus_types::deployment::PlannerConfig;
use nexus_types::deployment::ReconfiguratorConfig;
use nexus_types::deployment::ReconfiguratorConfigParam;
use nexus_types::deployment::ReconfiguratorConfigView;
use omicron_common::api::external::DataPageParams;
Expand Down Expand Up @@ -142,22 +144,38 @@ impl DataStore {
));
}

// This statement exists just to trigger compilation errors when the
// `ReconfiguratorConfigView` type changes so that people are prompted
// to fix this query. If you get a compiler error here, you probably
// added or removed a field to this type, and you will need to adjust
// the query below accordingly.
let ReconfiguratorConfigView {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

version,
config:
ReconfiguratorConfig {
planner_enabled,
planner_config:
PlannerConfig { add_zones_with_mupdate_override },
tuf_repo_pruner_enabled,
},
time_modified,
} = *switches;

sql_query(
r"INSERT INTO reconfigurator_config
(version, planner_enabled, time_modified,
add_zones_with_mupdate_override)
SELECT $1, $2, $3, $4
add_zones_with_mupdate_override, tuf_repo_pruner_enabled)
SELECT $1, $2, $3, $4, $5
WHERE $1 - 1 IN (
SELECT COALESCE(MAX(version), 0)
FROM reconfigurator_config
)",
)
.bind::<sql_types::BigInt, SqlU32>(switches.version.into())
.bind::<sql_types::Bool, _>(switches.config.planner_enabled)
.bind::<sql_types::Timestamptz, _>(switches.time_modified)
.bind::<sql_types::Bool, _>(
switches.config.planner_config.add_zones_with_mupdate_override,
)
.bind::<sql_types::BigInt, SqlU32>(version.into())
.bind::<sql_types::Bool, _>(planner_enabled)
.bind::<sql_types::Timestamptz, _>(time_modified)
.bind::<sql_types::Bool, _>(add_zones_with_mupdate_override)
.bind::<sql_types::Bool, _>(tuf_repo_pruner_enabled)
.execute_async(conn)
.await
.map_err(|e| public_error_from_diesel(e, ErrorHandler::Server))
Expand Down Expand Up @@ -186,12 +204,13 @@ mod tests {
.is_empty()
);

// Fail to insert a swtiches with version 0
// Fail to insert version 0
let mut switches = ReconfiguratorConfigParam {
version: 0,
config: ReconfiguratorConfig {
planner_enabled: false,
planner_config: PlannerConfig::default(),
tuf_repo_pruner_enabled: true,
},
};

Expand Down
1 change: 1 addition & 0 deletions nexus/db-schema/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1967,6 +1967,7 @@ table! {
planner_enabled -> Bool,
time_modified -> Timestamptz,
add_zones_with_mupdate_override -> Bool,
tuf_repo_pruner_enabled -> Bool,
}
}

Expand Down
5 changes: 3 additions & 2 deletions nexus/src/app/background/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ impl BackgroundTasksInitializer {
watchers: vec![
Box::new(inventory_load_watcher.clone()),
Box::new(rx_blueprint.clone()),
Box::new(reconfigurator_config_watcher),
Box::new(reconfigurator_config_watcher.clone()),
],
activator: task_blueprint_planner,
});
Expand Down Expand Up @@ -981,9 +981,10 @@ impl BackgroundTasksInitializer {
task_impl: Box::new(tuf_repo_pruner::TufRepoPruner::new(
datastore.clone(),
config.tuf_repo_pruner.clone(),
reconfigurator_config_watcher.clone(),
)),
opctx: opctx.child(BTreeMap::new()),
watchers: vec![],
watchers: vec![Box::new(reconfigurator_config_watcher)],
activator: task_tuf_repo_pruner,
});

Expand Down
7 changes: 3 additions & 4 deletions nexus/src/app/background/tasks/blueprint_planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,7 @@ mod test {
use nexus_test_utils::db::TestDatabase;
use nexus_test_utils_macros::nexus_test;
use nexus_types::deployment::{
PendingMgsUpdates, PlannerConfig, ReconfiguratorConfig,
ReconfiguratorConfigView,
PendingMgsUpdates, ReconfiguratorConfig, ReconfiguratorConfigView,
};
use omicron_test_utils::dev;
use omicron_uuid_kinds::OmicronZoneUuid;
Expand Down Expand Up @@ -488,7 +487,7 @@ mod test {
version: 1,
config: ReconfiguratorConfig {
planner_enabled: true,
planner_config: PlannerConfig::default(),
..ReconfiguratorConfig::default()
},
time_modified: now_db_precision(),
}),
Expand Down Expand Up @@ -660,7 +659,7 @@ mod test {
version: 1,
config: ReconfiguratorConfig {
planner_enabled: true,
planner_config: PlannerConfig::default(),
..ReconfiguratorConfig::default()
},
time_modified: now_db_precision(),
}),
Expand Down
Loading
Loading