Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ func (dcgs *DisaggregatedComputeGroupsController) clearCGInDorisMeta(ctx context
return nil
}

sqlClient, err := dcgs.getMasterSqlClient(ctx, dcgs.K8sclient, ddc)
sqlClient, err := dcgs.getMasterSqlClient(ctx, ddc)
if err != nil {
klog.Errorf("DisaggregatedComputeGroupsController clearCGInDorisMeta dropCGBySQLClient getMasterSqlClient failed: %s", err.Error())
dcgs.K8srecorder.Event(ddc, string(sc.EventWarning), string(sc.CGSqlExecFailed), "computeGroupSync dropCGBySQLClient failed: "+err.Error())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,10 @@ package computegroups
import (
"context"
dv1 "github.com/apache/doris-operator/api/disaggregated/v1"
"github.com/apache/doris-operator/pkg/common/utils/k8s"
"github.com/apache/doris-operator/pkg/common/utils/mysql"
"github.com/apache/doris-operator/pkg/common/utils/resource"
appv1 "k8s.io/api/apps/v1"
"k8s.io/klog/v2"
"sigs.k8s.io/controller-runtime/pkg/client"
"strconv"
"strings"
)
Expand Down Expand Up @@ -56,7 +54,7 @@ func (dcgs *DisaggregatedComputeGroupsController) preApplyStatefulSet(ctx contex
}

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

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

// get host and port
// When the operator and dcr are deployed in different namespace, it will be inaccessible, so need to add the dcr svc namespace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,7 @@ func (dfc *DisaggregatedFEController) recycleResources(ctx context.Context, ddc
// 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
func (dfc *DisaggregatedFEController) dropFEBySQLClient(ctx context.Context, k8sclient client.Client, cluster *v1.DorisDisaggregatedCluster) error {
// get adminuserName and pwd
secret, _ := k8s.GetSecret(ctx, k8sclient, cluster.Namespace, cluster.Spec.AuthSecret)
adminUserName, password := resource.GetDorisLoginInformation(secret)
adminUserName, password := dfc.GetManagementAdminUserAndPWD(ctx, cluster)

// get host and port
// When the operator and dcr are deployed in different namespace, it will be inaccessible, so need to add the dcr svc namespace
Expand Down
15 changes: 15 additions & 0 deletions pkg/controller/sub_controller/disaggregated_subcontroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,3 +238,18 @@ func (d *DisaggregatedSubDefaultController) RestrictConditionsEqual(nst *appv1.S
// TODO: updates to statefulset spec for fields other than 'replicas', 'template', 'updateStrategy', 'persistentVolumeClaimRetentionPolicy' and 'minReadySeconds' are forbidden
nst.Spec.VolumeClaimTemplates = est.Spec.VolumeClaimTemplates
}

func (d *DisaggregatedSubDefaultController) GetManagementAdminUserAndPWD(ctx context.Context, ddc *v1.DorisDisaggregatedCluster) (string, string) {
adminUserName := "root"
password := ""
if ddc.Spec.AuthSecret != "" {
secret, _ := k8s.GetSecret(ctx, d.K8sclient, ddc.Namespace, ddc.Spec.AuthSecret)
adminUserName, password = resource.GetDorisLoginInformation(secret)
} else if ddc.Spec.AdminUser != nil {
adminUserName = ddc.Spec.AdminUser.Name
password = ddc.Spec.AdminUser.Password
}

return adminUserName, password

}