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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ require (
k8s.io/klog/v2 v2.130.1
k8s.io/kubernetes v1.22.2
k8s.io/utils v0.0.0-20241210054802-24370beab758
kusionstack.io/kube-api v0.7.4-0.20250922083401-278352ec5aab
kusionstack.io/kube-api v0.7.4-0.20251013070018-4c09604521e4
kusionstack.io/kube-utils v0.2.1-0.20250613035327-11e9cdaec9d6
kusionstack.io/resourceconsist v0.0.4
sigs.k8s.io/controller-runtime v0.21.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1021,8 +1021,8 @@ k8s.io/sample-apiserver v0.22.2/go.mod h1:h+/DIV5EmuNq4vfPr5TSXy9mIBVXXlPAKQMPbj
k8s.io/system-validators v1.5.0/go.mod h1:bPldcLgkIUK22ALflnsXk8pvkTEndYdNuaHH6gRrl0Q=
k8s.io/utils v0.0.0-20240102154912-e7106e64919e h1:eQ/4ljkx21sObifjzXwlPKpdGLrCfRziVtos3ofG/sQ=
k8s.io/utils v0.0.0-20240102154912-e7106e64919e/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
kusionstack.io/kube-api v0.7.4-0.20250922083401-278352ec5aab h1:7l7Y3YezVPBP65JtlH57IwH9XsJdV2QhZcJEcTEg3cQ=
kusionstack.io/kube-api v0.7.4-0.20250922083401-278352ec5aab/go.mod h1:e1jtrQH2LK5fD2nTyfIXG6nYrYbU8VXShRxTRwVPaLk=
kusionstack.io/kube-api v0.7.4-0.20251013070018-4c09604521e4 h1:VQS8BsRs7jXTY+wwtRjOIfSxDq/Mu7ZIaFZ9CxRIe6U=
kusionstack.io/kube-api v0.7.4-0.20251013070018-4c09604521e4/go.mod h1:e1jtrQH2LK5fD2nTyfIXG6nYrYbU8VXShRxTRwVPaLk=
kusionstack.io/kube-utils v0.2.1-0.20250613035327-11e9cdaec9d6 h1:HYE6Wa8EzSlA6UmaTLtNKUgkB2mmasp6Ul69d3/SpK0=
kusionstack.io/kube-utils v0.2.1-0.20250613035327-11e9cdaec9d6/go.mod h1:5Uy3GCJ1JEGqZw/Sp/uVnHBJN1t9wjY6USPSZ9s4idk=
kusionstack.io/resourceconsist v0.0.4 h1:wRqLJuNh8O4TT6p0uOklFpHUKiRdRxcAH71Sw/q9LhE=
Expand Down
1 change: 1 addition & 0 deletions pkg/controllers/rolloutrun/executor/alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ const (
StepPostBatchStepHook = rolloutv1alpha1.RolloutStepPostBatchStepHook
StepSucceeded = rolloutv1alpha1.RolloutStepSucceeded
StepResourceRecycling = rolloutv1alpha1.RolloutStepResourceRecycling
StepSkipped = rolloutv1alpha1.RolloutStepSkipped
)
38 changes: 16 additions & 22 deletions pkg/controllers/rolloutrun/executor/do_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ func (r *Executor) doCommand(ctx *ExecutorContext) ctrl.Result {
logger.Info("processing manual command", "command", cmd)

newStatus := ctx.NewStatus
newBatchStatus := ctx.NewStatus.BatchStatus

batchError := newStatus.Error
currentBatchIndex := newBatchStatus.CurrentBatchIndex
switch cmd {
case rolloutapis.AnnoManualCommandPause:
newStatus.Phase = rolloutv1alpha1.RolloutRunPhasePausing
Expand All @@ -31,30 +28,27 @@ func (r *Executor) doCommand(ctx *ExecutorContext) ctrl.Result {
}
case rolloutapis.AnnoManualCommandSkip:
if batchError != nil {
newStatus.Error = nil

if int(currentBatchIndex) < (len(rolloutRun.Spec.Batch.Batches) - 1) {
currentBatchIndex++
newBatchStatus.CurrentBatchIndex = currentBatchIndex
newBatchStatus.CurrentBatchState = StepNone
} else {
newStatus.Phase = rolloutv1alpha1.RolloutRunPhasePostRollout
}
handleBatchStatusWhenSkipped(newStatus, len(rolloutRun.Spec.Batch.Batches))
}
case rolloutapis.AnnoManualCommandCancel:
newStatus.Phase = rolloutv1alpha1.RolloutRunPhaseCanceling
case rolloutapis.AnnoManualCommandForceSkipCurrentBatch:
if batchError != nil {
newStatus.Error = nil
}
if int(currentBatchIndex) < (len(rolloutRun.Spec.Batch.Batches) - 1) {
currentBatchIndex++
newBatchStatus.CurrentBatchIndex = currentBatchIndex
newBatchStatus.CurrentBatchState = StepNone
} else {
newBatchStatus.CurrentBatchState = StepPostBatchStepHook
}
handleBatchStatusWhenSkipped(newStatus, len(rolloutRun.Spec.Batch.Batches))
}

return ctrl.Result{Requeue: true}
}

func handleBatchStatusWhenSkipped(newStatus *rolloutv1alpha1.RolloutRunStatus, batchSize int) {
currentBatchIndex := newStatus.BatchStatus.CurrentBatchIndex
if newStatus.Error != nil {
newStatus.Error = nil
}

// only skip when current batch is not the last batch
if int(currentBatchIndex) < (batchSize - 1) {
newStatus.BatchStatus.Records[currentBatchIndex].State = StepSkipped
newStatus.BatchStatus.CurrentBatchIndex = currentBatchIndex + 1
newStatus.BatchStatus.CurrentBatchState = StepNone
}
}