From 80590bd0a1abdcd52ea80e7a083bd49eb90775c2 Mon Sep 17 00:00:00 2001 From: "Andrew J. Stone" Date: Thu, 7 Nov 2024 00:19:53 +0000 Subject: [PATCH] wip --- nexus/types/src/deployment/blueprint_diff.rs | 43 +++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/nexus/types/src/deployment/blueprint_diff.rs b/nexus/types/src/deployment/blueprint_diff.rs index 1aa06c0cae4..11416799d1f 100644 --- a/nexus/types/src/deployment/blueprint_diff.rs +++ b/nexus/types/src/deployment/blueprint_diff.rs @@ -1006,7 +1006,48 @@ impl ClickhouseClusterConfigDiffTables { /// The "before" inventory collection or blueprint does not have a relevant /// keeper configuration. pub fn added_to_blueprint(after: &ClickhouseClusterConfig) -> Self { - todo!() + let rows: Vec<_> = [ + (GENERATION, after.generation.to_string()), + ( + CLICKHOUSE_MAX_USED_SERVER_ID, + after.max_used_server_id.to_string(), + ), + ( + CLICKHOUSE_MAX_USED_KEEPER_ID, + after.max_used_keeper_id.to_string(), + ), + (CLICKHOUSE_CLUSTER_NAME, after.cluster_name.clone()), + (CLICKHOUSE_CLUSTER_SECRET, after.cluster_secret.clone()), + ( + CLICKHOUSE_HIGHEST_SEEN_KEEPER_LEADER_COMMITTED_LOG_INDEX, + after + .highest_seen_keeper_leader_committed_log_index + .to_string(), + ), + ] + .into_iter() + .map(|(key, val)| KvPair::new(BpDiffState::Added, key, val)) + .collect(); + + let metadata = + KvListWithHeading::new(CLICKHOUSE_CLUSTER_CONFIG_HEADING, rows); + + let keepers = BpSledSubtable::new( + BpClickhouseKeepersSubtableSchema {}, + BpGeneration::Value(after.generation), + (after.generation, &after.keepers) + .rows(BpDiffState::Added) + .collect(), + ); + let servers = Some(BpSledSubtable::new( + BpClickhouseServersSubtableSchema {}, + BpGeneration::Value(after.generation), + (after.generation, &after.servers) + .rows(BpDiffState::Added) + .collect(), + )); + + ClickhouseClusterConfigDiffTables { metadata, keepers, servers } } /// We are diffing two `Blueprint`s, but The latest bluerprint does not have