8000 fix(chi): deprioritize the host being restarted in remote_servers by Savid · Pull Request #2177 · Altinity/clickhouse-operator · GitHub
[go: up one dir, main page]

Skip to content

fix(chi): deprioritize the host being restarted in remote_servers - #2177

Merged
alex-zaitsev merged 1 commit into
Altinity:0.28.0from
Savid:fix/low-priority-tag-allocation
Dec 1, 2026
Merged

alex-zaitsev merged 1 commit into
Altinity:0.28.0from
Savid:fix/low-priority-tag-allocation

Conversation

@Savid
@Savid Savid commented Nov 27, 2026
Copy link
Copy Markdown

Completes the split asked for in the review of #2087: #2087 (comment) — the CHI-visible half of the tag allocation, with the CHANGELOG line and generator test that review asked for.

The bug

NewReconcileAttributes() leaves tags nil, and Tags.Set has a value receiver on a map type, so it cannot allocate one and returns early when the map is nil. SetLowPriority() stored nothing and IsLowPriority() stayed false, so descendHostInClickHouseCluster rendered the host it was descending without <priority>1000</priority>: the common ConfigMap came out unchanged, peers had nothing to pick up and kept sending Distributed subqueries to the host at normal priority while it went down. This has been the case since the tag was introduced in 0.24.5.

Changes

  • ReconcileAttributes.SetLowPriority allocates tags when nil, in the same form SetExclude uses, and the comment documenting the no-op goes away. This restores the hunk 9731a3785 removed from Stage CHK scale-up so 1→3 does not create all Raft members at once #2087.
  • TestGetRemoteServersLowPriority in pkg/model/chi/config renders remote_servers through the generator, marks one host of a two-replica shard low priority, and renders again. It asserts that the marked host's <replica> carries <priority>1000</priority> in every cluster it appears in, that its peer does not, and that UnsetLowPriority restores the earlier output.
  • CHANGELOG entry under Fixed.

Allocating in the setter rather than in the constructor is deliberate: getRaftGeneratorOptions builds (&types.ReconcileAttributes{}).SetExclude() (pkg/controller/chk/worker.go:515), which a constructor-level fix would not cover.

#2041 carries the same allocation for both setters and is approved, but it is not planned for merge, so the fix does not arrive that way.

What this does not fix

The element only reaches peers once the kubelet rewrites the mounted ConfigMap and ClickHouse reloads it. The operator waits reconcile.configMapPropagationTimeout for that. It defaults to 10s, and only when the CR carries neither spec.reconcile nor spec.reconciling — with either key present but the field unset the value is 0 and there is no wait at all. kubelet propagation can take longer than 10s, so on some clusters the host will still go down before its peers see the change. Choosing a timeout is per-installation, so it is left out of this PR.

Worth stating too: now that the element renders, the descend and ascend around each host restart both change the common ConfigMap, so a rolling restart writes it twice per host and every pod of the installation reloads its config twice per host. That is what the descend was written to do, but it is new behaviour for anyone upgrading.

Checks

  • go test -vet=off -race -count=1 ./pkg/... passes; gofmt clean on the touched files.
  • The generator test fails without the change — both renders are identical.
  • No e2e run. The remote_servers assertions in tests/e2e/test_operator.py count <shard> and <replica> inside the cluster block and do not look at block contents, so the added element does not move them.
  • All commits in the PR are squashed.
  • The PR is made into dedicated next-release branch, not into master branch.
  • The PR is signed.

NewReconcileAttributes() leaves the tag map nil, and Tags.Set has a value
receiver on a map type, so it cannot allocate one and returns early when
the map is nil. SetLowPriority() stored nothing and IsLowPriority() stayed
false, so descendHostInClickHouseCluster rendered the descending host's
<replica> entry without <priority>1000</priority>. The common ConfigMap
was rendered unchanged, so peers had nothing to pick up and kept sending
Distributed subqueries to the host at normal priority while it went down.

Altinity#2087 carried both halves of this allocation. Its review asked for the
CHI-visible half to be split out with a CHANGELOG line and a generator
test, and it was reverted to a documented no-op. This change is that
split: SetLowPriority allocates the map in the same form SetExclude does.
Allocating in the setter rather than in the constructor also keeps
(&types.ReconcileAttributes{}).SetExclude() in getRaftGeneratorOptions
working, which a constructor-level fix would miss.

The generator test renders remote_servers through the real generator and
asserts that a host marked low priority carries <priority>1000</priority>
in every cluster it belongs to, that its peer does not, and that
unsetting the mark restores the previous output. It fails without the
allocation, where both renders are identical.

Signed-off-by: Andrew Davis <1709934+Savid@users.noreply.github.com>
@Savid
Savid force-pushed the fix/low-priority-tag-allocation branch from 533079d to 2cae27e Compare November 27, 2026 13:28
@alex-zaitsev
alex-zaitsev self-requested a review December 1, 2026 05:45
@alex-zaitsev
alex-zaitsev merged commit 7119079 into Altinity:0.28.0 Dec 1, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0