Repository navigation
fix(chi): deprioritize the host being restarted in remote_servers - #2177
Merged
alex-zaitsev merged 1 commit intoDec 1, 2026
Merged
Conversation
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
force-pushed
the
fix/low-priority-tag-allocation
branch
from
November 27, 2026 13:28
533079d to
2cae27e
Compare
alex-zaitsev
self-requested a review
December 1, 2026 05:45
alex-zaitsev
approved these changes
Dec 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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()leavestagsnil, andTags.Sethas a value receiver on a map type, so it cannot allocate one and returns early when the map is nil.SetLowPriority()stored nothing andIsLowPriority()stayed false, sodescendHostInClickHouseClusterrendered 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.SetLowPriorityallocatestagswhen nil, in the same formSetExcludeuses, and the comment documenting the no-op goes away. This restores the hunk9731a3785removed from Stage CHK scale-up so 1→3 does not create all Raft members at once #2087.TestGetRemoteServersLowPriorityinpkg/model/chi/configrendersremote_serversthrough 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 thatUnsetLowPriorityrestores the earlier output.Fixed.Allocating in the setter rather than in the constructor is deliberate:
getRaftGeneratorOptionsbuilds(&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.configMapPropagationTimeoutfor that. It defaults to 10s, and only when the CR carries neitherspec.reconcilenorspec.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;gofmtclean on the touched files.remote_serversassertions intests/e2e/test_operator.pycount<shard>and<replica>inside the cluster block and do not look at block contents, so the added element does not move them.next-releasebranch, not intomasterbranch.