fix(operator): Make rollout order deterministic for rolling deploy when multiple StatefulSets share same NodeType#18973
Open
aruraghuwanshi wants to merge 2 commits intoapache:masterfrom
Conversation
Within each node type, specs were appended from map iteration over m.Spec.Nodes, so rollout order was non-deterministic (e.g. historicalst1 vs historicalst2). Sort specs by ServiceGroup.key before appending so rollout order is stable across reconciles.
Contributor
Author
|
@AdheipSingh fyi |
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.
Description
With the default/current code, if there is more than one StatefulSet or Deployment belonging to the same NodeType (e.g.
historicals-hotandhistoricals-cold), the rollout order keeps flapping non-deterministically whenrollingDeployis enabled. Within each node type, specs were appended from map iteration overm.Spec.Nodes, so the order can change between calls and across reconciles (e.g. sometimeshistoricals-hotfirst, sometimeshistoricals-coldfirst).When
getNodeSpecsByOrderis called multiple times during a single rollout, the order returned for specs within the same NodeType can therefore change between calls. That leads to erroneous behavior: multiple StatefulSets/Deployments of that NodeType may undergo rollout at the same time instead of one completing before the next.This change enforces ordering and consistency by sorting specs by
ServiceGroup.keywithin each node type before appending them to the ordered list. Rollout order is now stable and deterministic across reconciles: one StatefulSet/Deployment within the same NodeType is fully rolled out before the operator moves on to the next.Deterministic ordering in
getNodeSpecsByOrderServiceGroup.key(ascending) using Go’ssort.Slicebefore appending to the final ordered list.druidServicesOrder(historical → overlord → middleManager → indexer → broker → coordinator → router). Within each node type, order is now deterministic by node spec key (e.g.historicals-cold,historicals-hot).Release note
Druid Operator: When
rollingDeployis enabled, rollout order for multiple StatefulSets/Deployments of the same NodeType (e.g.historicals-hotandhistoricals-cold) is now deterministic and stable. One such resource is fully rolled out before the next, avoiding concurrent rollouts within the same NodeType.Key changed/added classes in this PR
druid-operator/controllers/druid/ordering.go—getNodeSpecsByOrderdruid-operator/controllers/druid/ordering_determinism_test.go— unit tests for deterministic orderingThis PR has: