Skip to content

Commit

Permalink
modify decommission
Browse files Browse the repository at this point in the history
  • Loading branch information
catpineapple committed Dec 6, 2024
1 parent e3ab93e commit 8c08871
Showing 1 changed file with 13 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,8 @@ import (

const decommissioningMessage = "decommissionBENodes in progress"

func skipApplyStatefulset(err error) bool {
if err == nil || err.Error() == decommissioningMessage {
return true
}
return false
}

func (dcgs *DisaggregatedComputeGroupsController) preApplyStatefulSet(ctx context.Context, st, est *appv1.StatefulSet, cluster *dv1.DorisDisaggregatedCluster, cg *dv1.ComputeGroup) error {

var cgStatus *dv1.ComputeGroupStatus

uniqueId := cg.UniqueId
for i := range cluster.Status.ComputeGroupStatuses {
if cluster.Status.ComputeGroupStatuses[i].UniqueId == uniqueId {
Expand All @@ -55,7 +46,7 @@ func (dcgs *DisaggregatedComputeGroupsController) preApplyStatefulSet(ctx contex

switch optType {
case "scaleDown":
err := dcgs.PreScaleOut(ctx, cgStatus, cluster, cg)
err := dcgs.scaleOut(ctx, cgStatus, cluster, cg)
if err != nil {
return err
}
Expand All @@ -65,10 +56,10 @@ func (dcgs *DisaggregatedComputeGroupsController) preApplyStatefulSet(ctx contex

}

func (dcgs *DisaggregatedComputeGroupsController) PreScaleOut(ctx context.Context, cgStatus *dv1.ComputeGroupStatus, cluster *dv1.DorisDisaggregatedCluster, cg *dv1.ComputeGroup) error {
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)
if err != nil {
klog.Errorf("PreScaleOut getMasterSqlClient failed, get fe master node connection err:%s", err.Error())
klog.Errorf("ScaleOut getMasterSqlClient failed, get fe master node connection err:%s", err.Error())
return err
}
defer sqlClient.Close()
Expand All @@ -83,7 +74,7 @@ func (dcgs *DisaggregatedComputeGroupsController) PreScaleOut(ctx context.Contex
} else { // not decommission , drop node
if err := dcgs.scaledOutBENodesByDrop(sqlClient, cgName, cgKeepAmount); err != nil {
cgStatus.Phase = dv1.ScaleDownFailed
klog.Errorf("PreScaleOut scaledOutBENodesByDrop failed, err:%s ", err.Error())
klog.Errorf("ScaleOut scaledOutBENodesByDrop failed, err:%s ", err.Error())
return err
}
}
Expand All @@ -102,14 +93,14 @@ func (dcgs *DisaggregatedComputeGroupsController) scaledOutBENodesByDecommission
err = dcgs.decommissionBENodes(sqlClient, cgName, cgKeepAmount)
if err != nil {
cgStatus.Phase = dv1.ScaleDownFailed
klog.Errorf("PreScaleOut decommissionBENodes failed, err:%s ", err.Error())
klog.Errorf("scaledOutBENodesByDecommission failed, err:%s ", err.Error())
return err
}
cgStatus.Phase = dv1.Decommissioning
return errors.New(decommissioningMessage)
case resource.Decommissioning, resource.DecommissionPhaseUnknown:
cgStatus.Phase = dv1.Decommissioning
klog.Infof("PreScaleOut decommissionBENodes in progress")
klog.Infof("scaledOutBENodesByDecommission in progress")
return errors.New(decommissioningMessage)
case resource.Decommissioned:
dcgs.scaledOutBENodesByDrop(sqlClient, cgName, cgKeepAmount)
Expand Down Expand Up @@ -237,3 +228,10 @@ func getScaledOutBENode(
}
return dropNodes, nil
}

func skipApplyStatefulset(err error) bool {
if err == nil || err.Error() == decommissioningMessage {
return true
}
return false
}

0 comments on commit 8c08871

Please sign in to comment.