diff --git a/api/v1alpha1/rollout_types.go b/api/v1alpha1/rollout_types.go index 6a5edfa..9096c4f 100644 --- a/api/v1alpha1/rollout_types.go +++ b/api/v1alpha1/rollout_types.go @@ -33,6 +33,9 @@ type RolloutSpec struct { ObjectRef ObjectRef `json:"objectRef"` // rollout strategy Strategy RolloutStrategy `json:"strategy"` + // RolloutID should be changed before each workload revision publication. + // It is to distinguish consecutive multiple workload publications and rollout progress. + RolloutID string `json:"rolloutID,omitempty"` } type ObjectRef struct { @@ -206,6 +209,8 @@ const ( type CanaryStatus struct { // observedWorkloadGeneration is the most recent generation observed for this Rollout ref workload generation. ObservedWorkloadGeneration int64 `json:"observedWorkloadGeneration,omitempty"` + // ObservedRolloutID will record the newest spec.RolloutID if status.canaryRevision equals to workload.updateRevision + ObservedRolloutID string `json:"observedRolloutID,omitempty"` // RolloutHash from rollout.spec object RolloutHash string `json:"rolloutHash,omitempty"` // CanaryService holds the name of a service which selects pods with canary version and don't select any pods with stable version. diff --git a/config/crd/bases/rollouts.kruise.io_rollouts.yaml b/config/crd/bases/rollouts.kruise.io_rollouts.yaml index 9819a10..a63ac78 100644 --- a/config/crd/bases/rollouts.kruise.io_rollouts.yaml +++ b/config/crd/bases/rollouts.kruise.io_rollouts.yaml @@ -80,6 +80,11 @@ spec: - name type: object type: object + rolloutID: + description: RolloutID should be changed before each workload revision + publication. It is to distinguish consecutive multiple workload + publications and rollout progress. + type: string strategy: description: rollout strategy properties: @@ -207,6 +212,10 @@ spec: type: string message: type: string + observedRolloutID: + description: ObservedRolloutID will record the newest spec.RolloutID + if status.canaryRevision equals to workload.updateRevision + type: string observedWorkloadGeneration: description: observedWorkloadGeneration is the most recent generation observed for this Rollout ref workload generation. diff --git a/pkg/controller/rollout/progressing.go b/pkg/controller/rollout/progressing.go index 066a1af..053bf78 100644 --- a/pkg/controller/rollout/progressing.go +++ b/pkg/controller/rollout/progressing.go @@ -130,6 +130,7 @@ func (r *RolloutReconciler) reconcileRolloutProgressing(rollout *rolloutv1alpha1 } } } + // after the normal completion of rollout, enter into the Finalising process case rolloutv1alpha1.ProgressingReasonFinalising: klog.Infof("rollout(%s/%s) is Progressing, and in reason(%s)", rollout.Namespace, rollout.Name, cond.Reason) diff --git a/pkg/controller/rollout/status.go b/pkg/controller/rollout/status.go index 8118a90..ea46c24 100644 --- a/pkg/controller/rollout/status.go +++ b/pkg/controller/rollout/status.go @@ -83,6 +83,7 @@ func (r *RolloutReconciler) updateRolloutStatus(rollout *rolloutv1alpha1.Rollout // which version of deployment is targeted, ObservedWorkloadGeneration that is to compare with the workload generation if newStatus.CanaryStatus != nil && newStatus.CanaryStatus.CanaryRevision != "" && newStatus.CanaryStatus.CanaryRevision == workload.CanaryRevision { + newStatus.CanaryStatus.ObservedRolloutID = rollout.Spec.RolloutID newStatus.CanaryStatus.ObservedWorkloadGeneration = workload.Generation }