Skip to content

Commit

Permalink
[reconfigurator] Decommission sleds (#5698)
Browse files Browse the repository at this point in the history
This builds on (and is currently pointed at) #5663, and is on the path
to fixing #5625, although there is still more work to do there. (Should
be small, and I'll start on it while this is in review to make sure it
really fixes it.) I don't plan on landing this before R8 is out the
door, but wanted to go ahead and open it up to review.

Much of this is fallout from our discussions about what it means to
decommission a sled. Major changes are:

* `SledFilter::All` has been renamed to `SledFilter::Commissioned`, and
no longer returns sleds that are in `SledState::Decommissioned`.
* The blueprint planner will now update the desired sled state to
`Decommissioned` for sleds which satisfy our conditions. (See
`do_plan_decommission()`.)
* The blueprint planner will carry forward the Omicron zones of
decommissioned sleds to child blueprints. Pruning these is #5552.
* The blueprint planner will _not_ carry forward a desired sled state of
`Decommissioned` once the inputs report that the sled has already been
decommissioned.
* The blueprint executor will decommission sleds that the planner said
to.
* Decommissioning a sled implicitly decommissions all its disks. (This
matches what happens with sled expungement, and should not interfere
with region replacement, which keys off of policy, not state.)
  • Loading branch information
jgallagher authored May 13, 2024
1 parent d2ed452 commit a0cc2ff
Show file tree
Hide file tree
Showing 26 changed files with 896 additions and 208 deletions.
7 changes: 5 additions & 2 deletions dev-tools/omdb/src/bin/omdb/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1455,8 +1455,11 @@ async fn cmd_db_sleds(
let filter = match args.filter {
Some(filter) => filter,
None => {
eprintln!("note: listing all sleds (use -F to filter, e.g. -F in-service)");
SledFilter::All
eprintln!(
"note: listing all commissioned sleds \
(use -F to filter, e.g. -F in-service)"
);
SledFilter::Commissioned
}
};

Expand Down
6 changes: 3 additions & 3 deletions dev-tools/omdb/tests/env.out
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ stdout:
stderr:
note: using database URL postgresql://root@[::1]:REDACTED_PORT/omicron?sslmode=disable
note: database schema version matches expected (<redacted database version>)
note: listing all sleds (use -F to filter, e.g. -F in-service)
note: listing all commissioned sleds (use -F to filter, e.g. -F in-service)
=============================================
EXECUTING COMMAND: omdb ["db", "--db-url", "junk", "sleds"]
termination: Exited(2)
Expand Down Expand Up @@ -341,7 +341,7 @@ note: database URL not specified. Will search DNS.
note: (override with --db-url or OMDB_DB_URL)
note: using database URL postgresql://root@[::1]:REDACTED_PORT/omicron?sslmode=disable
note: database schema version matches expected (<redacted database version>)
note: listing all sleds (use -F to filter, e.g. -F in-service)
note: listing all commissioned sleds (use -F to filter, e.g. -F in-service)
=============================================
EXECUTING COMMAND: omdb ["--dns-server", "[::1]:REDACTED_PORT", "db", "sleds"]
termination: Exited(0)
Expand All @@ -356,5 +356,5 @@ note: database URL not specified. Will search DNS.
note: (override with --db-url or OMDB_DB_URL)
note: using database URL postgresql://root@[::1]:REDACTED_PORT/omicron?sslmode=disable
note: database schema version matches expected (<redacted database version>)
note: listing all sleds (use -F to filter, e.g. -F in-service)
note: listing all commissioned sleds (use -F to filter, e.g. -F in-service)
=============================================
2 changes: 1 addition & 1 deletion dev-tools/omdb/tests/successes.out
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ stdout:
stderr:
note: using database URL postgresql://root@[::1]:REDACTED_PORT/omicron?sslmode=disable
note: database schema version matches expected (<redacted database version>)
note: listing all sleds (use -F to filter, e.g. -F in-service)
note: listing all commissioned sleds (use -F to filter, e.g. -F in-service)
=============================================
EXECUTING COMMAND: omdb ["db", "sleds", "-F", "discretionary"]
termination: Exited(0)
Expand Down
2 changes: 1 addition & 1 deletion dev-tools/omdb/tests/test_all_output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ async fn test_omdb_success_cases(cptestctx: &ControlPlaneTestContext) {
// collection?
assert!(parsed
.planning_input
.all_sled_ids(SledFilter::All)
.all_sled_ids(SledFilter::Commissioned)
.next()
.is_some());
assert!(!parsed.collections.is_empty());
Expand Down
2 changes: 1 addition & 1 deletion dev-tools/omdb/tests/usage_errors.out
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ Options:
Show sleds that match the given filter

Possible values:
- all: All sleds
- commissioned: All sleds that are currently part of the control plane cluster
- discretionary: Sleds that are eligible for discretionary services
- in-service: Sleds that are in service (even if they might not be eligible
for discretionary services)
Expand Down
8 changes: 4 additions & 4 deletions dev-tools/reconfigurator-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ fn cmd_sled_list(
.to_planning_input_builder()
.context("failed to generate planning input")?
.build();
let rows = planning_input.all_sled_resources(SledFilter::All).map(
let rows = planning_input.all_sled_resources(SledFilter::Commissioned).map(
|(sled_id, sled_resources)| Sled {
id: sled_id,
subnet: sled_resources.subnet.net().to_string(),
Expand Down Expand Up @@ -648,7 +648,7 @@ fn cmd_inventory_generate(
// has no zones on it.
let planning_input =
sim.system.to_planning_input_builder().unwrap().build();
for sled_id in planning_input.all_sled_ids(SledFilter::All) {
for sled_id in planning_input.all_sled_ids(SledFilter::Commissioned) {
builder
.found_sled_omicron_zones(
"fake sled agent",
Expand Down Expand Up @@ -1077,7 +1077,7 @@ fn cmd_load(
.context("generating planning input")?
.build();
for (sled_id, sled_details) in
loaded.planning_input.all_sleds(SledFilter::All)
loaded.planning_input.all_sleds(SledFilter::Commissioned)
{
if current_planning_input.sled_resources(&sled_id).is_some() {
swriteln!(
Expand Down Expand Up @@ -1202,7 +1202,7 @@ fn cmd_file_contents(args: FileContentsArgs) -> anyhow::Result<Option<String>> {
let mut s = String::new();

for (sled_id, sled_resources) in
loaded.planning_input.all_sled_resources(SledFilter::All)
loaded.planning_input.all_sled_resources(SledFilter::Commissioned)
{
swriteln!(
s,
Expand Down
2 changes: 1 addition & 1 deletion nexus/db-queries/src/db/datastore/deployment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1553,7 +1553,7 @@ mod tests {
// Check the number of blueprint elements against our collection.
assert_eq!(
blueprint1.blueprint_zones.len(),
planning_input.all_sled_ids(SledFilter::All).count(),
planning_input.all_sled_ids(SledFilter::Commissioned).count(),
);
assert_eq!(
blueprint1.blueprint_zones.len(),
Expand Down
2 changes: 2 additions & 0 deletions nexus/db-queries/src/db/datastore/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ pub use probe::ProbeInfo;
pub use rack::RackInit;
pub use rack::SledUnderlayAllocationResult;
pub use silo::Discoverability;
pub use sled::SledTransition;
pub use sled::TransitionError;
pub use switch_port::SwitchPortSettingsCombinedResult;
pub use virtual_provisioning_collection::StorageType;
pub use volume::read_only_resources_associated_with_volume;
Expand Down
Loading

0 comments on commit a0cc2ff

Please sign in to comment.