diff --git a/config/crd/rollout/rollout.kusionstack.io_rolloutruns.yaml b/config/crd/rollout/rollout.kusionstack.io_rolloutruns.yaml index f008832..a207d14 100644 --- a/config/crd/rollout/rollout.kusionstack.io_rolloutruns.yaml +++ b/config/crd/rollout/rollout.kusionstack.io_rolloutruns.yaml @@ -4500,6 +4500,55 @@ spec: required: - targets type: object + rollback: + description: Rollback Strategy + properties: + batches: + description: Batches define the order of phases to execute release in rollback release + items: + properties: + breakpoint: + description: If set to true, the rollout will be paused before the step starts. + type: boolean + properties: + additionalProperties: + type: string + description: Properties contains additional information for step. + type: object + targets: + description: desired target replicas + items: + properties: + cluster: + description: Cluster indicates the name of cluster + type: string + name: + description: Name is the resource name + type: string + replicaSlidingWindow: + anyOf: + - type: integer + - type: string + description: |- + ReplicaSlidingWindow used to control the number of pods that are allowed to be upgraded in + a sliding window for progressive rollout smoothly. + x-kubernetes-int-or-string: true + replicas: + anyOf: + - type: integer + - type: string + description: Replicas is the replicas of the rollout task, which represents the number of pods to be upgraded + x-kubernetes-int-or-string: true + required: + - name + - replicas + type: object + type: array + required: + - targets + type: object + type: array + type: object targetType: description: TargetType defines the GroupVersionKind of target resource properties: @@ -4888,6 +4937,115 @@ spec: phase: description: Phase indecates the current phase of rollout type: string + rollbackStatus: + description: RollbackStatus describes the state of the active rollback release + properties: + currentBatchIndex: + description: CurrentBatchIndex defines the current batch index of batch release progress. + format: int32 + type: integer + currentBatchState: + description: CurrentBatchState indicates the current batch state. + type: string + records: + description: Records contains all batches status details. + items: + properties: + finishTime: + description: FinishTime is the time when the stage finished + format: date-time + type: string + index: + description: Index is the id of the batch + format: int32 + type: integer + startTime: + description: StartTime is the time when the stage started + format: date-time + type: string + state: + description: State is Rollout step state + type: string + targets: + description: WorkloadDetails contains release details for each workload + items: + properties: + cluster: + description: Cluster defines which cluster the workload is in. + type: string + generation: + description: Generation is the found in workload metadata. + format: int64 + type: integer + name: + description: Name is the workload name + type: string + observedGeneration: + description: ObservedGeneration is the most recent generation observed for this workload. + format: int64 + type: integer + replicas: + description: Replicas is the desired number of pods targeted by workload + format: int32 + type: integer + stableRevision: + description: StableRevision is the old stable revision used to generate pods. + type: string + updatedAvailableReplicas: + description: UpdatedAvailableReplicas is the number of service available pods targeted by workload that have the updated template spec. + format: int32 + type: integer + updatedReadyReplicas: + description: UpdatedReadyReplicas is the number of ready pods targeted by workload that have the updated template spec. + format: int32 + type: integer + updatedReplicas: + description: UpdatedReplicas is the number of pods targeted by workload that have the updated template spec. + format: int32 + type: integer + updatedRevision: + description: UpdatedRevision is the updated template revision used to generate pods. + type: string + required: + - replicas + - updatedAvailableReplicas + - updatedReadyReplicas + - updatedReplicas + type: object + type: array + webhooks: + description: Webhooks contains webhook status + items: + properties: + code: + description: Code is a globally unique identifier + type: string + failureCount: + description: Failure count + format: int32 + type: integer + hookType: + description: Webhook Type + type: string + message: + description: A human-readable message indicating details about the transition. + type: string + name: + description: Webhook Name + type: string + reason: + description: A human-readable short word + type: string + state: + description: Current webhook worker state + type: string + type: object + type: array + type: object + type: array + required: + - currentBatchIndex + type: object targetStatuses: description: TargetStatuses describes the referenced workloads status items: diff --git a/rollout/v1alpha1/rollout_types.go b/rollout/v1alpha1/rollout_types.go index 0763b7b..92a11d5 100644 --- a/rollout/v1alpha1/rollout_types.go +++ b/rollout/v1alpha1/rollout_types.go @@ -163,6 +163,10 @@ const ( RolloutReasonProgressingCompleted = "Completed" // RolloutReasonProgressingCanceled means the rollout is completed. RolloutReasonProgressingCanceled = "Canceled" + // RolloutReasonProgressingRollbacked means the rollout is rollbacked. + RolloutReasonProgressingRollbacking = "Rollbacking" + // RolloutReasonProgressingRollbacked means the rollout is rollbacked. + RolloutReasonProgressingRollbacked = "Rollbacked" // RolloutReasonProgressingError means the rollout is completed. RolloutReasonProgressingError = "Error" ) @@ -219,6 +223,9 @@ const ( // RolloutStepPreBatchStepHook indicates that the step is in the pre-batch hook. RolloutStepPreBatchStepHook RolloutStepState = RolloutStepState(PreBatchStepHook) + // RolloutStepPreRollbackStepHook indicates that the step is in the pre-rollback hook. + RolloutStepPreRollbackStepHook RolloutStepState = RolloutStepState(PreRollbackStepHook) + // RolloutStepRunning indicates that the step is running. RolloutStepRunning RolloutStepState = "Running" @@ -228,6 +235,9 @@ const ( // RolloutStepPostBatchStepHook indicates that the step is in the post-batch hook. RolloutStepPostBatchStepHook RolloutStepState = RolloutStepState(PostBatchStepHook) + // RolloutStepPostRollbackStepHook indicates that the step is in the post-rollback hook. + RolloutStepPostRollbackStepHook RolloutStepState = RolloutStepState(PostRollbackStepHook) + // RolloutStepSucceeded indicates that the step is completed. RolloutStepSucceeded RolloutStepState = "Succeeded" diff --git a/rollout/v1alpha1/rollout_webhook_types.go b/rollout/v1alpha1/rollout_webhook_types.go index 04c3fc2..1c5a09f 100644 --- a/rollout/v1alpha1/rollout_webhook_types.go +++ b/rollout/v1alpha1/rollout_webhook_types.go @@ -147,6 +147,10 @@ type RolloutWebhookReviewSpec struct { // Batch defines the batch step webhook review spec // +optional Batch *RolloutWebhookReviewBatch `json:"batch,omitempty"` + + // Rollback defines the rollback step webhook review spec + // +optional + Rollback *RolloutWebhookReviewBatch `json:"rollback,omitempty"` } type RolloutWebhookReviewCanary struct { @@ -169,10 +173,12 @@ type RolloutWebhookReviewBatch struct { type HookType string const ( - PreCanaryStepHook HookType = "PreCanaryStepHook" - PostCanaryStepHook HookType = "PostCanaryStepHook" - PreBatchStepHook HookType = "PreBatchStepHook" - PostBatchStepHook HookType = "PostBatchStepHook" + PreCanaryStepHook HookType = "PreCanaryStepHook" + PostCanaryStepHook HookType = "PostCanaryStepHook" + PreBatchStepHook HookType = "PreBatchStepHook" + PostBatchStepHook HookType = "PostBatchStepHook" + PreRollbackStepHook HookType = "PreRollbackStepHook" + PostRollbackStepHook HookType = "PostRollbackStepHook" ) type RolloutWebhookReviewStatus struct { diff --git a/rollout/v1alpha1/rolloutrun_types.go b/rollout/v1alpha1/rolloutrun_types.go index b9cf496..0cdb4e1 100644 --- a/rollout/v1alpha1/rolloutrun_types.go +++ b/rollout/v1alpha1/rolloutrun_types.go @@ -70,6 +70,10 @@ type RolloutRunSpec struct { // Batch Strategy // +optional Batch *RolloutRunBatchStrategy `json:"batch,omitempty"` + + // Rollback Strategy + // +optional + Rollback *RolloutRunRollbackStrategy `json:"rollback,omitempty"` } type RolloutRunBatchStrategy struct { @@ -81,6 +85,11 @@ type RolloutRunBatchStrategy struct { Toleration *TolerationStrategy `json:"toleration,omitempty"` } +type RolloutRunRollbackStrategy struct { + // Batches define the order of phases to execute release in rollback release + Batches []RolloutRunRollbackStep `json:"batches,omitempty"` +} + type RolloutRunStep struct { // desired target replicas Targets []RolloutRunStepTarget `json:"targets"` @@ -98,6 +107,19 @@ type RolloutRunStep struct { Properties map[string]string `json:"properties,omitempty"` } +type RolloutRunRollbackStep struct { + // desired target replicas + Targets []RolloutRunStepTarget `json:"targets"` + + // If set to true, the rollout will be paused before the step starts. + // +optional + Breakpoint bool `json:"breakpoint,omitempty"` + + // Properties contains additional information for step. + // +optional + Properties map[string]string `json:"properties,omitempty"` +} + type RolloutRunCanaryStrategy struct { // desired target replicas Targets []RolloutRunStepTarget `json:"targets"` @@ -146,6 +168,9 @@ type RolloutRunStatus struct { // BatchStatus describes the state of the active batch release // +optional BatchStatus *RolloutRunBatchStatus `json:"batchStatus,omitempty"` + // RollbackStatus describes the state of the active rollback release + // +optional + RollbackStatus *RolloutRunBatchStatus `json:"rollbackStatus,omitempty"` // TargetStatuses describes the referenced workloads status // +optional TargetStatuses []RolloutWorkloadStatus `json:"targetStatuses,omitempty"` @@ -177,7 +202,11 @@ const ( RolloutRunPhaseCanceling RolloutRunPhase = "Canceling" // RolloutRunPhaseCanceled defines the phase of rolloutRun canceled RolloutRunPhaseCanceled RolloutRunPhase = "Canceled" - // RolloutRunPhaseFailed defines the phase of rolloutRun succeeded + // RolloutRunPhaseRollbacking defines the phase of rolloutRun rollbacking + RolloutRunPhaseRollbacking RolloutRunPhase = "Rollbacking" + // RolloutRunPhaseRollbacked defines the phase of rolloutRun rollbacked + RolloutRunPhaseRollbacked RolloutRunPhase = "Rollbacked" + // RolloutRunPhaseSucceeded defines the phase of rolloutRun succeeded RolloutRunPhaseSucceeded RolloutRunPhase = "Succeeded" ) @@ -226,5 +255,5 @@ func (r *RolloutRun) IsCompleted() bool { if r == nil { return false } - return r.Status.Phase == RolloutRunPhaseSucceeded || r.Status.Phase == RolloutRunPhaseCanceled + return r.Status.Phase == RolloutRunPhaseSucceeded || r.Status.Phase == RolloutRunPhaseCanceled || r.Status.Phase == RolloutRunPhaseRollbacked } diff --git a/rollout/v1alpha1/shared_types.go b/rollout/v1alpha1/shared_types.go index 2287739..6404340 100644 --- a/rollout/v1alpha1/shared_types.go +++ b/rollout/v1alpha1/shared_types.go @@ -109,6 +109,7 @@ type ProgressingInfo struct { RolloutID string `json:"rolloutID,omitempty"` Canary *CanaryProgressingInfo `json:"canary,omitempty"` Batch *BatchProgressingInfo `json:"batch,omitempty"` + Rollback *BatchProgressingInfo `json:"rollback,omitempty"` } type CanaryProgressingInfo struct{} diff --git a/rollout/v1alpha1/zz_generated.deepcopy.go b/rollout/v1alpha1/zz_generated.deepcopy.go index b0902a1..fffa942 100644 --- a/rollout/v1alpha1/zz_generated.deepcopy.go +++ b/rollout/v1alpha1/zz_generated.deepcopy.go @@ -799,6 +799,11 @@ func (in *ProgressingInfo) DeepCopyInto(out *ProgressingInfo) { *out = new(BatchProgressingInfo) **out = **in } + if in.Rollback != nil { + in, out := &in.Rollback, &out.Rollback + *out = new(BatchProgressingInfo) + **out = **in + } return } @@ -1084,6 +1089,59 @@ func (in *RolloutRunList) DeepCopyObject() runtime.Object { return nil } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RolloutRunRollbackStep) DeepCopyInto(out *RolloutRunRollbackStep) { + *out = *in + if in.Targets != nil { + in, out := &in.Targets, &out.Targets + *out = make([]RolloutRunStepTarget, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Properties != nil { + in, out := &in.Properties, &out.Properties + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RolloutRunRollbackStep. +func (in *RolloutRunRollbackStep) DeepCopy() *RolloutRunRollbackStep { + if in == nil { + return nil + } + out := new(RolloutRunRollbackStep) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RolloutRunRollbackStrategy) DeepCopyInto(out *RolloutRunRollbackStrategy) { + *out = *in + if in.Batches != nil { + in, out := &in.Batches, &out.Batches + *out = make([]RolloutRunRollbackStep, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RolloutRunRollbackStrategy. +func (in *RolloutRunRollbackStrategy) DeepCopy() *RolloutRunRollbackStrategy { + if in == nil { + return nil + } + out := new(RolloutRunRollbackStrategy) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *RolloutRunSpec) DeepCopyInto(out *RolloutRunSpec) { *out = *in @@ -1110,6 +1168,11 @@ func (in *RolloutRunSpec) DeepCopyInto(out *RolloutRunSpec) { *out = new(RolloutRunBatchStrategy) (*in).DeepCopyInto(*out) } + if in.Rollback != nil { + in, out := &in.Rollback, &out.Rollback + *out = new(RolloutRunRollbackStrategy) + (*in).DeepCopyInto(*out) + } return } @@ -1152,6 +1215,11 @@ func (in *RolloutRunStatus) DeepCopyInto(out *RolloutRunStatus) { *out = new(RolloutRunBatchStatus) (*in).DeepCopyInto(*out) } + if in.RollbackStatus != nil { + in, out := &in.RollbackStatus, &out.RollbackStatus + *out = new(RolloutRunBatchStatus) + (*in).DeepCopyInto(*out) + } if in.TargetStatuses != nil { in, out := &in.TargetStatuses, &out.TargetStatuses *out = make([]RolloutWorkloadStatus, len(*in)) @@ -1579,6 +1647,11 @@ func (in *RolloutWebhookReviewSpec) DeepCopyInto(out *RolloutWebhookReviewSpec) *out = new(RolloutWebhookReviewBatch) (*in).DeepCopyInto(*out) } + if in.Rollback != nil { + in, out := &in.Rollback, &out.Rollback + *out = new(RolloutWebhookReviewBatch) + (*in).DeepCopyInto(*out) + } return }