Skip to content

Commit

Permalink
deploy_ctrl: add HandleManualMode() (#189)
Browse files Browse the repository at this point in the history
Signed-off-by: haorenfsa <[email protected]>
  • Loading branch information
haorenfsa authored Sep 19, 2024
1 parent 7e4f54c commit d84ef0f
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 10 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ Versions, v2.4.11 `[1]`, 2.9.5 / 3.1.0, 3.5.14, RELEASE.2023-03-20T20-16-18Z -->


> `[1]` Version of milvus is the default version we will use, you can set it to other version. The Compatibility with milvus releases is showed below.
>
> `[2]` pulsar of 3.x is also supported. check [this sample](config/samples/milvus_pulsar_v3.yaml) for more details.
## Compatibility With Milvus Releases
Expand Down
28 changes: 22 additions & 6 deletions pkg/controllers/deploy_ctrl.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,15 @@ func (c *DeployControllerImpl) Reconcile(ctx context.Context, mc v1beta1.Milvus,
return nil
}

if mc.Spec.Com.EnableManualMode {
return biz.HandleManualMode(ctx, mc)
}

err = biz.HandleRolling(ctx, mc)
if err != nil {
return errors.Wrap(err, "handle rolling")
}

if mc.Spec.Com.EnableManualMode {
return nil
}

if ReplicasValue(component.GetReplicas(mc.Spec)) == 0 {
return biz.HandleStop(ctx, mc)
}
Expand All @@ -130,6 +130,7 @@ type DeployControllerBiz interface {
HandleStop(ctx context.Context, mc v1beta1.Milvus) error
HandleScaling(ctx context.Context, mc v1beta1.Milvus) error
HandleRolling(ctx context.Context, mc v1beta1.Milvus) error
HandleManualMode(ctx context.Context, mc v1beta1.Milvus) error
}

// DeployModeChanger changes deploy mode
Expand Down Expand Up @@ -284,10 +285,10 @@ func (c *DeployControllerBizImpl) HandleScaling(ctx context.Context, mc v1beta1.
func (c *DeployControllerBizImpl) HandleRolling(ctx context.Context, mc v1beta1.Milvus) error {
currentDeploy, lastDeploy, err := c.util.GetDeploys(ctx, mc)
if err != nil {
return errors.Wrap(err, "get querynode deploys")
return errors.Wrapf(err, "get [%s] deploys", c.component.Name)
}
if currentDeploy == nil {
return errors.Errorf("querynode deployment not found")
return errors.Errorf("[%s]'s current deployment not found", c.component.Name)
}
podTemplate := c.util.RenderPodTemplateWithoutGroupID(mc, &currentDeploy.Spec.Template, c.component)

Expand Down Expand Up @@ -315,3 +316,18 @@ func (c *DeployControllerBizImpl) HandleRolling(ctx context.Context, mc v1beta1.

return nil
}

func (c *DeployControllerBizImpl) HandleManualMode(ctx context.Context, mc v1beta1.Milvus) error {
currentDeploy, _, err := c.util.GetDeploys(ctx, mc)
if err != nil {
return errors.Wrapf(err, "get [%s] deploys", c.component.Name)
}
if currentDeploy == nil {
return errors.Errorf("[%s]'s current deployment not found", c.component.Name)
}
podTemplate := c.util.RenderPodTemplateWithoutGroupID(mc, &currentDeploy.Spec.Template, c.component)
if c.util.IsNewRollout(ctx, currentDeploy, podTemplate) {
return c.util.PrepareNewRollout(ctx, mc, currentDeploy, podTemplate)
}
return nil
}
2 changes: 1 addition & 1 deletion pkg/controllers/deploy_ctrl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func TestDeployControllerImpl_Reconcile(t *testing.T) {
mockBiz.EXPECT().MarkDeployModeChanging(gomock.Any(), mc, false).Return(nil)
mockBiz.EXPECT().HandleCreate(gomock.Any(), mc).Return(nil)
mockBiz.EXPECT().IsPaused(gomock.Any(), mc).Return(false)
mockBiz.EXPECT().HandleRolling(gomock.Any(), mc).Return(nil)
mockBiz.EXPECT().HandleManualMode(gomock.Any(), mc).Return(nil)
err := DeployControllerImpl.Reconcile(ctx, mc, QueryNode)
assert.NoError(t, err)
})
Expand Down
6 changes: 3 additions & 3 deletions pkg/controllers/deploy_ctrl_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -522,14 +522,14 @@ func (c *DeployControllerBizUtilImpl) PrepareNewRollout(ctx context.Context, mc
logger := ctrl.LoggerFrom(ctx)
labelHelper := v1beta1.Labels()
currentGroupIdStr := labelHelper.GetLabelGroupID(c.component.Name, currentDeployment)
logger.Info("prepare new rollout stage 1 update podTemplate", "deployGroupId", currentGroupIdStr, "podTemplateDiff", util.DiffStr(currentDeployment.Spec.Template, *podTemplate))
logger.Info("prepare new rollout stage 1: updateDeployTemplate", "deployGroupId", currentGroupIdStr, "podTemplateDiff", util.DiffStr(currentDeployment.Spec.Template, *podTemplate))
currentDeployment.Spec.Template = *podTemplate
labelHelper.SetGroupIDStr(c.component.Name, currentDeployment.Spec.Template.Labels, currentGroupIdStr)
err := c.cli.Update(ctx, currentDeployment)
if err != nil {
return errors.Wrap(err, "update current deploy for rolling failed")
return errors.Wrap(err, "updateDeployTemplate failed")
}
logger.Info("prepare new rollout stage 2: set current group id, set component to rolling", "currentGroupId", currentGroupIdStr)
logger.Info("prepare new rollout stage 2: setRolling", "currentGroupId", currentGroupIdStr)
labelHelper.SetCurrentGroupIDStr(&mc, c.component.Name, currentGroupIdStr)
labelHelper.SetComponentRolling(&mc, c.component.Name, true)
return c.UpdateAndRequeue(ctx, &mc)
Expand Down

0 comments on commit d84ef0f

Please sign in to comment.