Commit 35124a3
feat(keeper): Raft-safe ClickHouseKeeperInstallation rescale
Make CHK scale-up/scale-down Raft-safe by replacing the fixed post-create
sleep and the all-at-once XML publish with staged, verified membership changes.
Problem: on rescale the operator published a raft_configuration with every
desired server at once and only waited a fixed 7s, never confirming committed
Raft membership. Two freshly-started Keeper nodes could form a quorum between
themselves while the original node still believed it was the whole cluster — a
split-brain window. Scale-down deleted StatefulSets/PVCs with no barrier
confirming the member had actually left committed membership.
Approach (hardened staged XML; source-verified against Keeper 23.8..master —
versioned `reconfig` CAS does not exist in any version, and the XML-diff mode
is the reliable control plane):
- Publish new members one at a time, each behind a committed-membership barrier
read from the `/keeper/config` znode plus a leader `mntr` synced-followers
barrier. Never more than one not-yet-committed server in the published XML
(split-brain guard). Emit `<start_as_follower>` for members joining an
established cluster.
- Gate CHK `Completed` on committed membership == desired.
- Scale-down: transfer leadership (`rqld`) off departing members, then gate
StatefulSet/PVC purge on confirmed committed removal.
- Lease leader election for the CHK controller manager.
- Fail-safe: any barrier timeout / quorum loss requeues without deleting or
mutating anything.
Also version-gates the `async_replication` / `use_xid_64` coordination settings
(a pre-existing incompatibility that CrashLooped Keeper < 24.12) and fixes a
shared ReconcileAttributes tag setter that was a silent no-op.
Adds a keeper observe client (`pkg/model/chk/keeper`), the controller barriers
(`pkg/controller/chk/worker-raft-membership.go`), and e2e coverage including a
deterministic split-brain demonstration (RED on the pre-fix operator, GREEN on
this branch, across Keeper 23.8/24.8/25.8). Full-rescale support floor is Keeper
24.8 (documented; < 24.3 is safety-covered only). See
docs/chk-rescale-raft-safety-v3.md.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Mikhail Filimonov <mfilimonov@altinity.com>1 parent c0f085f commit 35124a3
37 files changed
Lines changed: 2912 additions & 47 deletions
File tree
- cmd/operator/app
- config/chk/keeper_config.d
- deploy
- builder
- templates-config/chk/keeper_config.d
- templates-install-bundle
- helm/clickhouse-operator/templates/generated
- operator
- docs
- pkg
- apis
- clickhouse.altinity.com/v1
- common/types
- controller
- chk
- common/announcer
- model
- chk
- config
- keeper
- common/config
- tests
- e2e
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| 24 | + | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
| |||
67 | 69 | | |
68 | 70 | | |
69 | 71 | | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
70 | 79 | | |
71 | 80 | | |
72 | 81 | | |
| |||
Lines changed: 10 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
10 | 19 | | |
11 | | - | |
12 | 20 | | |
13 | 21 | | |
14 | 22 | | |
15 | 23 | | |
16 | | - | |
17 | 24 | | |
18 | 25 | | |
19 | 26 | | |
| |||
35 | 42 | | |
36 | 43 | | |
37 | 44 | | |
38 | | - | |
| 45 | + | |
39 | 46 | | |
40 | 47 | | |
41 | 48 | | |
| |||
Lines changed: 10 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
4 | 13 | | |
5 | | - | |
6 | 14 | | |
7 | 15 | | |
8 | 16 | | |
9 | 17 | | |
10 | | - | |
11 | 18 | | |
12 | 19 | | |
13 | 20 | | |
| |||
29 | 36 | | |
30 | 37 | | |
31 | 38 | | |
32 | | - | |
| 39 | + | |
33 | 40 | | |
34 | 41 | | |
35 | 42 | | |
| |||
Lines changed: 17 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
90 | 107 | | |
91 | 108 | | |
92 | 109 | | |
| |||
Lines changed: 13 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
17 | 30 | | |
18 | 31 | | |
19 | 32 | | |
| |||
Lines changed: 13 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
17 | 30 | | |
18 | 31 | | |
19 | 32 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5496 | 5496 | | |
5497 | 5497 | | |
5498 | 5498 | | |
| 5499 | + | |
| 5500 | + | |
| 5501 | + | |
| 5502 | + | |
| 5503 | + | |
| 5504 | + | |
| 5505 | + | |
| 5506 | + | |
| 5507 | + | |
| 5508 | + | |
| 5509 | + | |
| 5510 | + | |
| 5511 | + | |
| 5512 | + | |
| 5513 | + | |
| 5514 | + | |
| 5515 | + | |
5499 | 5516 | | |
5500 | 5517 | | |
5501 | 5518 | | |
| |||
6705 | 6722 | | |
6706 | 6723 | | |
6707 | 6724 | | |
| 6725 | + | |
| 6726 | + | |
| 6727 | + | |
| 6728 | + | |
| 6729 | + | |
| 6730 | + | |
| 6731 | + | |
| 6732 | + | |
| 6733 | + | |
6708 | 6734 | | |
6709 | | - | |
6710 | 6735 | | |
6711 | 6736 | | |
6712 | 6737 | | |
6713 | 6738 | | |
6714 | | - | |
6715 | 6739 | | |
6716 | 6740 | | |
6717 | 6741 | | |
| |||
6733 | 6757 | | |
6734 | 6758 | | |
6735 | 6759 | | |
6736 | | - | |
| 6760 | + | |
6737 | 6761 | | |
6738 | 6762 | | |
6739 | 6763 | | |
| |||
Lines changed: 40 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5365 | 5365 | | |
5366 | 5366 | | |
5367 | 5367 | | |
5368 | | - | |
5369 | 5368 | | |
5370 | 5369 | | |
5371 | 5370 | | |
| |||
5452 | 5451 | | |
5453 | 5452 | | |
5454 | 5453 | | |
| 5454 | + | |
| 5455 | + | |
| 5456 | + | |
| 5457 | + | |
| 5458 | + | |
| 5459 | + | |
| 5460 | + | |
| 5461 | + | |
| 5462 | + | |
| 5463 | + | |
| 5464 | + | |
| 5465 | + | |
| 5466 | + | |
| 5467 | + | |
| 5468 | + | |
5455 | 5469 | | |
5456 | 5470 | | |
5457 | 5471 | | |
| |||
5618 | 5632 | | |
5619 | 5633 | | |
5620 | 5634 | | |
5621 | | - | |
5622 | 5635 | | |
5623 | 5636 | | |
5624 | 5637 | | |
| |||
5705 | 5718 | | |
5706 | 5719 | | |
5707 | 5720 | | |
| 5721 | + | |
| 5722 | + | |
| 5723 | + | |
| 5724 | + | |
| 5725 | + | |
| 5726 | + | |
| 5727 | + | |
| 5728 | + | |
| 5729 | + | |
| 5730 | + | |
| 5731 | + | |
| 5732 | + | |
| 5733 | + | |
| 5734 | + | |
| 5735 | + | |
5708 | 5736 | | |
5709 | 5737 | | |
5710 | 5738 | | |
| |||
6895 | 6923 | | |
6896 | 6924 | | |
6897 | 6925 | | |
| 6926 | + | |
| 6927 | + | |
| 6928 | + | |
| 6929 | + | |
| 6930 | + | |
| 6931 | + | |
| 6932 | + | |
| 6933 | + | |
| 6934 | + | |
6898 | 6935 | | |
6899 | | - | |
6900 | 6936 | | |
6901 | 6937 | | |
6902 | 6938 | | |
6903 | 6939 | | |
6904 | | - | |
6905 | 6940 | | |
6906 | 6941 | | |
6907 | 6942 | | |
| |||
6923 | 6958 | | |
6924 | 6959 | | |
6925 | 6960 | | |
6926 | | - | |
| 6961 | + | |
6927 | 6962 | | |
6928 | 6963 | | |
6929 | 6964 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5489 | 5489 | | |
5490 | 5490 | | |
5491 | 5491 | | |
| 5492 | + | |
| 5493 | + | |
| 5494 | + | |
| 5495 | + | |
| 5496 | + | |
| 5497 | + | |
| 5498 | + | |
| 5499 | + | |
| 5500 | + | |
| 5501 | + | |
| 5502 | + | |
| 5503 | + | |
| 5504 | + | |
| 5505 | + | |
| 5506 | + | |
| 5507 | + | |
| 5508 | + | |
5492 | 5509 | | |
5493 | 5510 | | |
5494 | 5511 | | |
| |||
5755 | 5772 | | |
5756 | 5773 | | |
5757 | 5774 | | |
| 5775 | + | |
| 5776 | + | |
| 5777 | + | |
| 5778 | + | |
| 5779 | + | |
| 5780 | + | |
| 5781 | + | |
| 5782 | + | |
| 5783 | + | |
| 5784 | + | |
| 5785 | + | |
| 5786 | + | |
| 5787 | + | |
| 5788 | + | |
| 5789 | + | |
| 5790 | + | |
| 5791 | + | |
5758 | 5792 | | |
5759 | 5793 | | |
5760 | 5794 | | |
| |||
6964 | 6998 | | |
6965 | 6999 | | |
6966 | 7000 | | |
| 7001 | + | |
| 7002 | + | |
| 7003 | + | |
| 7004 | + | |
| 7005 | + | |
| 7006 | + | |
| 7007 | + | |
| 7008 | + | |
| 7009 | + | |
6967 | 7010 | | |
6968 | | - | |
6969 | 7011 | | |
6970 | 7012 | | |
6971 | 7013 | | |
6972 | 7014 | | |
6973 | | - | |
6974 | 7015 | | |
6975 | 7016 | | |
6976 | 7017 | | |
| |||
6992 | 7033 | | |
6993 | 7034 | | |
6994 | 7035 | | |
6995 | | - | |
| 7036 | + | |
6996 | 7037 | | |
6997 | 7038 | | |
6998 | 7039 | | |
| |||
0 commit comments