Repository navigation
[Feature] Support adding an observer role in FE to improve query load balancing and scale read workloads - #734
zhaohehuhu wants to merge 22 commits into
Conversation
Signed-off-by: zhaohehuhu <luoyedeyi@163.com>
|
@yandongxiao @kevincai plz help review |
There was a problem hiding this comment.
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
ObserverNumberfield toStarRocksFeSpecAPI 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
observerNumberfield - 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.
|
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>
|
This is much needed, thank you! |
I still need some time to test this feature. Thanks! |
Signed-off-by: zhaohehuhu <luoyedeyi@163.com>
Signed-off-by: zhaohehuhu <luoyedeyi@163.com>
|
@kevincai @yandongxiao plz help review. Thanks! |
|
Related issue #767 |
|
@yandongxiao any update, please? |
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>
|
@codex review |
There was a problem hiding this comment.
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 injectsFE_SERVICE_NAMEfor*StarRocksFeObserverSpec(seepkg/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
validateObserverImageVersioncurrently usespod.IsLowerThanAny(imageVersion, []string{"4.1.0"})and treats any error as “unsupported”.IsLowerThanAnyerrors 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 like4.0-latest. The validation should do a real "at least" comparison againstminFeObserverImageVersion.
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
|
@codex review |
|
@yandongxiao @kevincai Any updates please? My team is keenly awaiting this change |
There was a problem hiding this comment.
🟡 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
Getonly handlesNotFound; any other API error is ignored and reconciliation continues with an emptyst, 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
| Name: v1.IS_FE_OBSERVER, | ||
| Value: "true", |
| 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) |
| 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>
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:
make generateto generate the code.golangci-lint runto check the code style.make testto run UT.make manifeststo update the yaml files of CRD.For helm chart, please complete the following checklist:
file of starrocks chart.
scriptsdirectory, runbash create-parent-chart-values.shto update the values.yaml file of the parentchart( kube-starrocks chart).