feat: add support for dynamic KRaft quorum scaling - #1010
Conversation
Controllers now run a quorum-manager sidecar that admits itself into the KRaft voter set on startup (add-controller) and removes itself before termination (remove-controller via preStop), so controller role groups can be scaled up/down on a running cluster without a full rolling restart. controller.quorum.bootstrap.servers now points at each controller role group's headless Service DNS name instead of individual pod addresses, keeping container commands stable across replica changes. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Controllers get a startupProbe (plain TCP, generous failure threshold for slow metadata-log replay on boot), a plain-TCP livenessProbe, and a readinessProbe that checks the node's Raft state via its metrics endpoint instead of a bare TCP check, so a controller stuck rejoining the quorum is correctly reported as not ready. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Controller pods now start/scale sequentially (OrderedReady) instead of in parallel, since the quorum-manager sidecar's admission flow assumes one voter joins at a time. Brokers are unaffected and keep Parallel. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Scaling controllers to 0 replicas while brokers keep running is now rejected at validation time with an actionable error, instead of failing much later and confusingly while building the broker's ConfigMap. Scaling controllers and brokers to 0 together (a coordinated whole-cluster stop) is still allowed and now actually builds, since downstream resource builders no longer assume a non-empty controller quorum whenever KRaft mode is active. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…ns tests Enable the previously version-gated scale-up/down steps (Kafka 3.7 no longer needs special-casing), assert quorum voter counts via kafka-metadata-quorum.sh after each scale, and add a final step scaling both controllers and brokers to 0 to exercise the whole-cluster-stop path before namespace teardown. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Update the KRaft controller usage guide for scale-up/down support, record the design spec and implementation plan, add the CHANGELOG entries for this branch's changes, and ignore .worktrees/ for local worktree checkouts. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
The failed test was due to namespace deletion timeout |
maltesander
left a comment
There was a problem hiding this comment.
This is not quite stable yet. Also, alot of AI slur in the code comments etc. that can be skimmed down.
| describe=$(timeout --kill-after={cli_kill_after} {cli_timeout} {binary} --bootstrap-controller "$BOOTSTRAP_SERVERS" --command-config {config} describe --replication 2>/dev/null) | ||
| if [ -n "$describe" ]; then | ||
| voters=$(echo "$describe" | tail -n +2 | awk '$NF == "Leader" || $NF == "Follower"') | ||
| total_voters=$(echo "$voters" | grep -c .) |
There was a problem hiding this comment.
This works for scaling operations, not for namespace deletion or node drainages? Meaning when all prestop hooks run at "the same time" they all read the same $voters and all issue remove-controller? The voter set drains to zero and we reformat at restart? That is also the reason for 90-stop-kafka.yaml.j2 ? Meaning scaledown / stop cluster before namespace deletion.
There was a problem hiding this comment.
This works for scaling operations, not for namespace deletion or node drainages?
It works for all graceful operations except hard node failures.
Meaning when all prestop hooks run at "the same time" they all read the same $voters and all issue remove-controller?
The maxUnavailable: 1 of the controller PDB and the OrderedReady scaling strategy ensure scaling up/down is done one controller at a time.
The voter set drains to zero and we reformat at restart?
I'm preparing documentation for handling the case there the controllers lose the PVC. In that case, manual intervention is necessary to avoid a split-brain or just faulty quorum.
I will post a separate comment.
That is also the reason for 90-stop-kafka.yaml.j2 ? Meaning scaledown / stop cluster before namespace deletion.
No. The reason for 90-stop-kafka.yaml.j2 is to remove the cluster deletion time quota from the namespace termination budget. This is the strategy we wanted for all tests in all ops but that is postponed due to better testing tools comming.
There was a problem hiding this comment.
This adds troubleshooting docs for the case where a controller loses it's PVC.
In addition, it extracts the quorum command into a separate script. A new controller is now added to the quorum only if the quorum is healthy and the new controller is not crash-lopping.
There was a problem hiding this comment.
Cant we fix the script rather than add the troubleshoot guide?
There was a problem hiding this comment.
The troubleshooting guide is for incidents that can happen and that cannot be handled by the operator. Not sure what should be fixed here.
Co-authored-by: maltesander <malte.sander.it@gmail.com>
Co-authored-by: maltesander <malte.sander.it@gmail.com>
…ommand into separate script
# Conflicts: # rust/operator-binary/src/controller/build/kerberos.rs # rust/operator-binary/src/controller/build/resource/statefulset.rs # rust/operator-binary/src/controller/build/security.rs
maltesander
left a comment
There was a problem hiding this comment.
This needs a full resweep for -- in any docs and code or script comments / headers (not the CLI flag, the em/en dash usage).
| @@ -0,0 +1,95 @@ | |||
| #!/usr/bin/env bash | |||
There was a problem hiding this comment.
I think this should go into a dedicated script folder? (same for the other script)
| @@ -0,0 +1,95 @@ | |||
| #!/usr/bin/env bash | |||
| # The `preStop` hook of a KRaft controller pod's `kafka` container: remove this pod from the | |||
| # KRaft voter set before it terminates -- unless that would remove the *last* voter. | |||
There was a problem hiding this comment.
The -- is a new kind of dash and appears alot, could be rewritten properly? (same for the other script)
Description
Fixes #1009
See CHANGELOG for a high level view of everything that changed.
✅ : OKD integration tests work. I ran them many times but there was always one or two tests that failed due to flakiness. I added some cleanup steps so that
kuttldoesn't timeout during namespace cleanups.Definition of Done Checklist
Author
Reviewer
Acceptance
type/deprecationlabel & add to the deprecation scheduletype/experimentallabel & add to the experimental features tracker