diff --git a/api/v1alpha1/conversion.go b/api/v1alpha1/conversion.go index 13b98b24..6872c916 100644 --- a/api/v1alpha1/conversion.go +++ b/api/v1alpha1/conversion.go @@ -114,6 +114,8 @@ func (src *Rollout) ConvertTo(dst conversion.Hub) error { CurrentStepState: v1beta1.CanaryStepState(src.Status.CanaryStatus.CurrentStepState), Message: src.Status.CanaryStatus.Message, LastUpdateTime: src.Status.CanaryStatus.LastUpdateTime, + FinalisingStep: v1beta1.FinalisingStepType(src.Status.CanaryStatus.FinalisingStep), + NextStepIndex: src.Status.CanaryStatus.NextStepIndex, }, CanaryRevision: src.Status.CanaryStatus.CanaryRevision, CanaryReplicas: src.Status.CanaryStatus.CanaryReplicas, @@ -258,6 +260,8 @@ func (dst *Rollout) ConvertFrom(src conversion.Hub) error { CurrentStepState: CanaryStepState(srcV1beta1.Status.CanaryStatus.CurrentStepState), Message: srcV1beta1.Status.CanaryStatus.Message, LastUpdateTime: srcV1beta1.Status.CanaryStatus.LastUpdateTime, + FinalisingStep: FinalizeStateType(srcV1beta1.Status.CanaryStatus.FinalisingStep), + NextStepIndex: srcV1beta1.Status.CanaryStatus.NextStepIndex, } return nil default: diff --git a/api/v1alpha1/rollout_types.go b/api/v1alpha1/rollout_types.go index 39b6ca53..df3fa933 100644 --- a/api/v1alpha1/rollout_types.go +++ b/api/v1alpha1/rollout_types.go @@ -242,6 +242,14 @@ type CanaryStatus struct { CanaryReplicas int32 `json:"canaryReplicas"` // CanaryReadyReplicas the numbers of ready canary revision pods CanaryReadyReplicas int32 `json:"canaryReadyReplicas"` + // NextStepIndex defines the next step of the rollout is on. + // In normal case, NextStepIndex is equal to CurrentStepIndex + 1 + // If the current step is the last step, NextStepIndex is equal to 0 + // Before the release, NextStepIndex is also equal to 0 + // It is allowed to modify NextStepIndex by design, + // e.g. if CurrentStepIndex is 2, user can patch NextStepIndex to 3 (if exists) to + // achieve batch jump, or patch NextStepIndex to 1 to implement a re-execution of step 1 + NextStepIndex int32 `json:"nextStepIndex"` // +optional CurrentStepIndex int32 `json:"currentStepIndex"` CurrentStepState CanaryStepState `json:"currentStepState"` diff --git a/api/v1beta1/rollout_types.go b/api/v1beta1/rollout_types.go index 9d6b548e..d1b7b750 100644 --- a/api/v1beta1/rollout_types.go +++ b/api/v1beta1/rollout_types.go @@ -369,10 +369,12 @@ type CommonStatus struct { // It is allowed to modify NextStepIndex by design, // e.g. if CurrentStepIndex is 2, user can patch NextStepIndex to 3 (if exists) to // achieve batch jump, or patch NextStepIndex to 1 to implement a re-execution of step 1 - NextStepIndex int32 `json:"nextStepIndex"` - CurrentStepState CanaryStepState `json:"currentStepState"` - Message string `json:"message,omitempty"` - LastUpdateTime *metav1.Time `json:"lastUpdateTime,omitempty"` + NextStepIndex int32 `json:"nextStepIndex"` + // FinalisingStep the step of finalising + FinalisingStep FinalisingStepType `json:"finalisingStep"` + CurrentStepState CanaryStepState `json:"currentStepState"` + Message string `json:"message,omitempty"` + LastUpdateTime *metav1.Time `json:"lastUpdateTime,omitempty"` } // CanaryStatus status fields that only pertain to the canary rollout @@ -386,8 +388,6 @@ type CanaryStatus struct { CanaryReplicas int32 `json:"canaryReplicas"` // CanaryReadyReplicas the numbers of ready canary revision pods CanaryReadyReplicas int32 `json:"canaryReadyReplicas"` - // FinalisingStep the step of finalising - FinalisingStep FinalisingStepType `json:"finalisingStep"` } // BlueGreenStatus status fields that only pertain to the blueGreen rollout @@ -395,13 +395,11 @@ type BlueGreenStatus struct { CommonStatus `json:",inline"` // CanaryRevision is calculated by rollout based on podTemplateHash, and the internal logic flow uses // It may be different from rs podTemplateHash in different k8s versions, so it cannot be used as service selector label - CanaryRevision string `json:"updatedRevision"` + UpdatedRevision string `json:"updatedRevision"` // UpdatedReplicas the numbers of updated pods UpdatedReplicas int32 `json:"updatedReplicas"` // UpdatedReadyReplicas the numbers of updated ready pods UpdatedReadyReplicas int32 `json:"updatedReadyReplicas"` - // FinalisingStep the step of finalising - FinalisingStep FinalisingStepType `json:"finalisingStep"` } // GetSubStatus returns the ethier canary or bluegreen status @@ -427,7 +425,7 @@ func (r *RolloutStatus) GetCanaryRevision() string { if r.CanaryStatus != nil { return r.CanaryStatus.CanaryRevision } - return r.BlueGreenStatus.CanaryRevision + return r.BlueGreenStatus.UpdatedRevision } func (r *RolloutStatus) SetCanaryRevision(revision string) { @@ -435,7 +433,7 @@ func (r *RolloutStatus) SetCanaryRevision(revision string) { r.CanaryStatus.CanaryRevision = revision } if r.BlueGreenStatus != nil { - r.BlueGreenStatus.CanaryRevision = revision + r.BlueGreenStatus.UpdatedRevision = revision } } diff --git a/pkg/controller/rollout/rollout_progressing.go b/pkg/controller/rollout/rollout_progressing.go index 9eae32a5..42b7effc 100644 --- a/pkg/controller/rollout/rollout_progressing.go +++ b/pkg/controller/rollout/rollout_progressing.go @@ -80,7 +80,7 @@ func (r *RolloutReconciler) reconcileRolloutProgressing(rollout *v1beta1.Rollout CurrentStepState: v1beta1.CanaryStepStateInit, LastUpdateTime: &metav1.Time{Time: time.Now()}, }, - CanaryRevision: rolloutContext.Workload.CanaryRevision, + UpdatedRevision: rolloutContext.Workload.CanaryRevision, } } else { newStatus.CanaryStatus = &v1beta1.CanaryStatus{ diff --git a/pkg/controller/rollout/rollout_status.go b/pkg/controller/rollout/rollout_status.go index c1c8a375..015bca14 100755 --- a/pkg/controller/rollout/rollout_status.go +++ b/pkg/controller/rollout/rollout_status.go @@ -135,7 +135,7 @@ func (r *RolloutReconciler) calculateRolloutStatus(rollout *v1beta1.Rollout) (re CurrentStepState: v1beta1.CanaryStepStateCompleted, RolloutHash: rollout.Annotations[util.RolloutHashAnnotation], }, - CanaryRevision: workload.CanaryRevision, + UpdatedRevision: workload.CanaryRevision, } } else { newStatus.CanaryStatus = &v1beta1.CanaryStatus{