Skip to content

[Feature] Support adding an observer role in FE to improve query load balancing and scale read workloads - #734

Open
zhaohehuhu wants to merge 22 commits into
StarRocks:mainfrom
zhaohehuhu:dev-0106
Open

zhaohehuhu wants to merge 22 commits into
StarRocks:mainfrom
zhaohehuhu:dev-0106

Conversation

@zhaohehuhu

@zhaohehuhu zhaohehuhu commented Jan 6, 2026 •

Copy link
Copy Markdown
Contributor

Description

Support adding a read-only observer role in FE via the K8s Operator to scale read capacity and improve query load balancing.

associated with this PR(StarRocks/starrocks#67778)

Related Issue(s)

No.

Checklist

For operator, please complete the following checklist:

  • run make generate to generate the code.
  • run golangci-lint run 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 starrocks chart.
  • In scripts directory, run bash create-parent-chart-values.sh to update the values.yaml file of the parent
    chart( kube-starrocks chart).

Signed-off-by: zhaohehuhu <luoyedeyi@163.com>
@zhaohehuhu zhaohehuhu changed the title Support adding observer role Support adding observer role in FE Jan 6, 2026
@zhaohehuhu zhaohehuhu changed the title Support adding observer role in FE Support adding an Observer role in FE via the Operator Jan 6, 2026
Signed-off-by: zhaohehuhu <luoyedeyi@163.com>
@zhaohehuhu

zhaohehuhu commented Jan 7, 2026 •

Copy link
Copy Markdown
Contributor Author

@yandongxiao @kevincai plz help review

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds support for an Observer role in FE (Frontend) via the Kubernetes Operator to scale read capacity and improve query load balancing. The Observer role is implemented as a configurable field that can be set to specify the number of observer nodes.

Key changes:

  • Added ObserverNumber field to StarRocksFeSpec API with a getter method that defaults to 0
  • Exposed observer number as an environment variable (OBSERVER_NUMBER) to FE pods
  • Updated CRD schemas to include the new observerNumber field
  • Updated Helm chart values.yaml files with commented examples for the new configuration option

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
pkg/apis/starrocks/v1/starrockscluster_types.go Adds ObserverNumber field to StarRocksFeSpec and implements GetObserverNumber() method with default value of 0
pkg/apis/starrocks/v1/zz_generated.deepcopy.go Auto-generated deep copy implementation for the new ObserverNumber pointer field
pkg/apis/starrocks/v1/labels.go Adds OBSERVER_NUMBER constant for the environment variable name
pkg/apis/starrocks/v1/load_type.go Minor whitespace cleanup (removed blank lines)
pkg/k8sutils/templates/pod/spec.go Updates Envs function to set OBSERVER_NUMBER environment variable for FE pods using the new field
pkg/k8sutils/templates/pod/spec_test.go Adds test coverage for the OBSERVER_NUMBER environment variable in FE spec
config/crd/bases/starrocks.com_starrocksclusters.yaml Adds observerNumber field definition to the CRD schema
deploy/starrocks.com_starrocksclusters.yaml Adds observerNumber field definition to the deployed CRD schema
helm-charts/charts/kube-starrocks/charts/starrocks/values.yaml Adds commented example for observerNumber configuration
helm-charts/charts/kube-starrocks/values.yaml Adds commented example for observerNumber configuration in parent chart

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@kevincai

kevincai commented Jan 8, 2026

Copy link
Copy Markdown
Collaborator

don't try to use FE_OBSERVER_NUMBER to hack the current fe_entry_point.sh

It is so dangerous that a single improper env var update can ruin the entire cluster.

@zhaohehuhu

Copy link
Copy Markdown
Contributor Author

don't try to use FE_OBSERVER_NUMBER to hack the current fe_entry_point.sh

It is so dangerous that a single improper env var update can ruin the entire cluster.

Got it. In that case, we may need to add a new FE observer component.

Signed-off-by: zhaohehuhu <luoyedeyi@163.com>
Signed-off-by: zhaohehuhu <luoyedeyi@163.com>
@zhaohehuhu zhaohehuhu changed the title Support adding an Observer role in FE via the Operator Support adding an Observer role in FE to improve query load balancing Jan 12, 2026
@zhaohehuhu zhaohehuhu changed the title Support adding an Observer role in FE to improve query load balancing Support adding an Observer role in FE to improve query load balancing and scale read workloads Jan 12, 2026
Signed-off-by: zhaohehuhu <luoyedeyi@163.com>
Signed-off-by: zhaohehuhu <luoyedeyi@163.com>
@kyle-goodale-klaviyo

Copy link
Copy Markdown

This is much needed, thank you!

@zhaohehuhu

Copy link
Copy Markdown
Contributor Author

This is much needed, thank you!

I still need some time to test this feature. Thanks!

@zhaohehuhu zhaohehuhu changed the title Support adding an Observer role in FE to improve query load balancing and scale read workloads [Feature] Support adding an Observer role in FE to improve query load balancing and scale read workloads Jan 14, 2026
@zhaohehuhu zhaohehuhu changed the title [Feature] Support adding an Observer role in FE to improve query load balancing and scale read workloads [Feature] Support adding an observer role in FE to improve query load balancing and scale read workloads Feb 12, 2026
Signed-off-by: zhaohehuhu <luoyedeyi@163.com>
Signed-off-by: zhaohehuhu <luoyedeyi@163.com>
@zhaohehuhu

Copy link
Copy Markdown
Contributor Author

@kevincai @yandongxiao plz help review. Thanks!

Signed-off-by: zhaohehuhu <luoyedeyi@163.com>
kevincai
kevincai previously approved these changes Jul 8, 2026
@digitalpoetry

Copy link
Copy Markdown
Contributor

Related issue #767

@digitalpoetry

Copy link
Copy Markdown
Contributor

@yandongxiao any update, please?

Comment thread pkg/k8sutils/templates/service/spec.go Resolved
Signed-off-by: zhaohehuhu <luoyedeyi@163.com>
Signed-off-by: zhaohehuhu <luoyedeyi@163.com>

fix UTs

Signed-off-by: zhaohehuhu <luoyedeyi@163.com>

return nil if observer not found

Signed-off-by: zhaohehuhu <luoyedeyi@163.com>

unified external service for fe and observer

Signed-off-by: zhaohehuhu <luoyedeyi@163.com>

unified external serice for fe and observer

Signed-off-by: zhaohehuhu <luoyedeyi@163.com>
@kevincai

Copy link
Copy Markdown
Collaborator

@codex review

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 23 out of 24 changed files in this pull request and generated no new comments.

Files not reviewed (1)
  • pkg/apis/starrocks/v1/zz_generated.deepcopy.go: Generated file
Suppressed comments (2)

pkg/subcontrollers/feobserver/feobserver_pod.go:67

  • pod.Envs() already injects FE_SERVICE_NAME for *StarRocksFeObserverSpec (see pkg/k8sutils/templates/pod/spec.go). Appending it again here creates duplicate env var entries in the container spec, which is easy to miss and can lead to ambiguous behavior if the values ever diverge.
	feServiceName := service.ExternalServiceName(src.Name, src.Spec.StarRocksFeSpec)
	envs := pod.Envs(observerSpec, config, feServiceName, src.Namespace, observerSpec.FeEnvVars)
	envs = append(envs, corev1.EnvVar{
		Name:  srapi.FE_SERVICE_NAME,
		Value: feServiceName,
	})

pkg/subcontrollers/feobserver/feobserver_controller.go:227

  • validateObserverImageVersion currently uses pod.IsLowerThanAny(imageVersion, []string{"4.1.0"}) and treats any error as “unsupported”. IsLowerThanAny errors when the image minor version differs from the target (e.g. 4.2.0), so this will incorrectly reject newer FE versions while also allowing tags like 4.0-latest. The validation should do a real "at least" comparison against minFeObserverImageVersion.
func validateObserverImageVersion(image string) error {
	imageVersion := pod.GetImageVersion(image)
	_, err := pod.IsLowerThanAny(imageVersion, []string{"4.1.0"})
	if err != nil {
		return fmt.Errorf("fe observer requires StarRocks FE image version >= %s "+
			"Current image version %s does not enable FE observer", minFeObserverImageVersion, imageVersion)
	}
	return nil

@kevincai

Copy link
Copy Markdown
Collaborator

@codex review

@digitalpoetry

Copy link
Copy Markdown
Contributor

@yandongxiao @kevincai Any updates please? My team is keenly awaiting this change

@kevincai
kevincai requested a lite review from Copilot September 17, 2026 01:35
kevincai
kevincai previously approved these changes Sep 17, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved critical and moderate findings affect observer deployment, service availability, version support, and reconciliation error handling.

Get a fresh assessment by requesting another Copilot review.

Review details

Files not reviewed (1)

  • pkg/apis/starrocks/v1/zz_generated.deepcopy.go: Generated file

Suppressed comments (2)

pkg/k8sutils/templates/pod/spec.go:176

  • The observer-mode behavior depends on IS_FE_OBSERVER=true; without it, the StarRocks entrypoint registers this pod as a follower. The new tests verify the image, ports, and args but never assert this environment variable, so a regression here would make the feature silently add followers instead of observers. Add an observer pod-template/Envs assertion for the generated value.
				Name:  v1.IS_FE_OBSERVER,
				Value: "true",

pkg/subcontrollers/feobserver/feobserver_controller.go:168

  • This Get only handles NotFound; any other API error is ignored and reconciliation continues with an empty st, after which the controller can report/update observer status as if the StatefulSet were readable. Return non-NotFound errors here, as the other component status controllers do.
	if err := fc.Client.Get(ctx, types.NamespacedName{Namespace: src.Namespace, Name: statefulSetName}, &st); apierrors.IsNotFound(err) {
		logger.Info("fe observer statefulset is not found")
		return nil
	}
  • Files reviewed: 23/24 changed files
  • Comments generated: 4
  • Review effort level: Lite

Comment on lines +175 to +176
Name: v1.IS_FE_OBSERVER,
Value: "true",
Comment thread pkg/subcontrollers/fe/fe_controller.go Outdated
svc := rutils.BuildExternalService(object, feSpec, feConfig, load.Selector(src.Name, feSpec), defaultLabels)
searchServiceName := service.SearchServiceName(src.Name, feSpec)
internalService := service.MakeSearchService(searchServiceName, &svc, []corev1.ServicePort{
svc := rutils.BuildExternalService(object, feSpec, feConfig, load.FeServiceSelector(src.Name), defaultLabels)
Comment on lines +63 to +66
envs = append(envs, corev1.EnvVar{
Name: srapi.FE_SERVICE_NAME,
Value: feServiceName,
})

func validateObserverImageVersion(image string) error {
imageVersion := pod.GetImageVersion(image)
_, err := pod.IsLowerThanAny(imageVersion, []string{"4.1.0"})
Signed-off-by: zhaohehuhu <luoyedeyi@163.com>
Signed-off-by: zhaohehuhu <luoyedeyi@163.com>
Signed-off-by: zhaohehuhu <luoyedeyi@163.com>
Signed-off-by: zhaohehuhu <luoyedeyi@163.com>
Signed-off-by: zhaohehuhu <luoyedeyi@163.com>
Signed-off-by: zhaohehuhu <luoyedeyi@163.com>
Signed-off-by: zhaohehuhu <luoyedeyi@163.com>
Signed-off-by: zhaohehuhu <luoyedeyi@163.com>
@zhaohehuhu
zhaohehuhu requested a review from kevincai October 28, 2026 09:05

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.

8 participants