Skip to content
Open
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
9 changes: 7 additions & 2 deletions pkg/controllers/rolloutrun/executor/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"fmt"
"time"

corev1 "k8s.io/api/core/v1"
utilerrors "k8s.io/apimachinery/pkg/util/errors"
"k8s.io/apimachinery/pkg/util/intstr"
rolloutv1alpha1 "kusionstack.io/kube-api/rollout/v1alpha1"
Expand Down Expand Up @@ -194,6 +195,8 @@ func (e *batchExecutor) doBatchUpgrading(ctx *ExecutorContext) (bool, time.Durat
newStatus := ctx.NewStatus
currentBatchIndex := newStatus.BatchStatus.CurrentBatchIndex
currentBatch := rolloutRun.Spec.Batch.Batches[currentBatchIndex]
totalBatches := len(rolloutRun.Spec.Batch.Batches)
isLastBatch := int(currentBatchIndex+1) == totalBatches

logger := ctx.GetBatchLogger()

Expand All @@ -214,13 +217,15 @@ func (e *batchExecutor) doBatchUpgrading(ctx *ExecutorContext) (bool, time.Durat

currentBatchExpectedReplicas, _ := workload.CalculateUpdatedReplicas(&status.Replicas, item.Replicas)

if info.CheckUpdatedReady(currentBatchExpectedReplicas) {
ready, reason := info.CheckUpdatedReady(currentBatchExpectedReplicas, isLastBatch)
if ready {
// if the target is ready, we will not change partition
continue
}
ctx.Recorder.Eventf(ctx.RolloutRun, corev1.EventTypeNormal, "WaitingWorkloadUpdatedReady", "still waiting for target to be ready, target: %v, reason: %s", item.CrossClusterObjectNameReference, reason)

allWorkloadReady = false
logger.V(3).Info("still waiting for target to be ready", "target", item.CrossClusterObjectNameReference)
logger.V(3).Info("still waiting for target to be ready", "target", item.CrossClusterObjectNameReference, "reason", reason)

expectedReplicas, err := e.calculateExpectedReplicasBySlidingWindow(status, currentBatchExpectedReplicas, item.ReplicaSlidingWindow)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/rolloutrun/executor/canary.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ func (e *canaryExecutor) doCanary(ctx *ExecutorContext) (bool, time.Duration, er

// 2.b. waiting canary workload ready
for _, info := range canaryWorkloads {
if !info.CheckUpdatedReady(info.Status.DesiredReplicas) {
if ready, _ := info.CheckUpdatedReady(info.Status.DesiredReplicas, false); !ready {
// ready
logger.Info("still waiting for canary target ready",
"cluster", info.ClusterName,
Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/rolloutrun/webhook/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ func (w *worker) doProbe() (keepGoing bool) {
func (w *worker) now() metav1.Time {
now := metav1.NewTime(w.webhookManager.clock.Now())
data, _ := now.MarshalJSON()
now.UnmarshalJSON(data)
now.UnmarshalJSON(data) //nolint
return now
}

Expand Down
12 changes: 9 additions & 3 deletions pkg/workload/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,17 @@ func (o *Info) String() string {
return rolloutv1alpha1.CrossClusterObjectNameReference{Cluster: o.ClusterName, Name: o.Name}.String()
}

func (o *Info) CheckUpdatedReady(replicas int32) bool {
func (o *Info) CheckUpdatedReady(replicas int32, strictCheck bool) (bool, string) {
if o.Generation != o.Status.ObservedGeneration {
return false
return false, "workload Generation and ObservedGeneration are mismatched"
}
return o.Status.UpdatedAvailableReplicas >= replicas && o.Status.ObservedReplicas <= o.Status.DesiredReplicas
if o.Status.UpdatedAvailableReplicas < replicas {
return false, "workload updated available replicas is not satisfied"
}
if strictCheck && o.Status.ObservedReplicas > o.Status.DesiredReplicas {
return false, "workload observed replicas is more than desiredReplicas"
}
return true, ""
}

func (o *Info) APIStatus() rolloutv1alpha1.RolloutWorkloadStatus {
Expand Down