Skip to content

Commit 10eef37

Browse files
committed
fix
1 parent 2491b34 commit 10eef37

File tree

4 files changed

+20
-9
lines changed

4 files changed

+20
-9
lines changed

pkg/controller/sub_controller/disaggregated_cluster/computegroups/controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ func (dcgs *DisaggregatedComputeGroupsController) clearCGInDorisMeta(ctx context
348348
return nil
349349
}
350350

351-
sqlClient, err := dcgs.getMasterSqlClient(ctx, dcgs.K8sclient, ddc)
351+
sqlClient, err := dcgs.getMasterSqlClient(ctx, ddc)
352352
if err != nil {
353353
klog.Errorf("DisaggregatedComputeGroupsController clearCGInDorisMeta dropCGBySQLClient getMasterSqlClient failed: %s", err.Error())
354354
dcgs.K8srecorder.Event(ddc, string(sc.EventWarning), string(sc.CGSqlExecFailed), "computeGroupSync dropCGBySQLClient failed: "+err.Error())

pkg/controller/sub_controller/disaggregated_cluster/computegroups/prepare_modify.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,10 @@ package computegroups
2020
import (
2121
"context"
2222
dv1 "github.com/apache/doris-operator/api/disaggregated/v1"
23-
"github.com/apache/doris-operator/pkg/common/utils/k8s"
2423
"github.com/apache/doris-operator/pkg/common/utils/mysql"
2524
"github.com/apache/doris-operator/pkg/common/utils/resource"
2625
appv1 "k8s.io/api/apps/v1"
2726
"k8s.io/klog/v2"
28-
"sigs.k8s.io/controller-runtime/pkg/client"
2927
"strconv"
3028
"strings"
3129
)
@@ -56,7 +54,7 @@ func (dcgs *DisaggregatedComputeGroupsController) preApplyStatefulSet(ctx contex
5654
}
5755

5856
func (dcgs *DisaggregatedComputeGroupsController) scaleOut(ctx context.Context, cgStatus *dv1.ComputeGroupStatus, cluster *dv1.DorisDisaggregatedCluster, cg *dv1.ComputeGroup) error {
59-
sqlClient, err := dcgs.getMasterSqlClient(ctx, dcgs.K8sclient, cluster)
57+
sqlClient, err := dcgs.getMasterSqlClient(ctx, cluster)
6058
if err != nil {
6159
klog.Errorf("ScaleOut getMasterSqlClient failed, get fe master node connection err:%s", err.Error())
6260
return err
@@ -161,10 +159,9 @@ func (dcgs *DisaggregatedComputeGroupsController) decommissionBENodes(
161159
return nil
162160
}
163161

164-
func (dcgs *DisaggregatedComputeGroupsController) getMasterSqlClient(ctx context.Context, k8sclient client.Client, cluster *dv1.DorisDisaggregatedCluster) (*mysql.DB, error) {
162+
func (dcgs *DisaggregatedComputeGroupsController) getMasterSqlClient(ctx context.Context, cluster *dv1.DorisDisaggregatedCluster) (*mysql.DB, error) {
165163
// get user and password
166-
secret, _ := k8s.GetSecret(ctx, k8sclient, cluster.Namespace, cluster.Spec.AuthSecret)
167-
adminUserName, password := resource.GetDorisLoginInformation(secret)
164+
adminUserName, password := dcgs.GetManagementAdminUserAndPWD(ctx, cluster)
168165

169166
// get host and port
170167
// When the operator and dcr are deployed in different namespace, it will be inaccessible, so need to add the dcr svc namespace

pkg/controller/sub_controller/disaggregated_cluster/disaggregated_fe/controller.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,7 @@ func (dfc *DisaggregatedFEController) recycleResources(ctx context.Context, ddc
307307
// dropFEBySQLClient only delete the fe nodes whose pod number is greater than the expected number (cluster.Spec.FeSpec.Replicas) by calling the drop_node interface
308308
func (dfc *DisaggregatedFEController) dropFEBySQLClient(ctx context.Context, k8sclient client.Client, cluster *v1.DorisDisaggregatedCluster) error {
309309
// get adminuserName and pwd
310-
secret, _ := k8s.GetSecret(ctx, k8sclient, cluster.Namespace, cluster.Spec.AuthSecret)
311-
adminUserName, password := resource.GetDorisLoginInformation(secret)
310+
adminUserName, password := dfc.GetManagementAdminUserAndPWD(ctx, cluster)
312311

313312
// get host and port
314313
// When the operator and dcr are deployed in different namespace, it will be inaccessible, so need to add the dcr svc namespace

pkg/controller/sub_controller/disaggregated_subcontroller.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,3 +238,18 @@ func (d *DisaggregatedSubDefaultController) RestrictConditionsEqual(nst *appv1.S
238238
// TODO: updates to statefulset spec for fields other than 'replicas', 'template', 'updateStrategy', 'persistentVolumeClaimRetentionPolicy' and 'minReadySeconds' are forbidden
239239
nst.Spec.VolumeClaimTemplates = est.Spec.VolumeClaimTemplates
240240
}
241+
242+
func (d *DisaggregatedSubDefaultController) GetManagementAdminUserAndPWD(ctx context.Context, ddc *v1.DorisDisaggregatedCluster) (string, string) {
243+
adminUserName := "root"
244+
password := ""
245+
if ddc.Spec.AuthSecret != "" {
246+
secret, _ := k8s.GetSecret(ctx, d.K8sclient, ddc.Namespace, ddc.Spec.AuthSecret)
247+
adminUserName, password = resource.GetDorisLoginInformation(secret)
248+
} else if ddc.Spec.AdminUser != nil {
249+
adminUserName = ddc.Spec.AdminUser.Name
250+
password = ddc.Spec.AdminUser.Password
251+
}
252+
253+
return adminUserName, password
254+
255+
}

0 commit comments

Comments
 (0)