diff --git a/nexus/reconfigurator/planning/src/blueprint_builder/builder.rs b/nexus/reconfigurator/planning/src/blueprint_builder/builder.rs index b2124bcd20..d50f01b720 100644 --- a/nexus/reconfigurator/planning/src/blueprint_builder/builder.rs +++ b/nexus/reconfigurator/planning/src/blueprint_builder/builder.rs @@ -276,7 +276,6 @@ pub struct BlueprintBuilder<'a> { sled_ip_allocators: BTreeMap, external_networking: OnceCell>, internal_dns_subnets: OnceCell, - clickhouse_allocator: Option, // These fields will become part of the final blueprint. See the // corresponding fields in `Blueprint`. @@ -370,8 +369,6 @@ impl<'a> BlueprintBuilder<'a> { "parent_id" => parent_blueprint.id.to_string(), )); - let mut rng = PlannerRng::new(); - // Prefer the sled state from our parent blueprint for sleds // that were in it; there may be new sleds in `input`, in which // case we'll use their current state as our starting point. @@ -397,46 +394,6 @@ impl<'a> BlueprintBuilder<'a> { || commissioned_sled_ids.contains(sled_id) }); - // If we have the clickhouse cluster setup enabled via policy and we - // don't yet have a `ClickhouseClusterConfiguration`, then we must create - // one and feed it to our `ClickhouseAllocator`. - let clickhouse_allocator = if input.clickhouse_cluster_enabled() { - let parent_config = parent_blueprint - .clickhouse_cluster_config - .clone() - .unwrap_or_else(|| { - info!( - log, - concat!( - "Clickhouse cluster enabled by policy: ", - "generating initial 'ClickhouseClusterConfig' ", - "and 'ClickhouseAllocator'" - ) - ); - ClickhouseClusterConfig::new( - OXIMETER_CLUSTER.to_string(), - rng.next_clickhouse().to_string(), - ) - }); - Some(ClickhouseAllocator::new( - log.clone(), - parent_config, - inventory.latest_clickhouse_keeper_membership(), - )) - } else { - if parent_blueprint.clickhouse_cluster_config.is_some() { - info!( - log, - concat!( - "clickhouse cluster disabled via policy ", - "discarding existing 'ClickhouseAllocator' and ", - "the resulting generated 'ClickhouseClusterConfig" - ) - ); - } - None - }; - Ok(BlueprintBuilder { log, parent_blueprint, @@ -451,11 +408,10 @@ impl<'a> BlueprintBuilder<'a> { sled_state, cockroachdb_setting_preserve_downgrade: parent_blueprint .cockroachdb_setting_preserve_downgrade, - clickhouse_allocator, creator: creator.to_owned(), operations: Vec::new(), comments: Vec::new(), - rng, + rng: PlannerRng::new(), }) } @@ -536,9 +492,50 @@ impl<'a> BlueprintBuilder<'a> { .datasets .into_datasets_map(self.input.all_sled_ids(SledFilter::InService)); + // If we have the clickhouse cluster setup enabled via policy and we + // don't yet have a `ClickhouseClusterConfiguration`, then we must create + // one and feed it to our `ClickhouseAllocator`. + let clickhouse_allocator = if self.input.clickhouse_cluster_enabled() { + let parent_config = self + .parent_blueprint + .clickhouse_cluster_config + .clone() + .unwrap_or_else(|| { + info!( + self.log, + concat!( + "Clickhouse cluster enabled by policy: ", + "generating initial 'ClickhouseClusterConfig' ", + "and 'ClickhouseAllocator'" + ) + ); + ClickhouseClusterConfig::new( + OXIMETER_CLUSTER.to_string(), + self.rng.next_clickhouse().to_string(), + ) + }); + Some(ClickhouseAllocator::new( + self.log.clone(), + parent_config, + self.collection.latest_clickhouse_keeper_membership(), + )) + } else { + if self.parent_blueprint.clickhouse_cluster_config.is_some() { + info!( + self.log, + concat!( + "clickhouse cluster disabled via policy ", + "discarding existing 'ClickhouseAllocator' and ", + "the resulting generated 'ClickhouseClusterConfig" + ) + ); + } + None + }; + // If we have an allocator, use it to generate a new config. If an error // is returned then log it and carry over the parent_config. - let clickhouse_cluster_config = self.clickhouse_allocator.map(|a| { + let clickhouse_cluster_config = clickhouse_allocator.map(|a| { match a.plan(&(&blueprint_zones).into()) { Ok(config) => config, Err(e) => { diff --git a/nexus/reconfigurator/planning/tests/output/planner_deploy_all_keeper_nodes_1_2.txt b/nexus/reconfigurator/planning/tests/output/planner_deploy_all_keeper_nodes_1_2.txt index 078cad3a4d..19249f1a97 100644 --- a/nexus/reconfigurator/planning/tests/output/planner_deploy_all_keeper_nodes_1_2.txt +++ b/nexus/reconfigurator/planning/tests/output/planner_deploy_all_keeper_nodes_1_2.txt @@ -301,7 +301,7 @@ to: blueprint 31ef2071-2ec9-49d9-8827-fd83b17a0e3d + max used server id::::::::::::::::::::::::::::: 2 + max used keeper id::::::::::::::::::::::::::::: 3 + cluster name::::::::::::::::::::::::::::::::::: oximeter_cluster -+ cluster secret::::::::::::::::::::::::::::::::: 1c3bd4f4-3b2a-45e1-ba9c-8c75bd32462d ++ cluster secret::::::::::::::::::::::::::::::::: 75ba7558-f7cf-431f-bba5-71c8e82fd4c1 + highest seen keeper leader committed log index: 0 clickhouse keepers at generation 2: diff --git a/nexus/reconfigurator/planning/tests/output/planner_deploy_all_keeper_nodes_3_4.txt b/nexus/reconfigurator/planning/tests/output/planner_deploy_all_keeper_nodes_3_4.txt index 357a9ee4cb..4de3686aa3 100644 --- a/nexus/reconfigurator/planning/tests/output/planner_deploy_all_keeper_nodes_3_4.txt +++ b/nexus/reconfigurator/planning/tests/output/planner_deploy_all_keeper_nodes_3_4.txt @@ -301,7 +301,7 @@ to: blueprint 92fa943c-7dd4-48c3-9447-c9d0665744b6 max used server id::::::::::::::::::::::::::::: 2 (unchanged) max used keeper id::::::::::::::::::::::::::::: 3 (unchanged) cluster name::::::::::::::::::::::::::::::::::: oximeter_cluster (unchanged) - cluster secret::::::::::::::::::::::::::::::::: 1c3bd4f4-3b2a-45e1-ba9c-8c75bd32462d (unchanged) + cluster secret::::::::::::::::::::::::::::::::: 75ba7558-f7cf-431f-bba5-71c8e82fd4c1 (unchanged) * highest seen keeper leader committed log index: 0 -> 1 clickhouse keepers at generation 2: diff --git a/nexus/reconfigurator/planning/tests/output/planner_deploy_all_keeper_nodes_4_5.txt b/nexus/reconfigurator/planning/tests/output/planner_deploy_all_keeper_nodes_4_5.txt index da1adc9508..7847524bf2 100644 --- a/nexus/reconfigurator/planning/tests/output/planner_deploy_all_keeper_nodes_4_5.txt +++ b/nexus/reconfigurator/planning/tests/output/planner_deploy_all_keeper_nodes_4_5.txt @@ -309,7 +309,7 @@ to: blueprint 2886dab5-61a2-46b4-87af-bc7aeb44cccb max used server id::::::::::::::::::::::::::::: 2 (unchanged) * max used keeper id::::::::::::::::::::::::::::: 3 -> 4 cluster name::::::::::::::::::::::::::::::::::: oximeter_cluster (unchanged) - cluster secret::::::::::::::::::::::::::::::::: 1c3bd4f4-3b2a-45e1-ba9c-8c75bd32462d (unchanged) + cluster secret::::::::::::::::::::::::::::::::: 75ba7558-f7cf-431f-bba5-71c8e82fd4c1 (unchanged) highest seen keeper leader committed log index: 1 (unchanged) clickhouse keepers generation 2 -> 3: diff --git a/nexus/reconfigurator/planning/tests/output/planner_deploy_all_keeper_nodes_5_6.txt b/nexus/reconfigurator/planning/tests/output/planner_deploy_all_keeper_nodes_5_6.txt index 6f9dbf731e..9f7680ee5d 100644 --- a/nexus/reconfigurator/planning/tests/output/planner_deploy_all_keeper_nodes_5_6.txt +++ b/nexus/reconfigurator/planning/tests/output/planner_deploy_all_keeper_nodes_5_6.txt @@ -307,7 +307,7 @@ to: blueprint cb39be9d-5476-44fa-9edf-9938376219ef max used server id::::::::::::::::::::::::::::: 2 (unchanged) max used keeper id::::::::::::::::::::::::::::: 4 (unchanged) cluster name::::::::::::::::::::::::::::::::::: oximeter_cluster (unchanged) - cluster secret::::::::::::::::::::::::::::::::: 1c3bd4f4-3b2a-45e1-ba9c-8c75bd32462d (unchanged) + cluster secret::::::::::::::::::::::::::::::::: 75ba7558-f7cf-431f-bba5-71c8e82fd4c1 (unchanged) highest seen keeper leader committed log index: 1 (unchanged) clickhouse keepers at generation 3: diff --git a/nexus/reconfigurator/planning/tests/output/planner_expunge_clickhouse_clusters_3_4.txt b/nexus/reconfigurator/planning/tests/output/planner_expunge_clickhouse_clusters_3_4.txt index 123f56fca0..5991124012 100644 --- a/nexus/reconfigurator/planning/tests/output/planner_expunge_clickhouse_clusters_3_4.txt +++ b/nexus/reconfigurator/planning/tests/output/planner_expunge_clickhouse_clusters_3_4.txt @@ -330,7 +330,7 @@ to: blueprint 74f2e7fd-687e-4c9e-b5d8-e474a5bb8e7c max used server id::::::::::::::::::::::::::::: 2 (unchanged) max used keeper id::::::::::::::::::::::::::::: 3 (unchanged) cluster name::::::::::::::::::::::::::::::::::: oximeter_cluster (unchanged) - cluster secret::::::::::::::::::::::::::::::::: 1d73a59c-d623-4d22-8e55-ba9031bdc7d5 (unchanged) + cluster secret::::::::::::::::::::::::::::::::: 9b56c0da-33d7-41a6-b411-6d00e71bea9b (unchanged) highest seen keeper leader committed log index: 1 (unchanged) clickhouse keepers generation 2 -> 3: diff --git a/nexus/reconfigurator/planning/tests/output/planner_expunge_clickhouse_clusters_5_6.txt b/nexus/reconfigurator/planning/tests/output/planner_expunge_clickhouse_clusters_5_6.txt index dfd0c13402..4a8d64fcc6 100644 --- a/nexus/reconfigurator/planning/tests/output/planner_expunge_clickhouse_clusters_5_6.txt +++ b/nexus/reconfigurator/planning/tests/output/planner_expunge_clickhouse_clusters_5_6.txt @@ -243,7 +243,7 @@ to: blueprint df68d4d4-5af4-4b56-95bb-1654a6957d4f max used server id::::::::::::::::::::::::::::: 2 (unchanged) * max used keeper id::::::::::::::::::::::::::::: 3 -> 4 cluster name::::::::::::::::::::::::::::::::::: oximeter_cluster (unchanged) - cluster secret::::::::::::::::::::::::::::::::: 1d73a59c-d623-4d22-8e55-ba9031bdc7d5 (unchanged) + cluster secret::::::::::::::::::::::::::::::::: 9b56c0da-33d7-41a6-b411-6d00e71bea9b (unchanged) * highest seen keeper leader committed log index: 1 -> 3 clickhouse keepers generation 3 -> 4: diff --git a/nexus/reconfigurator/planning/tests/output/planner_expunge_clickhouse_zones_after_policy_is_changed_3_4.txt b/nexus/reconfigurator/planning/tests/output/planner_expunge_clickhouse_zones_after_policy_is_changed_3_4.txt index 112316c675..dfafd0ce39 100644 --- a/nexus/reconfigurator/planning/tests/output/planner_expunge_clickhouse_zones_after_policy_is_changed_3_4.txt +++ b/nexus/reconfigurator/planning/tests/output/planner_expunge_clickhouse_zones_after_policy_is_changed_3_4.txt @@ -309,7 +309,7 @@ to: blueprint d895ef50-9978-454c-bdfb-b8dbe2c9a918 - max used server id::::::::::::::::::::::::::::: 2 - max used keeper id::::::::::::::::::::::::::::: 3 - cluster name::::::::::::::::::::::::::::::::::: oximeter_cluster -- cluster secret::::::::::::::::::::::::::::::::: 3a94d30e-5c49-4000-af93-f0862038097b +- cluster secret::::::::::::::::::::::::::::::::: 7470cfb0-bfbf-49d0-b37b-13747463c865 - highest seen keeper leader committed log index: 0 clickhouse keepers at generation 2: