Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Commit

Permalink
添加confirm确认显式指定分批数,保证幂等
Browse files Browse the repository at this point in the history
  • Loading branch information
liu-657667 committed Dec 18, 2023
1 parent ad0ae74 commit 083dc6d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
3 changes: 3 additions & 0 deletions module-controller/api/v1alpha1/moduledeployment_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ type ModuleDeploymentSpec struct {
OperationStrategy ModuleOperationStrategy `json:"operationStrategy,omitempty"`

SchedulingStrategy ModuleSchedulingStrategy `json:"schedulingStrategy,omitempty"`

// +kubebuilder:validation:Minimum=0
CurrentGroupConfirmation int32 `json:"currentGroupConfirmation,omitempty"`
}

// ModuleDeploymentStatus defines the observed state of ModuleDeployment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ spec:
Important: Run "make" to regenerate code after modifying this file'
minLength: 1
type: string
currentGroupConfirmation:
format: int32
minimum: 0
type: integer
minReadySeconds:
format: int32
type: integer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,14 @@ func (r *ModuleDeploymentReconciler) Reconcile(ctx context.Context, req ctrl.Req
return ctrl.Result{}, err
}
}

if moduleDeployment.Spec.CurrentGroupConfirmation > 0 {
moduleDeployment.Spec.CurrentGroupConfirmation = 0
if err := utils.UpdateResource(r.Client, ctx, moduleDeployment); err != nil {
return ctrl.Result{}, err
}
}

case v1alpha1.ModuleDeploymentReleaseProgressWaitingForConfirmation:
moduleDeployment.Spec.Pause = true
if err := r.Update(ctx, moduleDeployment); err != nil {
Expand All @@ -164,7 +172,9 @@ func (r *ModuleDeploymentReconciler) Reconcile(ctx context.Context, req ctrl.Req
return ctrl.Result{}, utils.Error(err, "update moduleDeployment releaseStatus progress to paused failed")
}
case v1alpha1.ModuleDeploymentReleaseProgressPaused:
if !moduleDeployment.Spec.Pause && time.Since(moduleDeployment.Status.ReleaseStatus.NextReconcileTime.Time) >= 0 {
if !moduleDeployment.Spec.Pause && time.Since(moduleDeployment.Status.ReleaseStatus.NextReconcileTime.Time) >= 0 &&
moduleDeployment.Spec.CurrentGroupConfirmation == moduleDeployment.Status.ReleaseStatus.CurrentBatch-1 {

moduleDeployment.Status.ReleaseStatus.Progress = v1alpha1.ModuleDeploymentReleaseProgressExecuting
log.Log.Info("update moduleDeployment progress from paused to executing", "moduleDeploymentName", moduleDeployment.Name)
if err := utils.UpdateStatus(r.Client, ctx, moduleDeployment); err != nil {
Expand Down

0 comments on commit 083dc6d

Please sign in to comment.