Skip to content

[Feature] Leader-aware FE upgrade behind --enable-fe-leader-aware-upgrade - #811

Open
AdheipSingh wants to merge 2 commits into
StarRocks:mainfrom
deep-bi:upstream/fe-leader-aware-upgrade
Open

AdheipSingh wants to merge 2 commits into
StarRocks:mainfrom
deep-bi:upstream/fe-leader-aware-upgrade

Conversation

@AdheipSingh

Copy link
Copy Markdown
Contributor

Description

With the default RollingUpdate strategy the StatefulSet controller replaces FE pods from the highest ordinal down and knows nothing about BDBJE roles. If the leader is not the lowest ordinal, the election its restart triggers can hand leadership to a pod that is replaced a moment later, so one upgrade causes two leader failovers.

This PR adds an opt-in, operator-ordered FE rollout behind --enable-fe-leader-aware-upgrade (Helm: starrocksOperator.enableFeLeaderAwareUpgrade). It is off by default and leaves existing behaviour unchanged.

When enabled:

  • The FE StatefulSet is switched to the OnDelete update strategy.
  • On every reconcile the operator finds the FE pods still on the old revision, runs SHOW FRONTENDS through the FE service, and deletes exactly one pod: followers first (highest ordinal first), the leader last.
  • The leader is re-read on every pass, so a leadership change mid-rollout still leaves the then-current leader for the end.
  • Nothing is deleted when SHOW FRONTENDS fails, any FE is not alive, or no single leader is reported.

Also in this PR:

  • statefulset.Status and fe.CheckFEFullyRolledOut understand OnDelete, where the StatefulSet controller never advances CurrentRevision, by counting pods on the update revision instead.
  • A StatefulSet created by an older operator has no last-applied annotation, so an explicit merge patch converts it to OnDelete first.
  • The MySQL SSL-mode helpers move to pkg/common/mysqlutil so the FE controller can share them with the CN controller; the cn package keeps its names as aliases.
  • RBAC gains the delete verb on pods (kubebuilder marker, config/rbac, Helm clusterrole/role, deploy/operator.yaml).
  • doc/fe_leader_aware_upgrade_howto.md describes the behaviour and how to turn it on.
  • A not-yet-cached FE StatefulSet is tolerated during the leader-aware upgrade.

Checklist

For operator, please complete the following checklist:

  • run make generate to generate the code.
  • run make lint to check the code style.
  • run make test to run UT.
  • run make manifests to update the yaml files of CRD.

For helm chart, please complete the following checklist:

  • make sure you have updated the values.yaml file of operator chart.
  • In scripts directory, run bash create-parent-chart-values.sh to update the values.yaml file of the parent chart (kube-starrocks chart).

…rade

With the default RollingUpdate strategy the StatefulSet controller replaces FE
pods from the highest ordinal down and knows nothing about BDBJE roles. If the
leader is not the lowest ordinal, the election its restart triggers can hand
leadership to a pod that is replaced a moment later, so one upgrade causes two
leader failovers.

When the operator runs with --enable-fe-leader-aware-upgrade=true (Helm:
starrocksOperator.enableFeLeaderAwareUpgrade), the FE StatefulSet is forced to
the OnDelete strategy and the operator orders the rollout itself: on every
reconcile it finds the FE pods still on the old revision, runs SHOW FRONTENDS
through the FE service, and deletes exactly one pod, followers first (highest
ordinal first) and the leader last. The leader is re-read on every pass, so a
leadership change mid-rollout still leaves the then-current leader for the end.
Nothing is deleted when SHOW FRONTENDS fails, any FE is not alive, or no single
leader is reported. The flag is off by default and leaves behaviour unchanged.

Also:
- statefulset.Status and fe.CheckFEFullyRolledOut understand OnDelete, where
  the StatefulSet controller never advances CurrentRevision, by counting pods on
  the update revision instead. Previously an OnDelete FE StatefulSet made the
  status update fail on every reconcile.
- A StatefulSet created by an older operator has no last-applied annotation, so
  the three-way merge cannot clear rollingUpdate; an explicit merge patch
  converts it to OnDelete first.
- The MySQL SSL-mode helpers move to pkg/common/mysqlutil so the FE controller
  can share them with the CN controller without an import cycle; the cn package
  keeps its names as aliases.
- RBAC gains the delete verb on pods (kubebuilder marker, config/rbac, Helm
  clusterrole/role, deploy/operator.yaml).
- doc/fe_leader_aware_upgrade_howto.md describes the behaviour and how to turn
  it on.

Signed-off-by: adheip <adheip@deep.bi>
…grade

Right after ApplyStatefulSet creates the StatefulSet, the cached client can
still report NotFound. The kind run showed this as a spurious SyncFeFailed
warning on the first reconcile. The StatefulSet watch retriggers the reconcile
once the cache catches up, so NotFound is now treated as nothing to do yet.

Signed-off-by: adheip <adheip@deep.bi>
@mergify

mergify Bot commented Nov 13, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue). If it does not match the queue conditions yet, it enters the queue once it does.

  • Queue this pull request

This branch has not been deployed

No deployments
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.

1 participant