Skip to content

Commit cdf65d1

Browse files
jgallagherhawkw
authored andcommitted
[reconfigurator] Fix assert_planning_makes_no_changes() (#7512)
Despite its name, this test function didn't actually invoke the planner. Now it does, and this fixes up some tests that now fail (and changes the behavior of the planner in one case where the test failure arguably indicated some planner misbehavior). The specific planner change: Previously, if we added an NTP zone to a sled, we considered that sled ineligible for any other zones (consistent with the sled-agent behavior of refusing to start zones if time isn't sync'd yet). This PR relaxes that slightly: if we're adding an NTP zone to a sled and that sled already has other zones that needed time to be sync'd, we do consider it eligible. This avoids having to make multiple planner iterations to repopulate a sled that had a subset of disks/zones expunged, while maintaining the existing behavior for new sleds being added. I'm not totally convinced that the existing behavior for new sleds is necessary; since we're only waiting for the presence of an NTP zone, not an inventory report that time is actually sync'd, I'm not sure there's a meaningful difference to requiring two planning iterations instead of one to place extra zones. But I don't have a reason to propose changing it or testing it other than "seems a little over-cautious", so it seems fine to leave it.
1 parent ce67d90 commit cdf65d1

File tree

3 files changed

+150
-105
lines changed

3 files changed

+150
-105
lines changed

nexus/reconfigurator/planning/src/blueprint_builder/builder.rs

Lines changed: 18 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2057,8 +2057,8 @@ pub mod test {
20572057
use crate::example::example;
20582058
use crate::example::ExampleSystemBuilder;
20592059
use crate::example::SimRngState;
2060+
use crate::planner::test::assert_planning_makes_no_changes;
20602061
use crate::system::SledBuilder;
2061-
use nexus_inventory::CollectionBuilder;
20622062
use nexus_reconfigurator_blippy::Blippy;
20632063
use nexus_reconfigurator_blippy::BlippyReportSortKey;
20642064
use nexus_types::deployment::BlueprintDatasetDisposition;
@@ -2087,34 +2087,6 @@ pub mod test {
20872087
}
20882088
}
20892089

2090-
#[track_caller]
2091-
pub fn assert_planning_makes_no_changes(
2092-
log: &Logger,
2093-
blueprint: &Blueprint,
2094-
input: &PlanningInput,
2095-
test_name: &'static str,
2096-
) {
2097-
let collection = CollectionBuilder::new("test").build();
2098-
let builder = BlueprintBuilder::new_based_on(
2099-
&log,
2100-
&blueprint,
2101-
&input,
2102-
&collection,
2103-
test_name,
2104-
)
2105-
.expect("failed to create builder");
2106-
let child_blueprint = builder.build();
2107-
verify_blueprint(&child_blueprint);
2108-
let diff = child_blueprint.diff_since_blueprint(&blueprint);
2109-
println!(
2110-
"diff between blueprints (expected no changes):\n{}",
2111-
diff.display()
2112-
);
2113-
assert_eq!(diff.sleds_added.len(), 0);
2114-
assert_eq!(diff.sleds_removed.len(), 0);
2115-
assert_eq!(diff.sleds_modified.len(), 0);
2116-
}
2117-
21182090
#[test]
21192091
fn test_basic() {
21202092
static TEST_NAME: &str = "blueprint_builder_test_basic";
@@ -2267,6 +2239,7 @@ pub mod test {
22672239
&logctx.log,
22682240
&blueprint3,
22692241
&input,
2242+
&example.collection,
22702243
TEST_NAME,
22712244
);
22722245

@@ -2388,14 +2361,6 @@ pub mod test {
23882361
Some(SledState::Decommissioned),
23892362
);
23902363

2391-
// Test a no-op planning iteration.
2392-
assert_planning_makes_no_changes(
2393-
&logctx.log,
2394-
&blueprint4,
2395-
&input,
2396-
TEST_NAME,
2397-
);
2398-
23992364
logctx.cleanup_successful();
24002365
}
24012366

@@ -2840,14 +2805,25 @@ pub mod test {
28402805
static TEST_NAME: &str = "blueprint_builder_test_ensure_cockroachdb";
28412806
let logctx = test_setup_log(TEST_NAME);
28422807

2843-
// Start with an empty system (sleds with no zones).
2808+
// Start with an example system (no CRDB zones).
28442809
let (example, parent) =
2845-
ExampleSystemBuilder::new(&logctx.log, TEST_NAME)
2846-
.create_zones(false)
2847-
.build();
2810+
ExampleSystemBuilder::new(&logctx.log, TEST_NAME).build();
28482811
let collection = example.collection;
28492812
let input = example.input;
28502813

2814+
// Ensure no CRDB zones (currently `ExampleSystemBuilder` never
2815+
// provisions CRDB; this check makes sure we update our use of it if
2816+
// that changes).
2817+
for (_, z) in
2818+
parent.all_omicron_zones(BlueprintZoneFilter::ShouldBeRunning)
2819+
{
2820+
assert!(
2821+
!z.zone_type.is_cockroach(),
2822+
"unexpected cockroach zone \
2823+
(update use of ExampleSystemBuilder?): {z:?}"
2824+
);
2825+
}
2826+
28512827
// Pick an arbitrary sled.
28522828
let (target_sled_id, sled_resources) = input
28532829
.all_sled_resources(SledFilter::InService)
@@ -2895,6 +2871,7 @@ pub mod test {
28952871
&logctx.log,
28962872
&blueprint,
28972873
&input,
2874+
&collection,
28982875
TEST_NAME,
28992876
);
29002877

0 commit comments

Comments
 (0)