You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG]CnController.ClearCluster — misleading placeholder variable looks like an inverted-condition bug #765
In pkg/subcontrollers/cn/cn_controller.go, the function (*CnController).ClearCluster contains code that looks like a logic bug at first glance — it appears the early-return condition is inverted, causing every later use of cnSpec to operate on a guaranteed-nil pointer:
// ClearResources clear the deployed resource about cn. statefulset, services, hpa.func (cc*CnController) ClearCluster(ctx context.Context, src*srapi.StarRocksCluster) error {
logger:=logr.FromContextOrDiscard(ctx)
ifsrc.Spec.StarRocksCnSpec!=nil {
returnnil
}
cnSpec:=src.Spec.StarRocksCnSpec// <-- always nil at this pointstatefulSetName:=load.Name(src.Name, cnSpec)
err:=k8sutils.DeleteStatefulset(ctx, cc.k8sClient, src.Namespace, statefulSetName)
...searchServiceName:=service.SearchServiceName(src.Name, cnSpec)
externalServiceName:=service.ExternalServiceName(src.Name, cnSpec)
...
}
To Reproduce
Expected behavior
Please complete the following information
Operator Version: v1.11.4 (latest release at the time of report; bug exists at least since the function was renamed from ClearResources to ClearCluster)
Activity
fix: Clarify ClearCluster nil CN spec handling and naming