Skip to content

Commit 090c778

Browse files
authored
Limit blueprint changes due to clickhouse (#9100)
Do not create a new blueprint if only the clickhouse cluster keeper log index changes. Fixes #9098
1 parent 3d2f118 commit 090c778

File tree

4 files changed

+33
-16
lines changed

4 files changed

+33
-16
lines changed

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

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -147,17 +147,8 @@ impl ClickhouseAllocator {
147147
return bump_gen_if_necessary(new_config);
148148
};
149149

150-
// Save the log index for next time if it's been incremented
151-
let inventory_updated = if inventory_membership
152-
.leader_committed_log_index
153-
> self.parent_config.highest_seen_keeper_leader_committed_log_index
154-
{
155-
new_config.highest_seen_keeper_leader_committed_log_index =
156-
inventory_membership.leader_committed_log_index;
157-
true
158-
} else {
159-
false
160-
};
150+
let inventory_updated = inventory_membership.leader_committed_log_index
151+
> self.parent_config.highest_seen_keeper_leader_committed_log_index;
161152

162153
if current_keepers != inventory_membership.raft_config {
163154
// We know that there is a reconfiguration in progress. If there has
@@ -167,6 +158,12 @@ impl ClickhouseAllocator {
167158
return bump_gen_if_necessary(new_config);
168159
}
169160

161+
// Save the log index from inventory because we are going to
162+
// need to use it to see if inventory has changed next time
163+
// through the planner.
164+
new_config.highest_seen_keeper_leader_committed_log_index =
165+
inventory_membership.leader_committed_log_index;
166+
170167
// We're still trying to reach our desired state. We want to ensure,
171168
// however, that if we are currently trying to add a node, that we
172169
// have not expunged the zone of the keeper that we are trying to
@@ -247,18 +244,36 @@ impl ClickhouseAllocator {
247244
// Remove the keeper for the first expunged zone we see.
248245
// Remember, we only do one keeper membership change at time.
249246
new_config.keepers.remove(zone_id);
247+
248+
if inventory_updated {
249+
// Save the log index from inventory because we are going to
250+
// need to use it to see if inventory has changed next time
251+
// through the planner.
252+
new_config.highest_seen_keeper_leader_committed_log_index =
253+
inventory_membership.leader_committed_log_index;
254+
}
255+
250256
return bump_gen_if_necessary(new_config);
251257
}
252258
}
253259

254-
// Do we need to add any nodes to in service zones that don't have them
260+
// Do we need to add any nodes to in-service zones that don't have them
255261
for zone_id in &active_clickhouse_zones.keepers {
256262
if !new_config.keepers.contains_key(zone_id) {
257263
// Allocate a new `KeeperId` and map it to the keeper zone
258264
new_config.max_used_keeper_id += 1.into();
259265
new_config
260266
.keepers
261267
.insert(*zone_id, new_config.max_used_keeper_id);
268+
269+
if inventory_updated {
270+
// Save the log index from inventory because we are going to
271+
// need to use it to see if inventory has changed next time
272+
// through the planner.
273+
new_config.highest_seen_keeper_leader_committed_log_index =
274+
inventory_membership.leader_committed_log_index;
275+
}
276+
262277
return bump_gen_if_necessary(new_config);
263278
}
264279
}

nexus/reconfigurator/planning/src/planner.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5224,9 +5224,10 @@ pub(crate) mod test {
52245224
);
52255225
assert_eq!(bp4_config.keepers, bp3_config.keepers);
52265226
assert_eq!(bp4_config.servers, bp3_config.servers);
5227+
// The blueprint shouldn't update solely because the log index changed
52275228
assert_eq!(
52285229
bp4_config.highest_seen_keeper_leader_committed_log_index,
5229-
1
5230+
0
52305231
);
52315232

52325233
// Let's bump the clickhouse target to 5 via policy so that we can add
@@ -5388,9 +5389,10 @@ pub(crate) mod test {
53885389
);
53895390
assert_eq!(bp8_config.keepers, bp7_config.keepers);
53905391
assert_eq!(bp7_config.keepers.len(), target_keepers as usize);
5392+
// The blueprint should not change solely due to the log index in inventory changing
53915393
assert_eq!(
53925394
bp8_config.highest_seen_keeper_leader_committed_log_index,
5393-
3
5395+
2
53945396
);
53955397

53965398
logctx.cleanup_successful();

nexus/reconfigurator/planning/tests/output/planner_deploy_all_keeper_nodes_3_4.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ to: blueprint 92fa943c-7dd4-48c3-9447-c9d0665744b6
2121
max used keeper id::::::::::::::::::::::::::::: 3 (unchanged)
2222
cluster name::::::::::::::::::::::::::::::::::: oximeter_cluster (unchanged)
2323
cluster secret::::::::::::::::::::::::::::::::: 6a984e2e-20be-4ed9-b572-d7ef063c67f7 (unchanged)
24-
* highest seen keeper leader committed log index: 0 -> 1
24+
highest seen keeper leader committed log index: 0 (unchanged)
2525

2626
clickhouse keepers at generation 2:
2727
------------------------------------------------

nexus/reconfigurator/planning/tests/output/planner_deploy_all_keeper_nodes_4_5.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ to: blueprint 2886dab5-61a2-46b4-87af-bc7aeb44cccb
235235
* max used keeper id::::::::::::::::::::::::::::: 3 -> 4
236236
cluster name::::::::::::::::::::::::::::::::::: oximeter_cluster (unchanged)
237237
cluster secret::::::::::::::::::::::::::::::::: 6a984e2e-20be-4ed9-b572-d7ef063c67f7 (unchanged)
238-
highest seen keeper leader committed log index: 1 (unchanged)
238+
* highest seen keeper leader committed log index: 0 -> 1
239239

240240
clickhouse keepers generation 2 -> 3:
241241
------------------------------------------------

0 commit comments

Comments
 (0)