diff --git a/api/v1beta1/deployment_types.go b/api/v1beta1/deployment_types.go new file mode 100644 index 00000000..24406d8f --- /dev/null +++ b/api/v1beta1/deployment_types.go @@ -0,0 +1,87 @@ +package v1beta1 + +import ( + apps "k8s.io/api/apps/v1" + "k8s.io/apimachinery/pkg/util/intstr" +) + +const ( + // DeploymentStrategyAnnotation is annotation for deployment, + // which is strategy fields of Advanced Deployment. + DeploymentStrategyAnnotation = "rollouts.kruise.io/deployment-strategy" + + // DeploymentExtraStatusAnnotation is annotation for deployment, + // which is extra status field of Advanced Deployment. + DeploymentExtraStatusAnnotation = "rollouts.kruise.io/deployment-extra-status" + + // DeploymentStableRevisionLabel is label for deployment, + // which record the stable revision during the current rolling process. + DeploymentStableRevisionLabel = "rollouts.kruise.io/stable-revision" + + // AdvancedDeploymentControlLabel is label for deployment, + // which labels whether the deployment is controlled by advanced-deployment-controller. + AdvancedDeploymentControlLabel = "rollouts.kruise.io/controlled-by-advanced-deployment-controller" +) + +// DeploymentStrategy is strategy field for Advanced Deployment +type DeploymentStrategy struct { + // RollingStyle define the behavior of rolling for deployment. + RollingStyle RollingStyleType `json:"rollingStyle,omitempty"` + // original deployment strategy rolling update fields + RollingUpdate *apps.RollingUpdateDeployment `json:"rollingUpdate,omitempty"` + // Paused = true will block the upgrade of Pods + Paused bool `json:"paused,omitempty"` + // Partition describe how many Pods should be updated during rollout. + // We use this field to implement partition-style rolling update. + Partition intstr.IntOrString `json:"partition,omitempty"` +} + +type RollingStyleType string + +const ( + // PartitionRollingStyle means rolling in batches just like CloneSet, and will NOT create any extra Deployment; + PartitionRollingStyle RollingStyleType = "Partition" + // CanaryRollingStyle means rolling in canary way, and will create a canary Deployment. + CanaryRollingStyle RollingStyleType = "Canary" +) + +// DeploymentExtraStatus is extra status field for Advanced Deployment +type DeploymentExtraStatus struct { + // UpdatedReadyReplicas the number of pods that has been updated and ready. + UpdatedReadyReplicas int32 `json:"updatedReadyReplicas,omitempty"` + // ExpectedUpdatedReplicas is an absolute number calculated based on Partition + // and Deployment.Spec.Replicas, means how many pods are expected be updated under + // current strategy. + // This field is designed to avoid users to fall into the details of algorithm + // for Partition calculation. + ExpectedUpdatedReplicas int32 `json:"expectedUpdatedReplicas,omitempty"` +} + +func SetDefaultDeploymentStrategy(strategy *DeploymentStrategy) { + if strategy.RollingStyle == CanaryRollingStyle { + return + } + if strategy.RollingUpdate == nil { + strategy.RollingUpdate = &apps.RollingUpdateDeployment{} + } + if strategy.RollingUpdate.MaxUnavailable == nil { + // Set MaxUnavailable as 25% by default + maxUnavailable := intstr.FromString("25%") + strategy.RollingUpdate.MaxUnavailable = &maxUnavailable + } + if strategy.RollingUpdate.MaxSurge == nil { + // Set MaxSurge as 25% by default + maxSurge := intstr.FromString("25%") + strategy.RollingUpdate.MaxUnavailable = &maxSurge + } + + // Cannot allow maxSurge==0 && MaxUnavailable==0, otherwise, no pod can be updated when rolling update. + maxSurge, _ := intstr.GetScaledValueFromIntOrPercent(strategy.RollingUpdate.MaxSurge, 100, true) + maxUnavailable, _ := intstr.GetScaledValueFromIntOrPercent(strategy.RollingUpdate.MaxUnavailable, 100, true) + if maxSurge == 0 && maxUnavailable == 0 { + strategy.RollingUpdate = &apps.RollingUpdateDeployment{ + MaxSurge: &intstr.IntOrString{Type: intstr.Int, IntVal: 0}, + MaxUnavailable: &intstr.IntOrString{Type: intstr.Int, IntVal: 1}, + } + } +} diff --git a/api/v1beta1/groupversion_info.go b/api/v1beta1/groupversion_info.go index 85719539..ef22a32e 100644 --- a/api/v1beta1/groupversion_info.go +++ b/api/v1beta1/groupversion_info.go @@ -33,4 +33,6 @@ var ( // AddToScheme adds the types in this group-version to the given scheme. AddToScheme = SchemeBuilder.AddToScheme + + SchemeGroupVersion = GroupVersion ) diff --git a/api/v1beta1/zz_generated.deepcopy.go b/api/v1beta1/zz_generated.deepcopy.go index 3d59aa85..2bfbfbe1 100644 --- a/api/v1beta1/zz_generated.deepcopy.go +++ b/api/v1beta1/zz_generated.deepcopy.go @@ -22,6 +22,7 @@ limitations under the License. package v1beta1 import ( + "k8s.io/api/apps/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/intstr" "sigs.k8s.io/gateway-api/apis/v1alpha2" @@ -255,6 +256,42 @@ func (in *CanaryStrategy) DeepCopy() *CanaryStrategy { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DeploymentExtraStatus) DeepCopyInto(out *DeploymentExtraStatus) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeploymentExtraStatus. +func (in *DeploymentExtraStatus) DeepCopy() *DeploymentExtraStatus { + if in == nil { + return nil + } + out := new(DeploymentExtraStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DeploymentStrategy) DeepCopyInto(out *DeploymentStrategy) { + *out = *in + if in.RollingUpdate != nil { + in, out := &in.RollingUpdate, &out.RollingUpdate + *out = new(v1.RollingUpdateDeployment) + (*in).DeepCopyInto(*out) + } + out.Partition = in.Partition +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeploymentStrategy. +func (in *DeploymentStrategy) DeepCopy() *DeploymentStrategy { + if in == nil { + return nil + } + out := new(DeploymentStrategy) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *GatewayTrafficRouting) DeepCopyInto(out *GatewayTrafficRouting) { *out = *in diff --git a/config/crd/bases/rollouts.kruise.io_batchreleases.yaml b/config/crd/bases/rollouts.kruise.io_batchreleases.yaml index 81561591..89cd6311 100644 --- a/config/crd/bases/rollouts.kruise.io_batchreleases.yaml +++ b/config/crd/bases/rollouts.kruise.io_batchreleases.yaml @@ -270,7 +270,7 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} - additionalPrinterColumns: @@ -527,7 +527,7 @@ spec: type: object type: object served: true - storage: false + storage: true subresources: status: {} status: diff --git a/config/crd/bases/rollouts.kruise.io_rollouthistories.yaml b/config/crd/bases/rollouts.kruise.io_rollouthistories.yaml index a3741c6f..e7fc14de 100644 --- a/config/crd/bases/rollouts.kruise.io_rollouthistories.yaml +++ b/config/crd/bases/rollouts.kruise.io_rollouthistories.yaml @@ -165,7 +165,7 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} - name: v1beta1 @@ -317,7 +317,7 @@ spec: type: object type: object served: true - storage: false + storage: true subresources: status: {} status: diff --git a/config/crd/bases/rollouts.kruise.io_rollouts.yaml b/config/crd/bases/rollouts.kruise.io_rollouts.yaml index 5e2730c1..1de96ead 100644 --- a/config/crd/bases/rollouts.kruise.io_rollouts.yaml +++ b/config/crd/bases/rollouts.kruise.io_rollouts.yaml @@ -502,7 +502,7 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} - additionalPrinterColumns: @@ -991,7 +991,7 @@ spec: type: object type: object served: true - storage: false + storage: true subresources: status: {} status: diff --git a/config/crd/bases/rollouts.kruise.io_trafficroutings.yaml b/config/crd/bases/rollouts.kruise.io_trafficroutings.yaml index b988e534..e72077b2 100644 --- a/config/crd/bases/rollouts.kruise.io_trafficroutings.yaml +++ b/config/crd/bases/rollouts.kruise.io_trafficroutings.yaml @@ -289,7 +289,7 @@ spec: type: object type: object served: true - storage: true + storage: false subresources: status: {} - additionalPrinterColumns: @@ -565,7 +565,7 @@ spec: type: object type: object served: true - storage: false + storage: true subresources: status: {} status: diff --git a/config/crd/kustomization.yaml b/config/crd/kustomization.yaml index 8a481017..269605db 100644 --- a/config/crd/kustomization.yaml +++ b/config/crd/kustomization.yaml @@ -12,9 +12,9 @@ patchesStrategicMerge: # [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix. # patches here are for enabling the conversion webhook for each CRD - patches/webhook_in_rollouts.yaml -#- patches/webhook_in_batchreleases.yaml -#- patches/webhook_in_trafficroutings.yaml -#- patches/webhook_in_rollouthistories.yaml +- patches/webhook_in_batchreleases.yaml +- patches/webhook_in_trafficroutings.yaml +- patches/webhook_in_rollouthistories.yaml #+kubebuilder:scaffold:crdkustomizewebhookpatch # [CERTMANAGER] To enable webhook, uncomment all the sections with [CERTMANAGER] prefix. diff --git a/config/webhook/manifests.yaml b/config/webhook/manifests.yaml index 1c74221c..bac8bdd2 100644 --- a/config/webhook/manifests.yaml +++ b/config/webhook/manifests.yaml @@ -151,6 +151,7 @@ webhooks: - apiGroups: - rollouts.kruise.io apiVersions: + - v1beta1 - v1alpha1 operations: - CREATE diff --git a/pkg/controller/batchrelease/batchrelease_controller.go b/pkg/controller/batchrelease/batchrelease_controller.go index 304b4c9b..a2f5caee 100644 --- a/pkg/controller/batchrelease/batchrelease_controller.go +++ b/pkg/controller/batchrelease/batchrelease_controller.go @@ -24,7 +24,7 @@ import ( "sync" "time" - "github.com/openkruise/rollouts/api/v1alpha1" + "github.com/openkruise/rollouts/api/v1beta1" "github.com/openkruise/rollouts/pkg/util" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" @@ -94,10 +94,10 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error { } // Watch for changes to BatchRelease - err = c.Watch(&source.Kind{Type: &v1alpha1.BatchRelease{}}, &handler.EnqueueRequestForObject{}, predicate.Funcs{ + err = c.Watch(&source.Kind{Type: &v1beta1.BatchRelease{}}, &handler.EnqueueRequestForObject{}, predicate.Funcs{ UpdateFunc: func(e event.UpdateEvent) bool { - oldObject := e.ObjectOld.(*v1alpha1.BatchRelease) - newObject := e.ObjectNew.(*v1alpha1.BatchRelease) + oldObject := e.ObjectOld.(*v1beta1.BatchRelease) + newObject := e.ObjectNew.(*v1beta1.BatchRelease) if oldObject.Generation != newObject.Generation || newObject.DeletionTimestamp != nil { klog.V(3).Infof("Observed updated Spec for BatchRelease: %s/%s", newObject.Namespace, newObject.Name) return true @@ -152,7 +152,7 @@ type BatchReleaseReconciler struct { // Reconcile reads that state of the cluster for a Rollout object and makes changes based on the state read // and what is in the Rollout.Spec func (r *BatchReleaseReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { - release := new(v1alpha1.BatchRelease) + release := new(v1beta1.BatchRelease) err := r.Get(context.TODO(), req.NamespacedName, release) if err != nil { if errors.IsNotFound(err) { @@ -216,7 +216,7 @@ func (r *BatchReleaseReconciler) Reconcile(ctx context.Context, req ctrl.Request } // updateStatus update BatchRelease status to newStatus -func (r *BatchReleaseReconciler) updateStatus(release *v1alpha1.BatchRelease, newStatus *v1alpha1.BatchReleaseStatus) error { +func (r *BatchReleaseReconciler) updateStatus(release *v1beta1.BatchRelease, newStatus *v1beta1.BatchReleaseStatus) error { var err error defer func() { if err != nil { @@ -234,7 +234,7 @@ func (r *BatchReleaseReconciler) updateStatus(release *v1alpha1.BatchRelease, ne objectKey := client.ObjectKeyFromObject(release) if !reflect.DeepEqual(release.Status, *newStatus) { err = retry.RetryOnConflict(retry.DefaultBackoff, func() error { - clone := &v1alpha1.BatchRelease{} + clone := &v1beta1.BatchRelease{} getErr := r.Get(context.TODO(), objectKey, clone) if getErr != nil { return getErr @@ -247,7 +247,7 @@ func (r *BatchReleaseReconciler) updateStatus(release *v1alpha1.BatchRelease, ne } // handleFinalizer will remove finalizer in finalized phase and add finalizer in the other phases. -func (r *BatchReleaseReconciler) handleFinalizer(release *v1alpha1.BatchRelease) (bool, error) { +func (r *BatchReleaseReconciler) handleFinalizer(release *v1beta1.BatchRelease) (bool, error) { var err error defer func() { if err != nil { @@ -257,7 +257,7 @@ func (r *BatchReleaseReconciler) handleFinalizer(release *v1alpha1.BatchRelease) // remove the release finalizer if it needs if !release.DeletionTimestamp.IsZero() && - release.Status.Phase == v1alpha1.RolloutPhaseCompleted && + release.Status.Phase == v1beta1.RolloutPhaseCompleted && controllerutil.ContainsFinalizer(release, ReleaseFinalizer) { err = util.UpdateFinalizer(r.Client, release, util.RemoveFinalizerOpType, ReleaseFinalizer) if client.IgnoreNotFound(err) != nil { diff --git a/pkg/controller/batchrelease/batchrelease_controller_test.go b/pkg/controller/batchrelease/batchrelease_controller_test.go index e6045562..4a1e2998 100644 --- a/pkg/controller/batchrelease/batchrelease_controller_test.go +++ b/pkg/controller/batchrelease/batchrelease_controller_test.go @@ -27,7 +27,7 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" kruiseappsv1alpha1 "github.com/openkruise/kruise-api/apps/v1alpha1" - "github.com/openkruise/rollouts/api/v1alpha1" + "github.com/openkruise/rollouts/api/v1beta1" "github.com/openkruise/rollouts/pkg/util" apps "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" @@ -49,9 +49,9 @@ const TIME_LAYOUT = "2006-01-02 15:04:05" var ( scheme *runtime.Scheme - releaseDeploy = &v1alpha1.BatchRelease{ + releaseDeploy = &v1beta1.BatchRelease{ TypeMeta: metav1.TypeMeta{ - APIVersion: v1alpha1.GroupVersion.String(), + APIVersion: v1beta1.GroupVersion.String(), Kind: "BatchRelease", }, ObjectMeta: metav1.ObjectMeta{ @@ -59,17 +59,17 @@ var ( Namespace: "application", UID: types.UID("87076677"), }, - Spec: v1alpha1.BatchReleaseSpec{ - TargetRef: v1alpha1.ObjectRef{ - WorkloadRef: &v1alpha1.WorkloadRef{ + Spec: v1beta1.BatchReleaseSpec{ + TargetRef: v1beta1.ObjectRef{ + WorkloadRef: &v1beta1.WorkloadRef{ APIVersion: "apps/v1", Kind: "Deployment", Name: "sample", }, }, - ReleasePlan: v1alpha1.ReleasePlan{ + ReleasePlan: v1beta1.ReleasePlan{ BatchPartition: pointer.Int32(0), - Batches: []v1alpha1.ReleaseBatch{ + Batches: []v1beta1.ReleaseBatch{ { CanaryReplicas: intstr.FromString("10%"), }, @@ -129,9 +129,9 @@ var ( ) var ( - releaseClone = &v1alpha1.BatchRelease{ + releaseClone = &v1beta1.BatchRelease{ TypeMeta: metav1.TypeMeta{ - APIVersion: v1alpha1.GroupVersion.String(), + APIVersion: v1beta1.GroupVersion.String(), Kind: "BatchRelease", }, ObjectMeta: metav1.ObjectMeta{ @@ -139,17 +139,17 @@ var ( Namespace: "application", UID: types.UID("87076677"), }, - Spec: v1alpha1.BatchReleaseSpec{ - TargetRef: v1alpha1.ObjectRef{ - WorkloadRef: &v1alpha1.WorkloadRef{ + Spec: v1beta1.BatchReleaseSpec{ + TargetRef: v1beta1.ObjectRef{ + WorkloadRef: &v1beta1.WorkloadRef{ APIVersion: "apps.kruise.io/v1alpha1", Kind: "CloneSet", Name: "sample", }, }, - ReleasePlan: v1alpha1.ReleasePlan{ + ReleasePlan: v1beta1.ReleasePlan{ BatchPartition: pointer.Int32Ptr(0), - Batches: []v1alpha1.ReleaseBatch{ + Batches: []v1beta1.ReleaseBatch{ { CanaryReplicas: intstr.FromString("10%"), }, @@ -209,7 +209,7 @@ var ( func init() { scheme = runtime.NewScheme() apimachineryruntime.Must(apps.AddToScheme(scheme)) - apimachineryruntime.Must(v1alpha1.AddToScheme(scheme)) + apimachineryruntime.Must(v1beta1.AddToScheme(scheme)) apimachineryruntime.Must(kruiseappsv1alpha1.AddToScheme(scheme)) controlInfo, _ := json.Marshal(metav1.NewControllerRef(releaseDeploy, releaseDeploy.GroupVersionKind())) @@ -232,13 +232,13 @@ func TestReconcile_CloneSet(t *testing.T) { GetRelease func() client.Object GetCloneSet func() []client.Object ExpectedBatch int32 - ExpectedPhase v1alpha1.RolloutPhase - ExpectedState v1alpha1.BatchReleaseBatchStateType + ExpectedPhase v1beta1.RolloutPhase + ExpectedState v1beta1.BatchReleaseBatchStateType }{ { Name: "Preparing, Input-Phase=Preparing, Output-Phase=Progressing", GetRelease: func() client.Object { - release := setPhase(releaseClone, v1alpha1.RolloutPhasePreparing) + release := setPhase(releaseClone, v1beta1.RolloutPhasePreparing) stableTemplate := stableClone.Spec.Template.DeepCopy() canaryTemplate := stableClone.Spec.Template.DeepCopy() stableTemplate.Spec.Containers = containers("v1") @@ -254,12 +254,12 @@ func TestReconcile_CloneSet(t *testing.T) { canary, } }, - ExpectedPhase: v1alpha1.RolloutPhaseProgressing, + ExpectedPhase: v1beta1.RolloutPhaseProgressing, }, { Name: "Progressing, stage=0, Input-State=Upgrade, Output-State=Verify", GetRelease: func() client.Object { - release := setState(releaseClone, v1alpha1.UpgradingBatchState) + release := setState(releaseClone, v1beta1.UpgradingBatchState) stableTemplate := stableClone.Spec.Template.DeepCopy() canaryTemplate := stableClone.Spec.Template.DeepCopy() stableTemplate.Spec.Containers = containers("v1") @@ -275,13 +275,13 @@ func TestReconcile_CloneSet(t *testing.T) { canary, } }, - ExpectedPhase: v1alpha1.RolloutPhaseProgressing, - ExpectedState: v1alpha1.VerifyingBatchState, + ExpectedPhase: v1beta1.RolloutPhaseProgressing, + ExpectedState: v1beta1.VerifyingBatchState, }, { Name: "Progressing, stage=0, Input-State=Upgrade, Output-State=Verify", GetRelease: func() client.Object { - release := setState(releaseClone, v1alpha1.UpgradingBatchState) + release := setState(releaseClone, v1beta1.UpgradingBatchState) stableTemplate := stableClone.Spec.Template.DeepCopy() canaryTemplate := stableClone.Spec.Template.DeepCopy() stableTemplate.Spec.Containers = containers("v1") @@ -297,13 +297,13 @@ func TestReconcile_CloneSet(t *testing.T) { canary, } }, - ExpectedPhase: v1alpha1.RolloutPhaseProgressing, - ExpectedState: v1alpha1.VerifyingBatchState, + ExpectedPhase: v1beta1.RolloutPhaseProgressing, + ExpectedState: v1beta1.VerifyingBatchState, }, { Name: "Progressing, stage=0, Input-State=Verify, Output-State=BatchReady", GetRelease: func() client.Object { - release := setState(releaseClone, v1alpha1.VerifyingBatchState) + release := setState(releaseClone, v1beta1.VerifyingBatchState) stableTemplate := stableClone.Spec.Template.DeepCopy() canaryTemplate := stableClone.Spec.Template.DeepCopy() stableTemplate.Spec.Containers = containers("v1") @@ -321,13 +321,13 @@ func TestReconcile_CloneSet(t *testing.T) { canary, } }, - ExpectedPhase: v1alpha1.RolloutPhaseProgressing, - ExpectedState: v1alpha1.ReadyBatchState, + ExpectedPhase: v1beta1.RolloutPhaseProgressing, + ExpectedState: v1beta1.ReadyBatchState, }, { Name: "Progressing, stage=0->1, Input-State=BatchReady, Output-State=Upgrade", GetRelease: func() client.Object { - release := setState(releaseClone, v1alpha1.ReadyBatchState) + release := setState(releaseClone, v1beta1.ReadyBatchState) release.Status.CanaryStatus.BatchReadyTime = getOldTime() stableTemplate := stableClone.Spec.Template.DeepCopy() canaryTemplate := stableClone.Spec.Template.DeepCopy() @@ -347,14 +347,14 @@ func TestReconcile_CloneSet(t *testing.T) { canary, } }, - ExpectedPhase: v1alpha1.RolloutPhaseProgressing, - ExpectedState: v1alpha1.UpgradingBatchState, + ExpectedPhase: v1beta1.RolloutPhaseProgressing, + ExpectedState: v1beta1.UpgradingBatchState, ExpectedBatch: 1, }, { Name: "Progressing, stage=0->1, Input-State=BatchReady, Output-State=BatchReady", GetRelease: func() client.Object { - release := setState(releaseClone, v1alpha1.ReadyBatchState) + release := setState(releaseClone, v1beta1.ReadyBatchState) now := metav1.Now() release.Status.CanaryStatus.BatchReadyTime = &now stableTemplate := stableClone.Spec.Template.DeepCopy() @@ -374,13 +374,13 @@ func TestReconcile_CloneSet(t *testing.T) { canary, } }, - ExpectedPhase: v1alpha1.RolloutPhaseProgressing, - ExpectedState: v1alpha1.ReadyBatchState, + ExpectedPhase: v1beta1.RolloutPhaseProgressing, + ExpectedState: v1beta1.ReadyBatchState, }, { Name: "Special Case: Scaling, Input-State=BatchReady, Output-State=Upgrade", GetRelease: func() client.Object { - release := setState(releaseClone, v1alpha1.ReadyBatchState) + release := setState(releaseClone, v1beta1.ReadyBatchState) now := metav1.Now() release.Status.CanaryStatus.BatchReadyTime = &now stableTemplate := stableClone.Spec.Template.DeepCopy() @@ -401,13 +401,13 @@ func TestReconcile_CloneSet(t *testing.T) { canary, } }, - ExpectedPhase: v1alpha1.RolloutPhaseProgressing, - ExpectedState: v1alpha1.UpgradingBatchState, + ExpectedPhase: v1beta1.RolloutPhaseProgressing, + ExpectedState: v1beta1.UpgradingBatchState, }, { Name: `Special Case: RollBack, Input-Phase=Progressing, Output-Phase=Progressing`, GetRelease: func() client.Object { - release := setState(releaseClone, v1alpha1.ReadyBatchState) + release := setState(releaseClone, v1beta1.ReadyBatchState) now := metav1.Now() release.Status.CanaryStatus.BatchReadyTime = &now stableTemplate := stableClone.Spec.Template.DeepCopy() @@ -431,13 +431,13 @@ func TestReconcile_CloneSet(t *testing.T) { canary, } }, - ExpectedPhase: v1alpha1.RolloutPhaseProgressing, - ExpectedState: v1alpha1.ReadyBatchState, + ExpectedPhase: v1beta1.RolloutPhaseProgressing, + ExpectedState: v1beta1.ReadyBatchState, }, { Name: `Special Case: Deletion, Input-Phase=Progressing, Output-Phase=Finalizing`, GetRelease: func() client.Object { - release := setState(releaseClone, v1alpha1.ReadyBatchState) + release := setState(releaseClone, v1beta1.ReadyBatchState) now := metav1.Now() release.Status.CanaryStatus.BatchReadyTime = &now stableTemplate := stableClone.Spec.Template.DeepCopy() @@ -459,13 +459,13 @@ func TestReconcile_CloneSet(t *testing.T) { canary, } }, - ExpectedPhase: v1alpha1.RolloutPhaseFinalizing, - ExpectedState: v1alpha1.ReadyBatchState, + ExpectedPhase: v1beta1.RolloutPhaseFinalizing, + ExpectedState: v1beta1.ReadyBatchState, }, { Name: `Special Case: Continuous Release, Input-Phase=Progressing, Output-Phase=Progressing`, GetRelease: func() client.Object { - release := setState(releaseClone, v1alpha1.ReadyBatchState) + release := setState(releaseClone, v1beta1.ReadyBatchState) now := metav1.Now() release.Status.CanaryStatus.BatchReadyTime = &now stableTemplate := stableClone.Spec.Template.DeepCopy() @@ -493,13 +493,13 @@ func TestReconcile_CloneSet(t *testing.T) { canary, } }, - ExpectedPhase: v1alpha1.RolloutPhaseProgressing, - ExpectedState: v1alpha1.ReadyBatchState, + ExpectedPhase: v1beta1.RolloutPhaseProgressing, + ExpectedState: v1beta1.ReadyBatchState, }, { Name: `Special Case: BatchPartition=nil, Input-Phase=Progressing, Output-Phase=Finalizing`, GetRelease: func() client.Object { - release := setState(releaseClone, v1alpha1.ReadyBatchState) + release := setState(releaseClone, v1beta1.ReadyBatchState) now := metav1.Now() release.Status.CanaryStatus.BatchReadyTime = &now stableTemplate := stableClone.Spec.Template.DeepCopy() @@ -521,8 +521,8 @@ func TestReconcile_CloneSet(t *testing.T) { canary, } }, - ExpectedPhase: v1alpha1.RolloutPhaseFinalizing, - ExpectedState: v1alpha1.ReadyBatchState, + ExpectedPhase: v1beta1.RolloutPhaseFinalizing, + ExpectedState: v1beta1.ReadyBatchState, }, } @@ -545,7 +545,7 @@ func TestReconcile_CloneSet(t *testing.T) { Expect(err).NotTo(HaveOccurred()) Expect(result.RequeueAfter).Should(BeNumerically(">=", int64(0))) - newRelease := v1alpha1.BatchRelease{} + newRelease := v1beta1.BatchRelease{} err = cli.Get(context.TODO(), key, &newRelease) Expect(err).NotTo(HaveOccurred()) Expect(newRelease.Status.Phase).Should(Equal(cs.ExpectedPhase)) @@ -563,14 +563,14 @@ func TestReconcile_Deployment(t *testing.T) { GetRelease func() client.Object GetDeployments func() []client.Object ExpectedBatch int32 - ExpectedPhase v1alpha1.RolloutPhase - ExpectedState v1alpha1.BatchReleaseBatchStateType + ExpectedPhase v1beta1.RolloutPhase + ExpectedState v1beta1.BatchReleaseBatchStateType }{ // Following cases of Linear Transaction on State Machine { Name: "IfNeedProgress=true, Input-Phase=Healthy, Output-Phase=Progressing", GetRelease: func() client.Object { - return setPhase(releaseDeploy, v1alpha1.RolloutPhaseHealthy) + return setPhase(releaseDeploy, v1beta1.RolloutPhaseHealthy) }, GetDeployments: func() []client.Object { stable := getStableWithReady(stableDeploy, "v2").(*apps.Deployment) @@ -579,12 +579,12 @@ func TestReconcile_Deployment(t *testing.T) { stable, canary, } }, - ExpectedPhase: v1alpha1.RolloutPhaseProgressing, + ExpectedPhase: v1beta1.RolloutPhaseProgressing, }, { Name: "Preparing, Input-Phase=Preparing, Output-Phase=Progressing", GetRelease: func() client.Object { - return setPhase(releaseDeploy, v1alpha1.RolloutPhasePreparing) + return setPhase(releaseDeploy, v1beta1.RolloutPhasePreparing) }, GetDeployments: func() []client.Object { stable := getStableWithReady(stableDeploy, "v2") @@ -593,12 +593,12 @@ func TestReconcile_Deployment(t *testing.T) { stable, canary, } }, - ExpectedPhase: v1alpha1.RolloutPhaseProgressing, + ExpectedPhase: v1beta1.RolloutPhaseProgressing, }, { Name: "Progressing, stage=0, Input-State=Upgrade, Output-State=Verify", GetRelease: func() client.Object { - return setState(releaseDeploy, v1alpha1.UpgradingBatchState) + return setState(releaseDeploy, v1beta1.UpgradingBatchState) }, GetDeployments: func() []client.Object { stable := getStableWithReady(stableDeploy, "v2") @@ -607,8 +607,8 @@ func TestReconcile_Deployment(t *testing.T) { stable, canary, } }, - ExpectedPhase: v1alpha1.RolloutPhaseProgressing, - ExpectedState: v1alpha1.VerifyingBatchState, + ExpectedPhase: v1beta1.RolloutPhaseProgressing, + ExpectedState: v1beta1.VerifyingBatchState, }, { Name: "Progressing, stage=0, Input-State=Verify, Output-State=Upgrade", @@ -616,7 +616,7 @@ func TestReconcile_Deployment(t *testing.T) { release := releaseDeploy.DeepCopy() release.Status.CanaryStatus.UpdatedReplicas = 5 release.Status.CanaryStatus.UpdatedReadyReplicas = 5 - return setState(release, v1alpha1.VerifyingBatchState) + return setState(release, v1beta1.VerifyingBatchState) }, GetDeployments: func() []client.Object { stable := getStableWithReady(stableDeploy, "v2") @@ -625,8 +625,8 @@ func TestReconcile_Deployment(t *testing.T) { stable, canary, } }, - ExpectedPhase: v1alpha1.RolloutPhaseProgressing, - ExpectedState: v1alpha1.UpgradingBatchState, + ExpectedPhase: v1beta1.RolloutPhaseProgressing, + ExpectedState: v1beta1.UpgradingBatchState, }, { Name: "Progressing, stage=0, Input-State=Verify, Output-State=BatchReady", @@ -634,7 +634,7 @@ func TestReconcile_Deployment(t *testing.T) { release := releaseDeploy.DeepCopy() release.Status.CanaryStatus.UpdatedReplicas = 10 release.Status.CanaryStatus.UpdatedReadyReplicas = 10 - return setState(release, v1alpha1.VerifyingBatchState) + return setState(release, v1beta1.VerifyingBatchState) }, GetDeployments: func() []client.Object { stable := getStableWithReady(stableDeploy, "v2") @@ -643,8 +643,8 @@ func TestReconcile_Deployment(t *testing.T) { stable, canary, } }, - ExpectedPhase: v1alpha1.RolloutPhaseProgressing, - ExpectedState: v1alpha1.ReadyBatchState, + ExpectedPhase: v1beta1.RolloutPhaseProgressing, + ExpectedState: v1beta1.ReadyBatchState, }, { Name: "Progressing, stage=0->1, Input-State=BatchReady, Output-State=Upgrade", @@ -653,7 +653,7 @@ func TestReconcile_Deployment(t *testing.T) { release.Status.CanaryStatus.UpdatedReplicas = 10 release.Status.CanaryStatus.UpdatedReadyReplicas = 10 release.Spec.ReleasePlan.BatchPartition = pointer.Int32Ptr(1) - return setState(release, v1alpha1.ReadyBatchState) + return setState(release, v1beta1.ReadyBatchState) }, GetDeployments: func() []client.Object { stable := getStableWithReady(stableDeploy, "v2") @@ -662,8 +662,8 @@ func TestReconcile_Deployment(t *testing.T) { stable, canary, } }, - ExpectedPhase: v1alpha1.RolloutPhaseProgressing, - ExpectedState: v1alpha1.UpgradingBatchState, + ExpectedPhase: v1beta1.RolloutPhaseProgressing, + ExpectedState: v1beta1.UpgradingBatchState, ExpectedBatch: 1, }, { @@ -672,7 +672,7 @@ func TestReconcile_Deployment(t *testing.T) { release := releaseDeploy.DeepCopy() release.Status.CanaryStatus.UpdatedReplicas = 10 release.Status.CanaryStatus.UpdatedReadyReplicas = 10 - release = setState(release, v1alpha1.ReadyBatchState) + release = setState(release, v1beta1.ReadyBatchState) return release }, GetDeployments: func() []client.Object { @@ -682,13 +682,13 @@ func TestReconcile_Deployment(t *testing.T) { stable, canary, } }, - ExpectedPhase: v1alpha1.RolloutPhaseProgressing, - ExpectedState: v1alpha1.ReadyBatchState, + ExpectedPhase: v1beta1.RolloutPhaseProgressing, + ExpectedState: v1beta1.ReadyBatchState, }, { Name: "Special Case: Scaling, Input-State=BatchReady, Output-State=Upgrade", GetRelease: func() client.Object { - release := setState(releaseDeploy, v1alpha1.ReadyBatchState) + release := setState(releaseDeploy, v1beta1.ReadyBatchState) now := metav1.Now() release.Status.CanaryStatus.BatchReadyTime = &now return release @@ -701,13 +701,13 @@ func TestReconcile_Deployment(t *testing.T) { stable, canary, } }, - ExpectedPhase: v1alpha1.RolloutPhaseProgressing, - ExpectedState: v1alpha1.UpgradingBatchState, + ExpectedPhase: v1beta1.RolloutPhaseProgressing, + ExpectedState: v1beta1.UpgradingBatchState, }, { Name: `Special Case: RollBack, Input-Phase=Progressing, Output-Phase=Progressing`, GetRelease: func() client.Object { - release := setState(releaseDeploy, v1alpha1.ReadyBatchState) + release := setState(releaseDeploy, v1beta1.ReadyBatchState) now := metav1.Now() release.Status.CanaryStatus.BatchReadyTime = &now stableTemplate := stableDeploy.Spec.Template.DeepCopy() @@ -725,13 +725,13 @@ func TestReconcile_Deployment(t *testing.T) { stable, canary, } }, - ExpectedPhase: v1alpha1.RolloutPhaseProgressing, - ExpectedState: v1alpha1.ReadyBatchState, + ExpectedPhase: v1beta1.RolloutPhaseProgressing, + ExpectedState: v1beta1.ReadyBatchState, }, { Name: `Special Case: Deletion, Input-Phase=Progressing, Output-Phase=Finalizing`, GetRelease: func() client.Object { - release := setState(releaseDeploy, v1alpha1.ReadyBatchState) + release := setState(releaseDeploy, v1beta1.ReadyBatchState) now := metav1.Now() release.Status.CanaryStatus.BatchReadyTime = &now stableTemplate := stableDeploy.Spec.Template.DeepCopy() @@ -751,13 +751,13 @@ func TestReconcile_Deployment(t *testing.T) { stable, canary, } }, - ExpectedPhase: v1alpha1.RolloutPhaseFinalizing, - ExpectedState: v1alpha1.ReadyBatchState, + ExpectedPhase: v1beta1.RolloutPhaseFinalizing, + ExpectedState: v1beta1.ReadyBatchState, }, { Name: `Special Case: Continuous Release, Input-Phase=Progressing, Output-Phase=Progressing`, GetRelease: func() client.Object { - release := setState(releaseDeploy, v1alpha1.ReadyBatchState) + release := setState(releaseDeploy, v1beta1.ReadyBatchState) now := metav1.Now() release.Status.CanaryStatus.BatchReadyTime = &now stableTemplate := stableDeploy.Spec.Template.DeepCopy() @@ -775,8 +775,8 @@ func TestReconcile_Deployment(t *testing.T) { stable, canary, } }, - ExpectedState: v1alpha1.ReadyBatchState, - ExpectedPhase: v1alpha1.RolloutPhaseProgressing, + ExpectedState: v1beta1.ReadyBatchState, + ExpectedPhase: v1beta1.RolloutPhaseProgressing, }, } @@ -808,7 +808,7 @@ func TestReconcile_Deployment(t *testing.T) { result, _ := reconciler.Reconcile(context.TODO(), request) Expect(result.RequeueAfter).Should(BeNumerically(">=", int64(0))) - newRelease := v1alpha1.BatchRelease{} + newRelease := v1beta1.BatchRelease{} err := cli.Get(context.TODO(), key, &newRelease) Expect(err).NotTo(HaveOccurred()) Expect(newRelease.Status.Phase).Should(Equal(cs.ExpectedPhase)) @@ -827,7 +827,7 @@ func containers(version string) []corev1.Container { } } -func setPhase(release *v1alpha1.BatchRelease, phase v1alpha1.RolloutPhase) *v1alpha1.BatchRelease { +func setPhase(release *v1beta1.BatchRelease, phase v1beta1.RolloutPhase) *v1beta1.BatchRelease { r := release.DeepCopy() r.Status.Phase = phase r.Status.ObservedWorkloadReplicas = 100 @@ -835,9 +835,9 @@ func setPhase(release *v1alpha1.BatchRelease, phase v1alpha1.RolloutPhase) *v1al return r } -func setState(release *v1alpha1.BatchRelease, state v1alpha1.BatchReleaseBatchStateType) *v1alpha1.BatchRelease { +func setState(release *v1beta1.BatchRelease, state v1beta1.BatchReleaseBatchStateType) *v1beta1.BatchRelease { r := release.DeepCopy() - r.Status.Phase = v1alpha1.RolloutPhaseProgressing + r.Status.Phase = v1beta1.RolloutPhaseProgressing r.Status.CanaryStatus.CurrentBatchState = state r.Status.ObservedWorkloadReplicas = 100 r.Status.ObservedReleasePlanHash = util.HashReleasePlanBatches(&release.Spec.ReleasePlan) diff --git a/pkg/controller/batchrelease/batchrelease_event_handler.go b/pkg/controller/batchrelease/batchrelease_event_handler.go index 7be717c9..63304782 100644 --- a/pkg/controller/batchrelease/batchrelease_event_handler.go +++ b/pkg/controller/batchrelease/batchrelease_event_handler.go @@ -23,7 +23,7 @@ import ( kruiseappsv1alpha1 "github.com/openkruise/kruise-api/apps/v1alpha1" kruiseappsv1beta1 "github.com/openkruise/kruise-api/apps/v1beta1" - "github.com/openkruise/rollouts/api/v1alpha1" + "github.com/openkruise/rollouts/api/v1beta1" "github.com/openkruise/rollouts/pkg/util" utilclient "github.com/openkruise/rollouts/pkg/util/client" expectations "github.com/openkruise/rollouts/pkg/util/expectation" @@ -224,14 +224,14 @@ func getBatchRelease(c client.Reader, workloadNamespaceName types.NamespacedName klog.Errorf("Failed to unmarshal controller info annotations for %v(%v)", gvk, workloadNamespaceName) } - if br.APIVersion == v1alpha1.GroupVersion.String() && br.Kind == "BatchRelease" { + if br.APIVersion == v1beta1.GroupVersion.String() && br.Kind == "BatchRelease" { klog.V(3).Infof("%s (%v) is managed by BatchRelease (%s), append queue and will reconcile BatchRelease", gvk.Kind, workloadNamespaceName, br.Name) nsn = types.NamespacedName{Namespace: workloadNamespaceName.Namespace, Name: br.Name} return } } - brList := &v1alpha1.BatchReleaseList{} + brList := &v1beta1.BatchReleaseList{} namespace := workloadNamespaceName.Namespace if err = c.List(context.TODO(), brList, client.InNamespace(namespace), utilclient.DisableDeepCopy); err != nil { klog.Errorf("List BatchRelease failed: %s", err.Error()) @@ -269,7 +269,7 @@ func getControllerKey(object client.Object) *string { if owner == nil { return nil } - if owner.APIVersion == v1alpha1.GroupVersion.String() { + if owner.APIVersion == v1beta1.GroupVersion.String() { key := types.NamespacedName{Namespace: object.GetNamespace(), Name: owner.Name}.String() return &key } diff --git a/pkg/controller/batchrelease/batchrelease_event_handler_test.go b/pkg/controller/batchrelease/batchrelease_event_handler_test.go index 3e81e86e..886ce7db 100644 --- a/pkg/controller/batchrelease/batchrelease_event_handler_test.go +++ b/pkg/controller/batchrelease/batchrelease_event_handler_test.go @@ -23,7 +23,7 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "github.com/openkruise/rollouts/api/v1alpha1" + "github.com/openkruise/rollouts/api/v1beta1" "github.com/openkruise/rollouts/pkg/util" apps "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" @@ -172,7 +172,7 @@ func TestWorkloadEventHandler_Create(t *testing.T) { GetNewWorkload: func() client.Object { object := getStableWithReady(stableDeploy, "v2").(*apps.Deployment) controlInfo, _ := json.Marshal(&metav1.OwnerReference{ - APIVersion: v1alpha1.GroupVersion.String(), + APIVersion: v1beta1.GroupVersion.String(), Kind: "Rollout", Name: "whatever", }) @@ -228,7 +228,7 @@ func TestWorkloadEventHandler_Delete(t *testing.T) { GetNewWorkload: func() client.Object { object := getStableWithReady(stableDeploy, "v2").(*apps.Deployment) controlInfo, _ := json.Marshal(&metav1.OwnerReference{ - APIVersion: v1alpha1.GroupVersion.String(), + APIVersion: v1beta1.GroupVersion.String(), Kind: "Rollout", Name: "whatever", }) diff --git a/pkg/controller/batchrelease/batchrelease_executor.go b/pkg/controller/batchrelease/batchrelease_executor.go index 7cb0b86f..0ac15755 100644 --- a/pkg/controller/batchrelease/batchrelease_executor.go +++ b/pkg/controller/batchrelease/batchrelease_executor.go @@ -23,7 +23,7 @@ import ( "time" appsv1alpha1 "github.com/openkruise/kruise-api/apps/v1alpha1" - "github.com/openkruise/rollouts/api/v1alpha1" + "github.com/openkruise/rollouts/api/v1beta1" "github.com/openkruise/rollouts/pkg/controller/batchrelease/control" "github.com/openkruise/rollouts/pkg/controller/batchrelease/control/canarystyle" canarydeployment "github.com/openkruise/rollouts/pkg/controller/batchrelease/control/canarystyle/deployment" @@ -63,7 +63,7 @@ func NewReleasePlanExecutor(cli client.Client, recorder record.EventRecorder) *E } // Do execute the release plan -func (r *Executor) Do(release *v1alpha1.BatchRelease) (reconcile.Result, *v1alpha1.BatchReleaseStatus, error) { +func (r *Executor) Do(release *v1beta1.BatchRelease) (reconcile.Result, *v1beta1.BatchReleaseStatus, error) { klog.InfoS("Starting one round of reconciling release plan", "BatchRelease", client.ObjectKeyFromObject(release), "phase", release.Status.Phase, @@ -84,7 +84,7 @@ func (r *Executor) Do(release *v1alpha1.BatchRelease) (reconcile.Result, *v1alph return r.executeBatchReleasePlan(release, newStatus, workloadController) } -func (r *Executor) executeBatchReleasePlan(release *v1alpha1.BatchRelease, newStatus *v1alpha1.BatchReleaseStatus, workloadController control.Interface) (reconcile.Result, *v1alpha1.BatchReleaseStatus, error) { +func (r *Executor) executeBatchReleasePlan(release *v1beta1.BatchRelease, newStatus *v1beta1.BatchReleaseStatus, workloadController control.Interface) (reconcile.Result, *v1beta1.BatchReleaseStatus, error) { var err error result := reconcile.Result{} @@ -93,34 +93,34 @@ func (r *Executor) executeBatchReleasePlan(release *v1alpha1.BatchRelease, newSt switch newStatus.Phase { default: // for compatibility. if it is an unknown phase, should start from beginning. - newStatus.Phase = v1alpha1.RolloutPhasePreparing + newStatus.Phase = v1beta1.RolloutPhasePreparing fallthrough - case v1alpha1.RolloutPhasePreparing: + case v1beta1.RolloutPhasePreparing: // prepare and initialize something before progressing in this state. err = workloadController.Initialize() switch { case err == nil: - newStatus.Phase = v1alpha1.RolloutPhaseProgressing + newStatus.Phase = v1beta1.RolloutPhaseProgressing result = reconcile.Result{RequeueAfter: DefaultDuration} default: klog.Warningf("Failed to initialize %v, err %v", klog.KObj(release), err) } - case v1alpha1.RolloutPhaseProgressing: + case v1beta1.RolloutPhaseProgressing: // progress the release plan in this state. result, err = r.progressBatches(release, newStatus, workloadController) - case v1alpha1.RolloutPhaseFinalizing: + case v1beta1.RolloutPhaseFinalizing: err = workloadController.Finalize() switch { case err == nil: - newStatus.Phase = v1alpha1.RolloutPhaseCompleted + newStatus.Phase = v1beta1.RolloutPhaseCompleted default: klog.Warningf("Failed to finalize %v, err %v", klog.KObj(release), err) } - case v1alpha1.RolloutPhaseCompleted: + case v1beta1.RolloutPhaseCompleted: // this state indicates that the plan is executed/cancelled successfully, should do nothing in these states. } @@ -128,7 +128,7 @@ func (r *Executor) executeBatchReleasePlan(release *v1alpha1.BatchRelease, newSt } // reconcile logic when we are in the middle of release, we have to go through finalizing state before succeed or fail -func (r *Executor) progressBatches(release *v1alpha1.BatchRelease, newStatus *v1alpha1.BatchReleaseStatus, workloadController control.Interface) (reconcile.Result, error) { +func (r *Executor) progressBatches(release *v1beta1.BatchRelease, newStatus *v1beta1.BatchReleaseStatus, workloadController control.Interface) (reconcile.Result, error) { var err error result := reconcile.Result{} @@ -137,43 +137,43 @@ func (r *Executor) progressBatches(release *v1alpha1.BatchRelease, newStatus *v1 switch newStatus.CanaryStatus.CurrentBatchState { default: // for compatibility. if it is an unknown state, should start from beginning. - newStatus.CanaryStatus.CurrentBatchState = v1alpha1.UpgradingBatchState + newStatus.CanaryStatus.CurrentBatchState = v1beta1.UpgradingBatchState fallthrough - case v1alpha1.UpgradingBatchState: + case v1beta1.UpgradingBatchState: // modify workload replicas/partition based on release plan in this state. err = workloadController.UpgradeBatch() switch { case err == nil: result = reconcile.Result{RequeueAfter: DefaultDuration} - newStatus.CanaryStatus.CurrentBatchState = v1alpha1.VerifyingBatchState + newStatus.CanaryStatus.CurrentBatchState = v1beta1.VerifyingBatchState default: klog.Warningf("Failed to upgrade %v, err %v", klog.KObj(release), err) } - case v1alpha1.VerifyingBatchState: + case v1beta1.VerifyingBatchState: // replicas/partition has been modified, should wait pod ready in this state. err = workloadController.CheckBatchReady() switch { case err != nil: // should go to upgrade state to do again to avoid dead wait. - newStatus.CanaryStatus.CurrentBatchState = v1alpha1.UpgradingBatchState + newStatus.CanaryStatus.CurrentBatchState = v1beta1.UpgradingBatchState klog.Warningf("%v current batch is not ready, err %v", klog.KObj(release), err) default: now := metav1.Now() newStatus.CanaryStatus.BatchReadyTime = &now result = reconcile.Result{RequeueAfter: DefaultDuration} - newStatus.CanaryStatus.CurrentBatchState = v1alpha1.ReadyBatchState + newStatus.CanaryStatus.CurrentBatchState = v1beta1.ReadyBatchState } - case v1alpha1.ReadyBatchState: + case v1beta1.ReadyBatchState: // replicas/partition may be modified even though ready, should recheck in this state. err = workloadController.CheckBatchReady() switch { case err != nil: // if the batch ready condition changed due to some reasons, just recalculate the current batch. newStatus.CanaryStatus.BatchReadyTime = nil - newStatus.CanaryStatus.CurrentBatchState = v1alpha1.UpgradingBatchState + newStatus.CanaryStatus.CurrentBatchState = v1beta1.UpgradingBatchState klog.Warningf("%v current batch is not ready, err %v", klog.KObj(release), err) case !isPartitioned(release): r.moveToNextBatch(release, newStatus) @@ -185,7 +185,7 @@ func (r *Executor) progressBatches(release *v1alpha1.BatchRelease, newStatus *v1 } // GetWorkloadController pick the right workload controller to work on the workload -func (r *Executor) getReleaseController(release *v1alpha1.BatchRelease, newStatus *v1alpha1.BatchReleaseStatus) (control.Interface, error) { +func (r *Executor) getReleaseController(release *v1beta1.BatchRelease, newStatus *v1beta1.BatchReleaseStatus) (control.Interface, error) { targetRef := release.Spec.TargetRef.WorkloadRef if targetRef == nil { return nil, nil @@ -216,7 +216,7 @@ func (r *Executor) getReleaseController(release *v1alpha1.BatchRelease, newStatu case apps.SchemeGroupVersion.String(): if targetRef.Kind == reflect.TypeOf(apps.Deployment{}).Name() { - if strings.EqualFold(release.Annotations[v1alpha1.RolloutStyleAnnotation], string(v1alpha1.PartitionRollingStyle)) { + if strings.EqualFold(release.Annotations[v1beta1.RolloutStyleAnnotation], string(v1beta1.PartitionRollingStyle)) { klog.InfoS("Using Deployment partition-style release controller for this batch release", "workload name", targetKey.Name, "namespace", targetKey.Namespace) return partitionstyle.NewControlPlane(partitiondeployment.NewController, r.client, r.recorder, release, newStatus, targetKey, gvk), nil } else { @@ -231,7 +231,7 @@ func (r *Executor) getReleaseController(release *v1alpha1.BatchRelease, newStatu return partitionstyle.NewControlPlane(statefulset.NewController, r.client, r.recorder, release, newStatus, targetKey, gvk), nil } -func (r *Executor) moveToNextBatch(release *v1alpha1.BatchRelease, status *v1alpha1.BatchReleaseStatus) { +func (r *Executor) moveToNextBatch(release *v1beta1.BatchRelease, status *v1beta1.BatchReleaseStatus) { currentBatch := int(status.CanaryStatus.CurrentBatch) if currentBatch >= len(release.Spec.ReleasePlan.Batches)-1 { klog.V(3).Infof("BatchRelease(%v) finished all batch, release current batch: %v", klog.KObj(release), status.CanaryStatus.CurrentBatch) @@ -239,11 +239,11 @@ func (r *Executor) moveToNextBatch(release *v1alpha1.BatchRelease, status *v1alp if release.Spec.ReleasePlan.BatchPartition == nil || *release.Spec.ReleasePlan.BatchPartition > status.CanaryStatus.CurrentBatch { status.CanaryStatus.CurrentBatch++ } - status.CanaryStatus.CurrentBatchState = v1alpha1.UpgradingBatchState + status.CanaryStatus.CurrentBatchState = v1beta1.UpgradingBatchState klog.V(3).Infof("BatchRelease(%v) finished one batch, release current batch: %v", klog.KObj(release), status.CanaryStatus.CurrentBatch) } -func isPartitioned(release *v1alpha1.BatchRelease) bool { +func isPartitioned(release *v1beta1.BatchRelease) bool { return release.Spec.ReleasePlan.BatchPartition != nil && *release.Spec.ReleasePlan.BatchPartition <= release.Status.CanaryStatus.CurrentBatch } diff --git a/pkg/controller/batchrelease/batchrelease_status.go b/pkg/controller/batchrelease/batchrelease_status.go index 81c660b9..2d97ff44 100644 --- a/pkg/controller/batchrelease/batchrelease_status.go +++ b/pkg/controller/batchrelease/batchrelease_status.go @@ -19,7 +19,7 @@ package batchrelease import ( "reflect" - "github.com/openkruise/rollouts/api/v1alpha1" + "github.com/openkruise/rollouts/api/v1beta1" "github.com/openkruise/rollouts/pkg/controller/batchrelease/control" "github.com/openkruise/rollouts/pkg/util" "k8s.io/apimachinery/pkg/api/errors" @@ -29,7 +29,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/reconcile" ) -func (r *Executor) syncStatusBeforeExecuting(release *v1alpha1.BatchRelease, newStatus *v1alpha1.BatchReleaseStatus, controller control.Interface) (bool, reconcile.Result, error) { +func (r *Executor) syncStatusBeforeExecuting(release *v1beta1.BatchRelease, newStatus *v1beta1.BatchReleaseStatus, controller control.Interface) (bool, reconcile.Result, error) { var err error var message string var needRetry bool @@ -145,7 +145,7 @@ func (r *Executor) syncStatusBeforeExecuting(release *v1alpha1.BatchRelease, new return needStopThisRound, result, err } -func refreshStatus(release *v1alpha1.BatchRelease, newStatus *v1alpha1.BatchReleaseStatus, workloadInfo *util.WorkloadInfo) { +func refreshStatus(release *v1beta1.BatchRelease, newStatus *v1beta1.BatchReleaseStatus, workloadInfo *util.WorkloadInfo) { // refresh workload info for status if workloadInfo != nil { newStatus.CanaryStatus.UpdatedReplicas = workloadInfo.Status.UpdatedReplicas @@ -156,76 +156,76 @@ func refreshStatus(release *v1alpha1.BatchRelease, newStatus *v1alpha1.BatchRele } } -func isPlanFinalizing(release *v1alpha1.BatchRelease) bool { - if release.DeletionTimestamp != nil || release.Status.Phase == v1alpha1.RolloutPhaseFinalizing { +func isPlanFinalizing(release *v1beta1.BatchRelease) bool { + if release.DeletionTimestamp != nil || release.Status.Phase == v1beta1.RolloutPhaseFinalizing { return true } return release.Spec.ReleasePlan.BatchPartition == nil } -func isPlanCompleted(release *v1alpha1.BatchRelease) bool { - return release.Status.Phase == v1alpha1.RolloutPhaseCompleted +func isPlanCompleted(release *v1beta1.BatchRelease) bool { + return release.Status.Phase == v1beta1.RolloutPhaseCompleted } -func isPlanChanged(release *v1alpha1.BatchRelease) bool { - return release.Status.ObservedReleasePlanHash != util.HashReleasePlanBatches(&release.Spec.ReleasePlan) && release.Status.Phase == v1alpha1.RolloutPhaseProgressing +func isPlanChanged(release *v1beta1.BatchRelease) bool { + return release.Status.ObservedReleasePlanHash != util.HashReleasePlanBatches(&release.Spec.ReleasePlan) && release.Status.Phase == v1beta1.RolloutPhaseProgressing } -func isPlanUnhealthy(release *v1alpha1.BatchRelease) bool { - return int(release.Status.CanaryStatus.CurrentBatch) >= len(release.Spec.ReleasePlan.Batches) && release.Status.Phase == v1alpha1.RolloutPhaseProgressing +func isPlanUnhealthy(release *v1beta1.BatchRelease) bool { + return int(release.Status.CanaryStatus.CurrentBatch) >= len(release.Spec.ReleasePlan.Batches) && release.Status.Phase == v1beta1.RolloutPhaseProgressing } func isGetWorkloadInfoError(err error) bool { return err != nil && !errors.IsNotFound(err) } -func isWorkloadGone(event control.WorkloadEventType, release *v1alpha1.BatchRelease) bool { - return event == control.WorkloadHasGone && release.Status.Phase != v1alpha1.RolloutPhaseInitial && release.Status.Phase != "" +func isWorkloadGone(event control.WorkloadEventType, release *v1beta1.BatchRelease) bool { + return event == control.WorkloadHasGone && release.Status.Phase != v1beta1.RolloutPhaseInitial && release.Status.Phase != "" } -func isWorkloadScaling(event control.WorkloadEventType, release *v1alpha1.BatchRelease) bool { - return event == control.WorkloadReplicasChanged && release.Status.Phase == v1alpha1.RolloutPhaseProgressing +func isWorkloadScaling(event control.WorkloadEventType, release *v1beta1.BatchRelease) bool { + return event == control.WorkloadReplicasChanged && release.Status.Phase == v1beta1.RolloutPhaseProgressing } -func isWorkloadRevisionChanged(event control.WorkloadEventType, release *v1alpha1.BatchRelease) bool { - return event == control.WorkloadPodTemplateChanged && release.Status.Phase == v1alpha1.RolloutPhaseProgressing +func isWorkloadRevisionChanged(event control.WorkloadEventType, release *v1beta1.BatchRelease) bool { + return event == control.WorkloadPodTemplateChanged && release.Status.Phase == v1beta1.RolloutPhaseProgressing } -func isWorkloadRollbackInBatch(event control.WorkloadEventType, release *v1alpha1.BatchRelease) bool { - return (event == control.WorkloadRollbackInBatch || release.Annotations[v1alpha1.RollbackInBatchAnnotation] != "") && - release.Status.CanaryStatus.NoNeedUpdateReplicas == nil && release.Status.Phase == v1alpha1.RolloutPhaseProgressing +func isWorkloadRollbackInBatch(event control.WorkloadEventType, release *v1beta1.BatchRelease) bool { + return (event == control.WorkloadRollbackInBatch || release.Annotations[v1beta1.RollbackInBatchAnnotation] != "") && + release.Status.CanaryStatus.NoNeedUpdateReplicas == nil && release.Status.Phase == v1beta1.RolloutPhaseProgressing } -func isWorkloadUnstable(event control.WorkloadEventType, _ *v1alpha1.BatchRelease) bool { +func isWorkloadUnstable(event control.WorkloadEventType, _ *v1beta1.BatchRelease) bool { return event == control.WorkloadStillReconciling } -func isRollbackInBatchSatisfied(workloadInfo *util.WorkloadInfo, release *v1alpha1.BatchRelease) bool { - return workloadInfo.Status.StableRevision == workloadInfo.Status.UpdateRevision && release.Annotations[v1alpha1.RollbackInBatchAnnotation] != "" +func isRollbackInBatchSatisfied(workloadInfo *util.WorkloadInfo, release *v1beta1.BatchRelease) bool { + return workloadInfo.Status.StableRevision == workloadInfo.Status.UpdateRevision && release.Annotations[v1beta1.RollbackInBatchAnnotation] != "" } -func signalRePrepareRollback(newStatus *v1alpha1.BatchReleaseStatus) { - newStatus.Phase = v1alpha1.RolloutPhasePreparing +func signalRePrepareRollback(newStatus *v1beta1.BatchReleaseStatus) { + newStatus.Phase = v1beta1.RolloutPhasePreparing newStatus.CanaryStatus.BatchReadyTime = nil - newStatus.CanaryStatus.CurrentBatchState = v1alpha1.UpgradingBatchState + newStatus.CanaryStatus.CurrentBatchState = v1beta1.UpgradingBatchState } -func signalRestartBatch(status *v1alpha1.BatchReleaseStatus) { +func signalRestartBatch(status *v1beta1.BatchReleaseStatus) { status.CanaryStatus.BatchReadyTime = nil - status.CanaryStatus.CurrentBatchState = v1alpha1.UpgradingBatchState + status.CanaryStatus.CurrentBatchState = v1beta1.UpgradingBatchState } -func signalRestartAll(status *v1alpha1.BatchReleaseStatus) { - emptyStatus := v1alpha1.BatchReleaseStatus{} +func signalRestartAll(status *v1beta1.BatchReleaseStatus) { + emptyStatus := v1beta1.BatchReleaseStatus{} resetStatus(&emptyStatus) *status = emptyStatus } -func signalFinalizing(status *v1alpha1.BatchReleaseStatus) { - status.Phase = v1alpha1.RolloutPhaseFinalizing +func signalFinalizing(status *v1beta1.BatchReleaseStatus) { + status.Phase = v1beta1.RolloutPhaseFinalizing } -func signalRecalculate(release *v1alpha1.BatchRelease, newStatus *v1alpha1.BatchReleaseStatus) { +func signalRecalculate(release *v1beta1.BatchRelease, newStatus *v1beta1.BatchReleaseStatus) { // When BatchRelease plan was changed, rollout controller will update this batchRelease cr, // and rollout controller will set BatchPartition as its expected current batch index. currentBatch := int32(0) @@ -242,11 +242,11 @@ func signalRecalculate(release *v1alpha1.BatchRelease, newStatus *v1alpha1.Batch newStatus.CanaryStatus.BatchReadyTime = nil newStatus.CanaryStatus.CurrentBatch = currentBatch newStatus.ObservedRolloutID = release.Spec.ReleasePlan.RolloutID - newStatus.CanaryStatus.CurrentBatchState = v1alpha1.UpgradingBatchState + newStatus.CanaryStatus.CurrentBatchState = v1beta1.UpgradingBatchState newStatus.ObservedReleasePlanHash = util.HashReleasePlanBatches(&release.Spec.ReleasePlan) } -func getInitializedStatus(status *v1alpha1.BatchReleaseStatus) *v1alpha1.BatchReleaseStatus { +func getInitializedStatus(status *v1beta1.BatchReleaseStatus) *v1beta1.BatchReleaseStatus { newStatus := status.DeepCopy() if len(status.Phase) == 0 { resetStatus(newStatus) @@ -254,11 +254,11 @@ func getInitializedStatus(status *v1alpha1.BatchReleaseStatus) *v1alpha1.BatchRe return newStatus } -func resetStatus(status *v1alpha1.BatchReleaseStatus) { - status.Phase = v1alpha1.RolloutPhasePreparing +func resetStatus(status *v1beta1.BatchReleaseStatus) { + status.Phase = v1beta1.RolloutPhasePreparing status.StableRevision = "" status.UpdateRevision = "" status.ObservedReleasePlanHash = "" status.ObservedWorkloadReplicas = -1 - status.CanaryStatus = v1alpha1.BatchReleaseCanaryStatus{} + status.CanaryStatus = v1beta1.BatchReleaseCanaryStatus{} } diff --git a/pkg/controller/batchrelease/context/context.go b/pkg/controller/batchrelease/context/context.go index 7e95daa9..5a801249 100644 --- a/pkg/controller/batchrelease/context/context.go +++ b/pkg/controller/batchrelease/context/context.go @@ -20,7 +20,7 @@ import ( "encoding/json" "fmt" - "github.com/openkruise/rollouts/api/v1alpha1" + "github.com/openkruise/rollouts/api/v1beta1" "github.com/openkruise/rollouts/pkg/util" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/intstr" @@ -100,7 +100,7 @@ func batchLabelSatisfied(pods []*corev1.Pod, rolloutID string, targetCount int32 if !pod.DeletionTimestamp.IsZero() { return false } - return pod.Labels[v1alpha1.RolloutIDLabel] == rolloutID + return pod.Labels[v1beta1.RolloutIDLabel] == rolloutID }) return patchedCount >= int(targetCount) } diff --git a/pkg/controller/batchrelease/context/context_test.go b/pkg/controller/batchrelease/context/context_test.go index 9f2d7f2d..6ba5c7e9 100644 --- a/pkg/controller/batchrelease/context/context_test.go +++ b/pkg/controller/batchrelease/context/context_test.go @@ -22,7 +22,7 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "github.com/openkruise/rollouts/api/v1alpha1" + "github.com/openkruise/rollouts/api/v1beta1" "github.com/openkruise/rollouts/pkg/util" apps "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" @@ -36,14 +36,14 @@ func TestIsBatchReady(t *testing.T) { p := func(f intstr.IntOrString) *intstr.IntOrString { return &f } - r := func(f *intstr.IntOrString, id, revision string) *v1alpha1.BatchRelease { - return &v1alpha1.BatchRelease{ - Spec: v1alpha1.BatchReleaseSpec{ReleasePlan: v1alpha1.ReleasePlan{RolloutID: id, FailureThreshold: f}}, - Status: v1alpha1.BatchReleaseStatus{UpdateRevision: revision}, + r := func(f *intstr.IntOrString, id, revision string) *v1beta1.BatchRelease { + return &v1beta1.BatchRelease{ + Spec: v1beta1.BatchReleaseSpec{ReleasePlan: v1beta1.ReleasePlan{RolloutID: id, FailureThreshold: f}}, + Status: v1beta1.BatchReleaseStatus{UpdateRevision: revision}, } } cases := map[string]struct { - release *v1alpha1.BatchRelease + release *v1beta1.BatchRelease pods []*corev1.Pod maxUnavailable *intstr.IntOrString labelDesired int32 @@ -151,11 +151,11 @@ func TestIsBatchReady(t *testing.T) { func generatePods(updatedReplicas, noNeedRollbackReplicas int) []*corev1.Pod { podsNoNeed := generatePodsWith(map[string]string{ util.NoNeedUpdatePodLabel: "0x1", - v1alpha1.RolloutIDLabel: "1", + v1beta1.RolloutIDLabel: "1", apps.ControllerRevisionHashLabelKey: "version-1", }, noNeedRollbackReplicas, 0) return append(generatePodsWith(map[string]string{ - v1alpha1.RolloutIDLabel: "1", + v1beta1.RolloutIDLabel: "1", apps.ControllerRevisionHashLabelKey: "version-1", }, updatedReplicas-noNeedRollbackReplicas, noNeedRollbackReplicas), podsNoNeed...) } diff --git a/pkg/controller/batchrelease/control/canarystyle/control_plane.go b/pkg/controller/batchrelease/control/canarystyle/control_plane.go index 03f315ff..f5faba4e 100644 --- a/pkg/controller/batchrelease/control/canarystyle/control_plane.go +++ b/pkg/controller/batchrelease/control/canarystyle/control_plane.go @@ -19,7 +19,7 @@ package canarystyle import ( "fmt" - "github.com/openkruise/rollouts/api/v1alpha1" + "github.com/openkruise/rollouts/api/v1beta1" "github.com/openkruise/rollouts/pkg/controller/batchrelease/control" "github.com/openkruise/rollouts/pkg/controller/batchrelease/labelpatch" "github.com/openkruise/rollouts/pkg/util" @@ -36,14 +36,14 @@ type realCanaryController struct { client.Client record.EventRecorder patcher labelpatch.LabelPatcher - release *v1alpha1.BatchRelease - newStatus *v1alpha1.BatchReleaseStatus + release *v1beta1.BatchRelease + newStatus *v1beta1.BatchReleaseStatus } type NewInterfaceFunc func(cli client.Client, key types.NamespacedName) Interface // NewControlPlane creates a new release controller to drive batch release state machine -func NewControlPlane(f NewInterfaceFunc, cli client.Client, recorder record.EventRecorder, release *v1alpha1.BatchRelease, newStatus *v1alpha1.BatchReleaseStatus, key types.NamespacedName) *realCanaryController { +func NewControlPlane(f NewInterfaceFunc, cli client.Client, recorder record.EventRecorder, release *v1beta1.BatchRelease, newStatus *v1beta1.BatchReleaseStatus, key types.NamespacedName) *realCanaryController { return &realCanaryController{ Client: cli, EventRecorder: recorder, diff --git a/pkg/controller/batchrelease/control/canarystyle/deployment/canary.go b/pkg/controller/batchrelease/control/canarystyle/deployment/canary.go index 811db7d5..e8afc70c 100644 --- a/pkg/controller/batchrelease/control/canarystyle/deployment/canary.go +++ b/pkg/controller/batchrelease/control/canarystyle/deployment/canary.go @@ -22,7 +22,7 @@ import ( "fmt" "sort" - "github.com/openkruise/rollouts/api/v1alpha1" + "github.com/openkruise/rollouts/api/v1beta1" batchcontext "github.com/openkruise/rollouts/pkg/controller/batchrelease/context" "github.com/openkruise/rollouts/pkg/util" utilclient "github.com/openkruise/rollouts/pkg/util/client" @@ -55,7 +55,7 @@ func (r *realCanaryController) GetCanaryInfo() *util.WorkloadInfo { // Delete do not delete canary deployments actually, it only removes the finalizers of // Deployments. These deployments will be cascaded deleted when BatchRelease is deleted. -func (r *realCanaryController) Delete(release *v1alpha1.BatchRelease) error { +func (r *realCanaryController) Delete(release *v1beta1.BatchRelease) error { deployments, err := r.listDeployment(release, client.InNamespace(r.objectKey.Namespace), utilclient.DisableDeepCopy) if err != nil { return err @@ -87,7 +87,7 @@ func (r *realCanaryController) UpgradeBatch(ctx *batchcontext.BatchContext) erro return r.canaryClient.Patch(context.TODO(), deployment, client.RawPatch(types.StrategicMergePatchType, []byte(body))) } -func (r *realCanaryController) Create(release *v1alpha1.BatchRelease) error { +func (r *realCanaryController) Create(release *v1beta1.BatchRelease) error { if r.canaryObject != nil { return nil // Don't re-create if exists } @@ -113,7 +113,7 @@ func (r *realCanaryController) Create(release *v1alpha1.BatchRelease) error { } return r.create(release, stable) } -func (r *realCanaryController) create(release *v1alpha1.BatchRelease, template *apps.Deployment) error { +func (r *realCanaryController) create(release *v1beta1.BatchRelease, template *apps.Deployment) error { canary := &apps.Deployment{ ObjectMeta: metav1.ObjectMeta{ GenerateName: fmt.Sprintf("%v-", r.objectKey.Name), @@ -162,7 +162,7 @@ func (r *realCanaryController) create(release *v1alpha1.BatchRelease, template * return fmt.Errorf("created canary deployment %v succeeded, but waiting informer synced", klog.KObj(canary)) } -func (r *realCanaryController) listDeployment(release *v1alpha1.BatchRelease, options ...client.ListOption) ([]*apps.Deployment, error) { +func (r *realCanaryController) listDeployment(release *v1beta1.BatchRelease, options ...client.ListOption) ([]*apps.Deployment, error) { dList := &apps.DeploymentList{} if err := r.canaryClient.List(context.TODO(), dList, options...); err != nil { return nil, err @@ -181,7 +181,7 @@ func (r *realCanaryController) listDeployment(release *v1alpha1.BatchRelease, op } // return the latest deployment with the newer creation time -func filterCanaryDeployment(release *v1alpha1.BatchRelease, ds []*apps.Deployment, template *corev1.PodTemplateSpec) *apps.Deployment { +func filterCanaryDeployment(release *v1beta1.BatchRelease, ds []*apps.Deployment, template *corev1.PodTemplateSpec) *apps.Deployment { if len(ds) == 0 { return nil } diff --git a/pkg/controller/batchrelease/control/canarystyle/deployment/control.go b/pkg/controller/batchrelease/control/canarystyle/deployment/control.go index 15f46021..c0f61670 100644 --- a/pkg/controller/batchrelease/control/canarystyle/deployment/control.go +++ b/pkg/controller/batchrelease/control/canarystyle/deployment/control.go @@ -20,7 +20,7 @@ import ( "context" "fmt" - "github.com/openkruise/rollouts/api/v1alpha1" + "github.com/openkruise/rollouts/api/v1beta1" batchcontext "github.com/openkruise/rollouts/pkg/controller/batchrelease/context" "github.com/openkruise/rollouts/pkg/controller/batchrelease/control" "github.com/openkruise/rollouts/pkg/controller/batchrelease/control/canarystyle" @@ -59,7 +59,7 @@ func (rc *realController) BuildStableController() (canarystyle.StableInterface, return rc, nil } -func (rc *realController) BuildCanaryController(release *v1alpha1.BatchRelease) (canarystyle.CanaryInterface, error) { +func (rc *realController) BuildCanaryController(release *v1beta1.BatchRelease) (canarystyle.CanaryInterface, error) { if rc.canaryObject != nil { return rc, nil } @@ -82,7 +82,7 @@ func (rc *realController) BuildCanaryController(release *v1alpha1.BatchRelease) return rc, nil } -func (rc *realController) CalculateBatchContext(release *v1alpha1.BatchRelease) *batchcontext.BatchContext { +func (rc *realController) CalculateBatchContext(release *v1beta1.BatchRelease) *batchcontext.BatchContext { replicas := *rc.stableObject.Spec.Replicas currentBatch := release.Status.CanaryStatus.CurrentBatch desiredUpdate := int32(control.CalculateBatchReplicas(release, int(replicas), int(currentBatch))) diff --git a/pkg/controller/batchrelease/control/canarystyle/deployment/control_test.go b/pkg/controller/batchrelease/control/canarystyle/deployment/control_test.go index 2eaf31a0..0b44b242 100644 --- a/pkg/controller/batchrelease/control/canarystyle/deployment/control_test.go +++ b/pkg/controller/batchrelease/control/canarystyle/deployment/control_test.go @@ -24,7 +24,7 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "github.com/openkruise/rollouts/api/v1alpha1" + "github.com/openkruise/rollouts/api/v1beta1" batchcontext "github.com/openkruise/rollouts/pkg/controller/batchrelease/context" "github.com/openkruise/rollouts/pkg/util" expectations "github.com/openkruise/rollouts/pkg/util/expectation" @@ -105,9 +105,9 @@ var ( }, } - releaseDemo = &v1alpha1.BatchRelease{ + releaseDemo = &v1beta1.BatchRelease{ TypeMeta: metav1.TypeMeta{ - APIVersion: "rollouts.kruise.io/v1alpha1", + APIVersion: "rollouts.kruise.io/v1beta1", Kind: "BatchRelease", }, ObjectMeta: metav1.ObjectMeta{ @@ -115,10 +115,10 @@ var ( Namespace: deploymentKey.Namespace, UID: uuid.NewUUID(), }, - Spec: v1alpha1.BatchReleaseSpec{ - ReleasePlan: v1alpha1.ReleasePlan{ - FinalizingPolicy: v1alpha1.WaitResumeFinalizingPolicyType, - Batches: []v1alpha1.ReleaseBatch{ + Spec: v1beta1.BatchReleaseSpec{ + ReleasePlan: v1beta1.ReleasePlan{ + FinalizingPolicy: v1beta1.WaitResumeFinalizingPolicyType, + Batches: []v1beta1.ReleaseBatch{ { CanaryReplicas: intstr.FromString("10%"), }, @@ -130,16 +130,16 @@ var ( }, }, }, - TargetRef: v1alpha1.ObjectRef{ - WorkloadRef: &v1alpha1.WorkloadRef{ + TargetRef: v1beta1.ObjectRef{ + WorkloadRef: &v1beta1.WorkloadRef{ APIVersion: deploymentDemo.APIVersion, Kind: deploymentDemo.Kind, Name: deploymentDemo.Name, }, }, }, - Status: v1alpha1.BatchReleaseStatus{ - CanaryStatus: v1alpha1.BatchReleaseCanaryStatus{ + Status: v1beta1.BatchReleaseStatus{ + CanaryStatus: v1beta1.BatchReleaseCanaryStatus{ CurrentBatch: 1, }, }, @@ -148,7 +148,7 @@ var ( func init() { apps.AddToScheme(scheme) - v1alpha1.AddToScheme(scheme) + v1beta1.AddToScheme(scheme) } func TestCalculateBatchContext(t *testing.T) { @@ -157,7 +157,7 @@ func TestCalculateBatchContext(t *testing.T) { percent := intstr.FromString("20%") cases := map[string]struct { workload func() (*apps.Deployment, *apps.Deployment) - release func() *v1alpha1.BatchRelease + release func() *v1beta1.BatchRelease result *batchcontext.BatchContext }{ "normal case": { @@ -184,21 +184,21 @@ func TestCalculateBatchContext(t *testing.T) { } return stable, canary }, - release: func() *v1alpha1.BatchRelease { - r := &v1alpha1.BatchRelease{ - Spec: v1alpha1.BatchReleaseSpec{ - ReleasePlan: v1alpha1.ReleasePlan{ + release: func() *v1beta1.BatchRelease { + r := &v1beta1.BatchRelease{ + Spec: v1beta1.BatchReleaseSpec{ + ReleasePlan: v1beta1.ReleasePlan{ FailureThreshold: &percent, - FinalizingPolicy: v1alpha1.WaitResumeFinalizingPolicyType, - Batches: []v1alpha1.ReleaseBatch{ + FinalizingPolicy: v1beta1.WaitResumeFinalizingPolicyType, + Batches: []v1beta1.ReleaseBatch{ { CanaryReplicas: percent, }, }, }, }, - Status: v1alpha1.BatchReleaseStatus{ - CanaryStatus: v1alpha1.BatchReleaseCanaryStatus{ + Status: v1beta1.BatchReleaseStatus{ + CanaryStatus: v1beta1.BatchReleaseCanaryStatus{ CurrentBatch: 0, }, }, @@ -310,7 +310,7 @@ func TestRealCanaryController(t *testing.T) { Expect(len(d.Finalizers)).Should(Equal(0)) } -func getCanaryDeployment(release *v1alpha1.BatchRelease, stable *apps.Deployment, c *realController) *apps.Deployment { +func getCanaryDeployment(release *v1beta1.BatchRelease, stable *apps.Deployment, c *realController) *apps.Deployment { ds, err := c.listDeployment(release) Expect(err).NotTo(HaveOccurred()) if len(ds) == 0 { @@ -328,7 +328,7 @@ func checkWorkloadInfo(stableInfo *util.WorkloadInfo, deployment *apps.Deploymen Expect(stableInfo.Status.ObservedGeneration).Should(Equal(deployment.Status.ObservedGeneration)) } -func getControlInfo(release *v1alpha1.BatchRelease) string { +func getControlInfo(release *v1beta1.BatchRelease) string { owner, _ := json.Marshal(metav1.NewControllerRef(release, release.GetObjectKind().GroupVersionKind())) return string(owner) } diff --git a/pkg/controller/batchrelease/control/canarystyle/deployment/stable.go b/pkg/controller/batchrelease/control/canarystyle/deployment/stable.go index a90b9792..f79fcfae 100644 --- a/pkg/controller/batchrelease/control/canarystyle/deployment/stable.go +++ b/pkg/controller/batchrelease/control/canarystyle/deployment/stable.go @@ -20,7 +20,7 @@ import ( "context" "fmt" - "github.com/openkruise/rollouts/api/v1alpha1" + "github.com/openkruise/rollouts/api/v1beta1" "github.com/openkruise/rollouts/pkg/controller/batchrelease/control" "github.com/openkruise/rollouts/pkg/util" apps "k8s.io/api/apps/v1" @@ -43,7 +43,7 @@ func (rc *realStableController) GetStableInfo() *util.WorkloadInfo { return rc.stableInfo } -func (rc *realStableController) Initialize(release *v1alpha1.BatchRelease) error { +func (rc *realStableController) Initialize(release *v1beta1.BatchRelease) error { if control.IsControlledByBatchRelease(release, rc.stableObject) { return nil } @@ -55,7 +55,7 @@ func (rc *realStableController) Initialize(release *v1alpha1.BatchRelease) error return rc.stableClient.Patch(context.TODO(), d, client.RawPatch(types.StrategicMergePatchType, []byte(body))) } -func (rc *realStableController) Finalize(release *v1alpha1.BatchRelease) error { +func (rc *realStableController) Finalize(release *v1beta1.BatchRelease) error { if rc.stableObject == nil { return nil // no need to process deleted object } diff --git a/pkg/controller/batchrelease/control/canarystyle/interface.go b/pkg/controller/batchrelease/control/canarystyle/interface.go index d50ec4ae..f2585446 100644 --- a/pkg/controller/batchrelease/control/canarystyle/interface.go +++ b/pkg/controller/batchrelease/control/canarystyle/interface.go @@ -17,7 +17,7 @@ limitations under the License. package canarystyle import ( - "github.com/openkruise/rollouts/api/v1alpha1" + "github.com/openkruise/rollouts/api/v1beta1" batchcontext "github.com/openkruise/rollouts/pkg/controller/batchrelease/context" "github.com/openkruise/rollouts/pkg/util" ) @@ -30,10 +30,10 @@ type Interface interface { BuildStableController() (StableInterface, error) // BuildCanaryController will get canary workload object and parse // canary workload info, and return a controller for canary workload. - BuildCanaryController(release *v1alpha1.BatchRelease) (CanaryInterface, error) + BuildCanaryController(release *v1beta1.BatchRelease) (CanaryInterface, error) // CalculateBatchContext calculate the current batch context according to // our release plan and the statues of stable workload and canary workload. - CalculateBatchContext(release *v1alpha1.BatchRelease) *batchcontext.BatchContext + CalculateBatchContext(release *v1beta1.BatchRelease) *batchcontext.BatchContext } // CanaryInterface contains the methods about canary workload @@ -43,9 +43,9 @@ type CanaryInterface interface { // UpgradeBatch upgrade canary workload according to current batch context UpgradeBatch(*batchcontext.BatchContext) error // Create creates canary workload before rolling out - Create(controller *v1alpha1.BatchRelease) error + Create(controller *v1beta1.BatchRelease) error // Delete deletes canary workload after rolling out - Delete(controller *v1alpha1.BatchRelease) error + Delete(controller *v1beta1.BatchRelease) error } // StableInterface contains the methods about stable workload @@ -53,9 +53,9 @@ type StableInterface interface { // GetStableInfo return the information about stable workload GetStableInfo() *util.WorkloadInfo // Initialize claim the stable workload is under rollout control - Initialize(controller *v1alpha1.BatchRelease) error + Initialize(controller *v1beta1.BatchRelease) error // Finalize do something after rolling out, for example: // - free the stable workload from rollout control; // - resume stable workload and wait all pods updated if we need. - Finalize(controller *v1alpha1.BatchRelease) error + Finalize(controller *v1beta1.BatchRelease) error } diff --git a/pkg/controller/batchrelease/control/partitionstyle/cloneset/control.go b/pkg/controller/batchrelease/control/partitionstyle/cloneset/control.go index 2e5e6194..b136b104 100644 --- a/pkg/controller/batchrelease/control/partitionstyle/cloneset/control.go +++ b/pkg/controller/batchrelease/control/partitionstyle/cloneset/control.go @@ -21,7 +21,7 @@ import ( "fmt" kruiseappsv1alpha1 "github.com/openkruise/kruise-api/apps/v1alpha1" - "github.com/openkruise/rollouts/api/v1alpha1" + "github.com/openkruise/rollouts/api/v1beta1" batchcontext "github.com/openkruise/rollouts/pkg/controller/batchrelease/context" "github.com/openkruise/rollouts/pkg/controller/batchrelease/control" "github.com/openkruise/rollouts/pkg/controller/batchrelease/control/partitionstyle" @@ -75,7 +75,7 @@ func (rc *realController) ListOwnedPods() ([]*corev1.Pod, error) { return rc.pods, err } -func (rc *realController) Initialize(release *v1alpha1.BatchRelease) error { +func (rc *realController) Initialize(release *v1beta1.BatchRelease) error { if control.IsControlledByBatchRelease(release, rc.object) { return nil } @@ -110,7 +110,7 @@ func (rc *realController) UpgradeBatch(ctx *batchcontext.BatchContext) error { return rc.client.Patch(context.TODO(), clone, client.RawPatch(types.MergePatchType, []byte(body))) } -func (rc *realController) Finalize(release *v1alpha1.BatchRelease) error { +func (rc *realController) Finalize(release *v1beta1.BatchRelease) error { if rc.object == nil { return nil } @@ -127,7 +127,7 @@ func (rc *realController) Finalize(release *v1alpha1.BatchRelease) error { return rc.client.Patch(context.TODO(), clone, client.RawPatch(types.MergePatchType, []byte(body))) } -func (rc *realController) CalculateBatchContext(release *v1alpha1.BatchRelease) (*batchcontext.BatchContext, error) { +func (rc *realController) CalculateBatchContext(release *v1beta1.BatchRelease) (*batchcontext.BatchContext, error) { rolloutID := release.Spec.ReleasePlan.RolloutID if rolloutID != "" { // if rollout-id is set, the pod will be patched batch label, diff --git a/pkg/controller/batchrelease/control/partitionstyle/cloneset/control_test.go b/pkg/controller/batchrelease/control/partitionstyle/cloneset/control_test.go index 435ec33a..41ba6626 100644 --- a/pkg/controller/batchrelease/control/partitionstyle/cloneset/control_test.go +++ b/pkg/controller/batchrelease/control/partitionstyle/cloneset/control_test.go @@ -25,7 +25,7 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" kruiseappsv1alpha1 "github.com/openkruise/kruise-api/apps/v1alpha1" - "github.com/openkruise/rollouts/api/v1alpha1" + "github.com/openkruise/rollouts/api/v1beta1" batchcontext "github.com/openkruise/rollouts/pkg/controller/batchrelease/context" "github.com/openkruise/rollouts/pkg/controller/batchrelease/labelpatch" "github.com/openkruise/rollouts/pkg/util" @@ -104,9 +104,9 @@ var ( }, } - releaseDemo = &v1alpha1.BatchRelease{ + releaseDemo = &v1beta1.BatchRelease{ TypeMeta: metav1.TypeMeta{ - APIVersion: "rollouts.kruise.io/v1alpha1", + APIVersion: "rollouts.kruise.io/v1beta1", Kind: "BatchRelease", }, ObjectMeta: metav1.ObjectMeta{ @@ -114,9 +114,9 @@ var ( Namespace: cloneKey.Namespace, UID: uuid.NewUUID(), }, - Spec: v1alpha1.BatchReleaseSpec{ - ReleasePlan: v1alpha1.ReleasePlan{ - Batches: []v1alpha1.ReleaseBatch{ + Spec: v1beta1.BatchReleaseSpec{ + ReleasePlan: v1beta1.ReleasePlan{ + Batches: []v1beta1.ReleaseBatch{ { CanaryReplicas: intstr.FromString("10%"), }, @@ -128,16 +128,16 @@ var ( }, }, }, - TargetRef: v1alpha1.ObjectRef{ - WorkloadRef: &v1alpha1.WorkloadRef{ + TargetRef: v1beta1.ObjectRef{ + WorkloadRef: &v1beta1.WorkloadRef{ APIVersion: cloneDemo.APIVersion, Kind: cloneDemo.Kind, Name: cloneDemo.Name, }, }, }, - Status: v1alpha1.BatchReleaseStatus{ - CanaryStatus: v1alpha1.BatchReleaseCanaryStatus{ + Status: v1beta1.BatchReleaseStatus{ + CanaryStatus: v1beta1.BatchReleaseCanaryStatus{ CurrentBatch: 0, }, }, @@ -146,7 +146,7 @@ var ( func init() { apps.AddToScheme(scheme) - v1alpha1.AddToScheme(scheme) + v1beta1.AddToScheme(scheme) kruiseappsv1alpha1.AddToScheme(scheme) } @@ -156,7 +156,7 @@ func TestCalculateBatchContext(t *testing.T) { percent := intstr.FromString("20%") cases := map[string]struct { workload func() *kruiseappsv1alpha1.CloneSet - release func() *v1alpha1.BatchRelease + release func() *v1beta1.BatchRelease result *batchcontext.BatchContext }{ "without NoNeedUpdate": { @@ -176,20 +176,20 @@ func TestCalculateBatchContext(t *testing.T) { }, } }, - release: func() *v1alpha1.BatchRelease { - r := &v1alpha1.BatchRelease{ - Spec: v1alpha1.BatchReleaseSpec{ - ReleasePlan: v1alpha1.ReleasePlan{ + release: func() *v1beta1.BatchRelease { + r := &v1beta1.BatchRelease{ + Spec: v1beta1.BatchReleaseSpec{ + ReleasePlan: v1beta1.ReleasePlan{ FailureThreshold: &percent, - Batches: []v1alpha1.ReleaseBatch{ + Batches: []v1beta1.ReleaseBatch{ { CanaryReplicas: percent, }, }, }, }, - Status: v1alpha1.BatchReleaseStatus{ - CanaryStatus: v1alpha1.BatchReleaseCanaryStatus{ + Status: v1beta1.BatchReleaseStatus{ + CanaryStatus: v1beta1.BatchReleaseCanaryStatus{ CurrentBatch: 0, }, }, @@ -226,20 +226,20 @@ func TestCalculateBatchContext(t *testing.T) { }, } }, - release: func() *v1alpha1.BatchRelease { - r := &v1alpha1.BatchRelease{ - Spec: v1alpha1.BatchReleaseSpec{ - ReleasePlan: v1alpha1.ReleasePlan{ + release: func() *v1beta1.BatchRelease { + r := &v1beta1.BatchRelease{ + Spec: v1beta1.BatchReleaseSpec{ + ReleasePlan: v1beta1.ReleasePlan{ FailureThreshold: &percent, - Batches: []v1alpha1.ReleaseBatch{ + Batches: []v1beta1.ReleaseBatch{ { CanaryReplicas: percent, }, }, }, }, - Status: v1alpha1.BatchReleaseStatus{ - CanaryStatus: v1alpha1.BatchReleaseCanaryStatus{ + Status: v1beta1.BatchReleaseStatus{ + CanaryStatus: v1beta1.BatchReleaseCanaryStatus{ CurrentBatch: 0, NoNeedUpdateReplicas: pointer.Int32(10), }, @@ -336,7 +336,7 @@ func checkWorkloadInfo(stableInfo *util.WorkloadInfo, clone *kruiseappsv1alpha1. Expect(stableInfo.Status.ObservedGeneration).Should(Equal(clone.Status.ObservedGeneration)) } -func getControlInfo(release *v1alpha1.BatchRelease) string { +func getControlInfo(release *v1beta1.BatchRelease) string { owner, _ := json.Marshal(metav1.NewControllerRef(release, release.GetObjectKind().GroupVersionKind())) return string(owner) } diff --git a/pkg/controller/batchrelease/control/partitionstyle/control_plane.go b/pkg/controller/batchrelease/control/partitionstyle/control_plane.go index 9788175b..7fc5d9bf 100644 --- a/pkg/controller/batchrelease/control/partitionstyle/control_plane.go +++ b/pkg/controller/batchrelease/control/partitionstyle/control_plane.go @@ -20,7 +20,7 @@ import ( "context" "fmt" - "github.com/openkruise/rollouts/api/v1alpha1" + "github.com/openkruise/rollouts/api/v1beta1" "github.com/openkruise/rollouts/pkg/controller/batchrelease/control" "github.com/openkruise/rollouts/pkg/controller/batchrelease/labelpatch" "github.com/openkruise/rollouts/pkg/util" @@ -39,14 +39,14 @@ type realBatchControlPlane struct { client.Client record.EventRecorder patcher labelpatch.LabelPatcher - release *v1alpha1.BatchRelease - newStatus *v1alpha1.BatchReleaseStatus + release *v1beta1.BatchRelease + newStatus *v1beta1.BatchReleaseStatus } type NewInterfaceFunc func(cli client.Client, key types.NamespacedName, gvk schema.GroupVersionKind) Interface // NewControlPlane creates a new release controller with partitioned-style to drive batch release state machine -func NewControlPlane(f NewInterfaceFunc, cli client.Client, recorder record.EventRecorder, release *v1alpha1.BatchRelease, newStatus *v1alpha1.BatchReleaseStatus, key types.NamespacedName, gvk schema.GroupVersionKind) *realBatchControlPlane { +func NewControlPlane(f NewInterfaceFunc, cli client.Client, recorder record.EventRecorder, release *v1beta1.BatchRelease, newStatus *v1beta1.BatchReleaseStatus, key types.NamespacedName, gvk schema.GroupVersionKind) *realBatchControlPlane { return &realBatchControlPlane{ Client: cli, EventRecorder: recorder, @@ -203,7 +203,7 @@ func (rc *realBatchControlPlane) SyncWorkloadInformation() (control.WorkloadEven // - err: whether error occurs. func (rc *realBatchControlPlane) markNoNeedUpdatePodsIfNeeds() (*int32, error) { // currently, we only support rollback scene, in the future, we may support more scenes. - if rc.release.Annotations[v1alpha1.RollbackInBatchAnnotation] == "" { + if rc.release.Annotations[v1beta1.RollbackInBatchAnnotation] == "" { return nil, nil } // currently, if rollout-id is not set, it is no scene which require patch this label diff --git a/pkg/controller/batchrelease/control/partitionstyle/daemonset/control.go b/pkg/controller/batchrelease/control/partitionstyle/daemonset/control.go index ec7b3311..d1f03885 100644 --- a/pkg/controller/batchrelease/control/partitionstyle/daemonset/control.go +++ b/pkg/controller/batchrelease/control/partitionstyle/daemonset/control.go @@ -5,7 +5,7 @@ import ( "fmt" kruiseappsv1alpha1 "github.com/openkruise/kruise-api/apps/v1alpha1" - "github.com/openkruise/rollouts/api/v1alpha1" + "github.com/openkruise/rollouts/api/v1beta1" batchcontext "github.com/openkruise/rollouts/pkg/controller/batchrelease/context" "github.com/openkruise/rollouts/pkg/controller/batchrelease/control" "github.com/openkruise/rollouts/pkg/controller/batchrelease/control/partitionstyle" @@ -89,7 +89,7 @@ func (rc *realController) ListOwnedPods() ([]*corev1.Pod, error) { return rc.pods, err } -func (rc *realController) Initialize(release *v1alpha1.BatchRelease) error { +func (rc *realController) Initialize(release *v1beta1.BatchRelease) error { if control.IsControlledByBatchRelease(release, rc.object) { return nil } @@ -118,7 +118,7 @@ func (rc *realController) UpgradeBatch(ctx *batchcontext.BatchContext) error { return rc.client.Patch(context.TODO(), daemon, client.RawPatch(types.MergePatchType, []byte(body))) } -func (rc *realController) Finalize(release *v1alpha1.BatchRelease) error { +func (rc *realController) Finalize(release *v1beta1.BatchRelease) error { if rc.object == nil { return nil } @@ -135,7 +135,7 @@ func (rc *realController) Finalize(release *v1alpha1.BatchRelease) error { return rc.client.Patch(context.TODO(), daemon, client.RawPatch(types.MergePatchType, []byte(body))) } -func (rc *realController) CalculateBatchContext(release *v1alpha1.BatchRelease) (*batchcontext.BatchContext, error) { +func (rc *realController) CalculateBatchContext(release *v1beta1.BatchRelease) (*batchcontext.BatchContext, error) { rolloutID := release.Spec.ReleasePlan.RolloutID if rolloutID != "" { // if rollout-id is set, the pod will be patched batch label, diff --git a/pkg/controller/batchrelease/control/partitionstyle/daemonset/control_test.go b/pkg/controller/batchrelease/control/partitionstyle/daemonset/control_test.go index b1163571..7d7b16bd 100644 --- a/pkg/controller/batchrelease/control/partitionstyle/daemonset/control_test.go +++ b/pkg/controller/batchrelease/control/partitionstyle/daemonset/control_test.go @@ -9,7 +9,7 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" kruiseappsv1alpha1 "github.com/openkruise/kruise-api/apps/v1alpha1" - "github.com/openkruise/rollouts/api/v1alpha1" + "github.com/openkruise/rollouts/api/v1beta1" batchcontext "github.com/openkruise/rollouts/pkg/controller/batchrelease/context" "github.com/openkruise/rollouts/pkg/controller/batchrelease/labelpatch" "github.com/openkruise/rollouts/pkg/util" @@ -92,9 +92,9 @@ var ( }, } - releaseDemo = &v1alpha1.BatchRelease{ + releaseDemo = &v1beta1.BatchRelease{ TypeMeta: metav1.TypeMeta{ - APIVersion: "rollouts.kruise.io/v1alpha1", + APIVersion: "rollouts.kruise.io/v1beta1", Kind: "BatchRelease", }, ObjectMeta: metav1.ObjectMeta{ @@ -102,9 +102,9 @@ var ( Namespace: daemonKey.Namespace, UID: uuid.NewUUID(), }, - Spec: v1alpha1.BatchReleaseSpec{ - ReleasePlan: v1alpha1.ReleasePlan{ - Batches: []v1alpha1.ReleaseBatch{ + Spec: v1beta1.BatchReleaseSpec{ + ReleasePlan: v1beta1.ReleasePlan{ + Batches: []v1beta1.ReleaseBatch{ { CanaryReplicas: intstr.FromString("10%"), }, @@ -116,16 +116,16 @@ var ( }, }, }, - TargetRef: v1alpha1.ObjectRef{ - WorkloadRef: &v1alpha1.WorkloadRef{ + TargetRef: v1beta1.ObjectRef{ + WorkloadRef: &v1beta1.WorkloadRef{ APIVersion: daemonDemo.APIVersion, Kind: daemonDemo.Kind, Name: daemonDemo.Name, }, }, }, - Status: v1alpha1.BatchReleaseStatus{ - CanaryStatus: v1alpha1.BatchReleaseCanaryStatus{ + Status: v1beta1.BatchReleaseStatus{ + CanaryStatus: v1beta1.BatchReleaseCanaryStatus{ CurrentBatch: 0, }, }, @@ -135,7 +135,7 @@ var ( func init() { apps.AddToScheme(scheme) corev1.AddToScheme(scheme) - v1alpha1.AddToScheme(scheme) + v1beta1.AddToScheme(scheme) kruiseappsv1alpha1.AddToScheme(scheme) } @@ -145,7 +145,7 @@ func TestCalculateBatchContext(t *testing.T) { percent := intstr.FromString("20%") cases := map[string]struct { workload func() *kruiseappsv1alpha1.DaemonSet - release func() *v1alpha1.BatchRelease + release func() *v1beta1.BatchRelease result *batchcontext.BatchContext pods func() []*corev1.Pod }{ @@ -183,24 +183,24 @@ func TestCalculateBatchContext(t *testing.T) { updatedReadyPods := generatePods(5, "update-version", "True") return append(stablePods, updatedReadyPods...) }, - release: func() *v1alpha1.BatchRelease { - r := &v1alpha1.BatchRelease{ + release: func() *v1beta1.BatchRelease { + r := &v1beta1.BatchRelease{ ObjectMeta: metav1.ObjectMeta{ Name: "test-br", Namespace: "test", }, - Spec: v1alpha1.BatchReleaseSpec{ - ReleasePlan: v1alpha1.ReleasePlan{ + Spec: v1beta1.BatchReleaseSpec{ + ReleasePlan: v1beta1.ReleasePlan{ FailureThreshold: &percent, - Batches: []v1alpha1.ReleaseBatch{ + Batches: []v1beta1.ReleaseBatch{ { CanaryReplicas: percent, }, }, }, }, - Status: v1alpha1.BatchReleaseStatus{ - CanaryStatus: v1alpha1.BatchReleaseCanaryStatus{ + Status: v1beta1.BatchReleaseStatus{ + CanaryStatus: v1beta1.BatchReleaseCanaryStatus{ CurrentBatch: 0, }, UpdateRevision: "update-version", @@ -256,25 +256,25 @@ func TestCalculateBatchContext(t *testing.T) { updatedReadyPods := generatePods(5, "update-version", "True") return append(stablePods, updatedReadyPods...) }, - release: func() *v1alpha1.BatchRelease { + release: func() *v1beta1.BatchRelease { - r := &v1alpha1.BatchRelease{ + r := &v1beta1.BatchRelease{ ObjectMeta: metav1.ObjectMeta{ Name: "test-br", Namespace: "test", }, - Spec: v1alpha1.BatchReleaseSpec{ - ReleasePlan: v1alpha1.ReleasePlan{ + Spec: v1beta1.BatchReleaseSpec{ + ReleasePlan: v1beta1.ReleasePlan{ FailureThreshold: &percent, - Batches: []v1alpha1.ReleaseBatch{ + Batches: []v1beta1.ReleaseBatch{ { CanaryReplicas: percent, }, }, }, }, - Status: v1alpha1.BatchReleaseStatus{ - CanaryStatus: v1alpha1.BatchReleaseCanaryStatus{ + Status: v1beta1.BatchReleaseStatus{ + CanaryStatus: v1beta1.BatchReleaseCanaryStatus{ CurrentBatch: 0, NoNeedUpdateReplicas: pointer.Int32(5), }, @@ -396,7 +396,7 @@ func checkWorkloadInfo(stableInfo *util.WorkloadInfo, daemon *kruiseappsv1alpha1 Expect(stableInfo.Status.ObservedGeneration).Should(Equal(daemon.Status.ObservedGeneration)) } -func getControlInfo(release *v1alpha1.BatchRelease) string { +func getControlInfo(release *v1beta1.BatchRelease) string { owner, _ := json.Marshal(metav1.NewControllerRef(release, release.GetObjectKind().GroupVersionKind())) return string(owner) } diff --git a/pkg/controller/batchrelease/control/partitionstyle/deployment/control.go b/pkg/controller/batchrelease/control/partitionstyle/deployment/control.go index 828590e5..8ac3b1e1 100644 --- a/pkg/controller/batchrelease/control/partitionstyle/deployment/control.go +++ b/pkg/controller/batchrelease/control/partitionstyle/deployment/control.go @@ -19,7 +19,7 @@ package deployment import ( "context" - "github.com/openkruise/rollouts/api/v1alpha1" + "github.com/openkruise/rollouts/api/v1beta1" batchcontext "github.com/openkruise/rollouts/pkg/controller/batchrelease/context" "github.com/openkruise/rollouts/pkg/controller/batchrelease/control" "github.com/openkruise/rollouts/pkg/controller/batchrelease/control/partitionstyle" @@ -77,7 +77,7 @@ func (rc *realController) ListOwnedPods() ([]*corev1.Pod, error) { return rc.pods, err } -func (rc *realController) Initialize(release *v1alpha1.BatchRelease) error { +func (rc *realController) Initialize(release *v1beta1.BatchRelease) error { if deploymentutil.IsUnderRolloutControl(rc.object) { return nil // No need initialize again. } @@ -88,17 +88,17 @@ func (rc *realController) Initialize(release *v1alpha1.BatchRelease) error { if rc.object.Spec.Strategy.RollingUpdate != nil { rollingUpdate = rc.object.Spec.Strategy.RollingUpdate } - strategy = v1alpha1.DeploymentStrategy{ + strategy = v1beta1.DeploymentStrategy{ Paused: false, Partition: intstr.FromInt(0), - RollingStyle: v1alpha1.PartitionRollingStyle, + RollingStyle: v1beta1.PartitionRollingStyle, RollingUpdate: rollingUpdate, } d := rc.object.DeepCopy() patchData := patch.NewDeploymentPatch() - patchData.InsertLabel(v1alpha1.AdvancedDeploymentControlLabel, "true") - patchData.InsertAnnotation(v1alpha1.DeploymentStrategyAnnotation, util.DumpJSON(&strategy)) + patchData.InsertLabel(v1beta1.AdvancedDeploymentControlLabel, "true") + patchData.InsertAnnotation(v1beta1.DeploymentStrategyAnnotation, util.DumpJSON(&strategy)) patchData.InsertAnnotation(util.BatchReleaseControlAnnotation, util.DumpJSON(metav1.NewControllerRef( release, release.GetObjectKind().GroupVersionKind()))) @@ -123,11 +123,11 @@ func (rc *realController) UpgradeBatch(ctx *batchcontext.BatchContext) error { d := rc.object.DeepCopy() strategy.Partition = ctx.DesiredPartition patchData := patch.NewDeploymentPatch() - patchData.InsertAnnotation(v1alpha1.DeploymentStrategyAnnotation, util.DumpJSON(&strategy)) + patchData.InsertAnnotation(v1beta1.DeploymentStrategyAnnotation, util.DumpJSON(&strategy)) return rc.client.Patch(context.TODO(), d, patchData) } -func (rc *realController) Finalize(release *v1alpha1.BatchRelease) error { +func (rc *realController) Finalize(release *v1beta1.BatchRelease) error { if rc.object == nil || !deploymentutil.IsUnderRolloutControl(rc.object) { return nil // No need to finalize again. } @@ -137,17 +137,17 @@ func (rc *realController) Finalize(release *v1alpha1.BatchRelease) error { strategy := util.GetDeploymentStrategy(rc.object) patchData.UpdatePaused(false) patchData.UpdateStrategy(apps.DeploymentStrategy{Type: apps.RollingUpdateDeploymentStrategyType, RollingUpdate: strategy.RollingUpdate}) - patchData.DeleteAnnotation(v1alpha1.DeploymentStrategyAnnotation) - patchData.DeleteAnnotation(v1alpha1.DeploymentExtraStatusAnnotation) - patchData.DeleteLabel(v1alpha1.DeploymentStableRevisionLabel) - patchData.DeleteLabel(v1alpha1.AdvancedDeploymentControlLabel) + patchData.DeleteAnnotation(v1beta1.DeploymentStrategyAnnotation) + patchData.DeleteAnnotation(v1beta1.DeploymentExtraStatusAnnotation) + patchData.DeleteLabel(v1beta1.DeploymentStableRevisionLabel) + patchData.DeleteLabel(v1beta1.AdvancedDeploymentControlLabel) } d := rc.object.DeepCopy() patchData.DeleteAnnotation(util.BatchReleaseControlAnnotation) return rc.client.Patch(context.TODO(), d, patchData) } -func (rc *realController) CalculateBatchContext(release *v1alpha1.BatchRelease) (*batchcontext.BatchContext, error) { +func (rc *realController) CalculateBatchContext(release *v1beta1.BatchRelease) (*batchcontext.BatchContext, error) { rolloutID := release.Spec.ReleasePlan.RolloutID if rolloutID != "" { // if rollout-id is set, the pod will be patched batch label, @@ -181,6 +181,6 @@ func (rc *realController) getWorkloadInfo(d *apps.Deployment) *util.WorkloadInfo workloadInfo := util.ParseWorkload(d) extraStatus := util.GetDeploymentExtraStatus(d) workloadInfo.Status.UpdatedReadyReplicas = extraStatus.UpdatedReadyReplicas - workloadInfo.Status.StableRevision = d.Labels[v1alpha1.DeploymentStableRevisionLabel] + workloadInfo.Status.StableRevision = d.Labels[v1beta1.DeploymentStableRevisionLabel] return workloadInfo } diff --git a/pkg/controller/batchrelease/control/partitionstyle/deployment/control_test.go b/pkg/controller/batchrelease/control/partitionstyle/deployment/control_test.go index c0c25885..ef7892e1 100644 --- a/pkg/controller/batchrelease/control/partitionstyle/deployment/control_test.go +++ b/pkg/controller/batchrelease/control/partitionstyle/deployment/control_test.go @@ -25,7 +25,7 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" kruiseappsv1alpha1 "github.com/openkruise/kruise-api/apps/v1alpha1" - "github.com/openkruise/rollouts/api/v1alpha1" + "github.com/openkruise/rollouts/api/v1beta1" batchcontext "github.com/openkruise/rollouts/pkg/controller/batchrelease/context" "github.com/openkruise/rollouts/pkg/util" apps "k8s.io/api/apps/v1" @@ -104,9 +104,9 @@ var ( }, } - releaseDemo = &v1alpha1.BatchRelease{ + releaseDemo = &v1beta1.BatchRelease{ TypeMeta: metav1.TypeMeta{ - APIVersion: "rollouts.kruise.io/v1alpha1", + APIVersion: "rollouts.kruise.io/v1beta1", Kind: "BatchRelease", }, ObjectMeta: metav1.ObjectMeta{ @@ -114,10 +114,10 @@ var ( Namespace: deploymentKey.Namespace, UID: uuid.NewUUID(), }, - Spec: v1alpha1.BatchReleaseSpec{ - ReleasePlan: v1alpha1.ReleasePlan{ - FinalizingPolicy: v1alpha1.WaitResumeFinalizingPolicyType, - Batches: []v1alpha1.ReleaseBatch{ + Spec: v1beta1.BatchReleaseSpec{ + ReleasePlan: v1beta1.ReleasePlan{ + FinalizingPolicy: v1beta1.WaitResumeFinalizingPolicyType, + Batches: []v1beta1.ReleaseBatch{ { CanaryReplicas: intstr.FromString("10%"), }, @@ -129,16 +129,16 @@ var ( }, }, }, - TargetRef: v1alpha1.ObjectRef{ - WorkloadRef: &v1alpha1.WorkloadRef{ + TargetRef: v1beta1.ObjectRef{ + WorkloadRef: &v1beta1.WorkloadRef{ APIVersion: deploymentDemo.APIVersion, Kind: deploymentDemo.Kind, Name: deploymentDemo.Name, }, }, }, - Status: v1alpha1.BatchReleaseStatus{ - CanaryStatus: v1alpha1.BatchReleaseCanaryStatus{ + Status: v1beta1.BatchReleaseStatus{ + CanaryStatus: v1beta1.BatchReleaseCanaryStatus{ CurrentBatch: 1, }, }, @@ -147,7 +147,7 @@ var ( func init() { apps.AddToScheme(scheme) - v1alpha1.AddToScheme(scheme) + v1beta1.AddToScheme(scheme) kruiseappsv1alpha1.AddToScheme(scheme) } @@ -157,7 +157,7 @@ func TestCalculateBatchContext(t *testing.T) { percent := intstr.FromString("20%") cases := map[string]struct { workload func() *apps.Deployment - release func() *v1alpha1.BatchRelease + release func() *v1beta1.BatchRelease result *batchcontext.BatchContext }{ "noraml case": { @@ -165,13 +165,13 @@ func TestCalculateBatchContext(t *testing.T) { deployment := &apps.Deployment{ ObjectMeta: metav1.ObjectMeta{ Annotations: map[string]string{ - v1alpha1.DeploymentStrategyAnnotation: util.DumpJSON(&v1alpha1.DeploymentStrategy{ - RollingStyle: v1alpha1.PartitionRollingStyle, + v1beta1.DeploymentStrategyAnnotation: util.DumpJSON(&v1beta1.DeploymentStrategy{ + RollingStyle: v1beta1.PartitionRollingStyle, RollingUpdate: &apps.RollingUpdateDeployment{MaxUnavailable: &percent, MaxSurge: &percent}, Partition: percent, Paused: false, }), - v1alpha1.DeploymentExtraStatusAnnotation: util.DumpJSON(&v1alpha1.DeploymentExtraStatus{ + v1beta1.DeploymentExtraStatusAnnotation: util.DumpJSON(&v1beta1.DeploymentExtraStatus{ UpdatedReadyReplicas: 1, ExpectedUpdatedReplicas: 2, }), @@ -189,21 +189,21 @@ func TestCalculateBatchContext(t *testing.T) { } return deployment }, - release: func() *v1alpha1.BatchRelease { - r := &v1alpha1.BatchRelease{ - Spec: v1alpha1.BatchReleaseSpec{ - ReleasePlan: v1alpha1.ReleasePlan{ + release: func() *v1beta1.BatchRelease { + r := &v1beta1.BatchRelease{ + Spec: v1beta1.BatchReleaseSpec{ + ReleasePlan: v1beta1.ReleasePlan{ FailureThreshold: &percent, - FinalizingPolicy: v1alpha1.WaitResumeFinalizingPolicyType, - Batches: []v1alpha1.ReleaseBatch{ + FinalizingPolicy: v1beta1.WaitResumeFinalizingPolicyType, + Batches: []v1beta1.ReleaseBatch{ { CanaryReplicas: percent, }, }, }, }, - Status: v1alpha1.BatchReleaseStatus{ - CanaryStatus: v1alpha1.BatchReleaseCanaryStatus{ + Status: v1beta1.BatchReleaseStatus{ + CanaryStatus: v1beta1.BatchReleaseCanaryStatus{ CurrentBatch: 0, }, UpdateRevision: "version-2", @@ -229,13 +229,13 @@ func TestCalculateBatchContext(t *testing.T) { deployment := &apps.Deployment{ ObjectMeta: metav1.ObjectMeta{ Annotations: map[string]string{ - v1alpha1.DeploymentStrategyAnnotation: util.DumpJSON(&v1alpha1.DeploymentStrategy{ - RollingStyle: v1alpha1.PartitionRollingStyle, + v1beta1.DeploymentStrategyAnnotation: util.DumpJSON(&v1beta1.DeploymentStrategy{ + RollingStyle: v1beta1.PartitionRollingStyle, RollingUpdate: &apps.RollingUpdateDeployment{MaxUnavailable: &percent, MaxSurge: &percent}, Partition: intstr.FromString("20%"), Paused: false, }), - v1alpha1.DeploymentExtraStatusAnnotation: util.DumpJSON(&v1alpha1.DeploymentExtraStatus{ + v1beta1.DeploymentExtraStatusAnnotation: util.DumpJSON(&v1beta1.DeploymentExtraStatus{ UpdatedReadyReplicas: 4, ExpectedUpdatedReplicas: 4, }), @@ -253,21 +253,21 @@ func TestCalculateBatchContext(t *testing.T) { } return deployment }, - release: func() *v1alpha1.BatchRelease { - r := &v1alpha1.BatchRelease{ - Spec: v1alpha1.BatchReleaseSpec{ - ReleasePlan: v1alpha1.ReleasePlan{ + release: func() *v1beta1.BatchRelease { + r := &v1beta1.BatchRelease{ + Spec: v1beta1.BatchReleaseSpec{ + ReleasePlan: v1beta1.ReleasePlan{ FailureThreshold: &percent, - FinalizingPolicy: v1alpha1.WaitResumeFinalizingPolicyType, - Batches: []v1alpha1.ReleaseBatch{ + FinalizingPolicy: v1beta1.WaitResumeFinalizingPolicyType, + Batches: []v1beta1.ReleaseBatch{ { CanaryReplicas: intstr.FromString("90%"), }, }, }, }, - Status: v1alpha1.BatchReleaseStatus{ - CanaryStatus: v1alpha1.BatchReleaseCanaryStatus{ + Status: v1beta1.BatchReleaseStatus{ + CanaryStatus: v1beta1.BatchReleaseCanaryStatus{ CurrentBatch: 0, }, UpdateRevision: "version-2", @@ -350,8 +350,8 @@ func TestRealController(t *testing.T) { fetch = &apps.Deployment{} Expect(cli.Get(context.TODO(), deploymentKey, fetch)).NotTo(HaveOccurred()) Expect(fetch.Annotations[util.BatchReleaseControlAnnotation]).Should(Equal("")) - Expect(fetch.Annotations[v1alpha1.DeploymentStrategyAnnotation]).Should(Equal("")) - Expect(fetch.Annotations[v1alpha1.DeploymentExtraStatusAnnotation]).Should(Equal("")) + Expect(fetch.Annotations[v1beta1.DeploymentStrategyAnnotation]).Should(Equal("")) + Expect(fetch.Annotations[v1beta1.DeploymentExtraStatusAnnotation]).Should(Equal("")) Expect(fetch.Spec.Paused).Should(BeFalse()) Expect(fetch.Spec.Strategy.Type).Should(Equal(apps.RollingUpdateDeploymentStrategyType)) @@ -369,7 +369,7 @@ func checkWorkloadInfo(stableInfo *util.WorkloadInfo, clone *apps.Deployment) { Expect(stableInfo.Status.ObservedGeneration).Should(Equal(clone.Status.ObservedGeneration)) } -func getControlInfo(release *v1alpha1.BatchRelease) string { +func getControlInfo(release *v1beta1.BatchRelease) string { owner, _ := json.Marshal(metav1.NewControllerRef(release, release.GetObjectKind().GroupVersionKind())) return string(owner) } diff --git a/pkg/controller/batchrelease/control/partitionstyle/interface.go b/pkg/controller/batchrelease/control/partitionstyle/interface.go index 99fbacf0..c5a193fa 100644 --- a/pkg/controller/batchrelease/control/partitionstyle/interface.go +++ b/pkg/controller/batchrelease/control/partitionstyle/interface.go @@ -17,7 +17,7 @@ limitations under the License. package partitionstyle import ( - "github.com/openkruise/rollouts/api/v1alpha1" + "github.com/openkruise/rollouts/api/v1beta1" batchcontext "github.com/openkruise/rollouts/pkg/controller/batchrelease/context" "github.com/openkruise/rollouts/pkg/util" corev1 "k8s.io/api/core/v1" @@ -34,16 +34,16 @@ type Interface interface { ListOwnedPods() ([]*corev1.Pod, error) // CalculateBatchContext calculate current batch context // according to release plan and current status of workload. - CalculateBatchContext(release *v1alpha1.BatchRelease) (*batchcontext.BatchContext, error) + CalculateBatchContext(release *v1beta1.BatchRelease) (*batchcontext.BatchContext, error) // Initialize do something before rolling out, for example: // - claim the workload is under our control; // - other things related with specific type of workload, such as 100% partition settings. - Initialize(release *v1alpha1.BatchRelease) error + Initialize(release *v1beta1.BatchRelease) error // UpgradeBatch upgrade workload according current batch context. UpgradeBatch(ctx *batchcontext.BatchContext) error // Finalize do something after rolling out, for example: // - free the stable workload from rollout control; // - resume workload if we need. - Finalize(release *v1alpha1.BatchRelease) error + Finalize(release *v1beta1.BatchRelease) error } diff --git a/pkg/controller/batchrelease/control/partitionstyle/statefulset/control.go b/pkg/controller/batchrelease/control/partitionstyle/statefulset/control.go index fa8e3219..8d83a559 100644 --- a/pkg/controller/batchrelease/control/partitionstyle/statefulset/control.go +++ b/pkg/controller/batchrelease/control/partitionstyle/statefulset/control.go @@ -21,7 +21,7 @@ import ( "fmt" "math" - "github.com/openkruise/rollouts/api/v1alpha1" + "github.com/openkruise/rollouts/api/v1beta1" batchcontext "github.com/openkruise/rollouts/pkg/controller/batchrelease/context" "github.com/openkruise/rollouts/pkg/controller/batchrelease/control" "github.com/openkruise/rollouts/pkg/controller/batchrelease/control/partitionstyle" @@ -97,7 +97,7 @@ func (rc *realController) ListOwnedPods() ([]*corev1.Pod, error) { return rc.pods, err } -func (rc *realController) Initialize(release *v1alpha1.BatchRelease) error { +func (rc *realController) Initialize(release *v1beta1.BatchRelease) error { if control.IsControlledByBatchRelease(release, rc.object) { return nil } @@ -126,7 +126,7 @@ func (rc *realController) UpgradeBatch(ctx *batchcontext.BatchContext) error { return rc.client.Patch(context.TODO(), clone, client.RawPatch(types.MergePatchType, []byte(body))) } -func (rc *realController) Finalize(release *v1alpha1.BatchRelease) error { +func (rc *realController) Finalize(release *v1beta1.BatchRelease) error { if rc.object == nil { return nil } @@ -143,7 +143,7 @@ func (rc *realController) Finalize(release *v1alpha1.BatchRelease) error { return rc.client.Patch(context.TODO(), clone, client.RawPatch(types.MergePatchType, []byte(body))) } -func (rc *realController) CalculateBatchContext(release *v1alpha1.BatchRelease) (*batchcontext.BatchContext, error) { +func (rc *realController) CalculateBatchContext(release *v1beta1.BatchRelease) (*batchcontext.BatchContext, error) { rolloutID := release.Spec.ReleasePlan.RolloutID if rolloutID != "" { // if rollout-id is set, the pod will be patched batch label, diff --git a/pkg/controller/batchrelease/control/partitionstyle/statefulset/control_test.go b/pkg/controller/batchrelease/control/partitionstyle/statefulset/control_test.go index 59451c52..ab66f6c2 100644 --- a/pkg/controller/batchrelease/control/partitionstyle/statefulset/control_test.go +++ b/pkg/controller/batchrelease/control/partitionstyle/statefulset/control_test.go @@ -27,7 +27,7 @@ import ( appsv1pub "github.com/openkruise/kruise-api/apps/pub" kruiseappsv1alpha1 "github.com/openkruise/kruise-api/apps/v1alpha1" kruiseappsv1beta1 "github.com/openkruise/kruise-api/apps/v1beta1" - "github.com/openkruise/rollouts/api/v1alpha1" + "github.com/openkruise/rollouts/api/v1beta1" batchcontext "github.com/openkruise/rollouts/pkg/controller/batchrelease/context" "github.com/openkruise/rollouts/pkg/controller/batchrelease/labelpatch" "github.com/openkruise/rollouts/pkg/util" @@ -53,7 +53,7 @@ var ( } stsDemo = &kruiseappsv1beta1.StatefulSet{ TypeMeta: metav1.TypeMeta{ - APIVersion: "apps.kruise.io/v1alpha1", + APIVersion: "apps.kruise.io/v1beta1", Kind: "StatefulSet", }, ObjectMeta: metav1.ObjectMeta{ @@ -111,9 +111,9 @@ var ( }, } - releaseDemo = &v1alpha1.BatchRelease{ + releaseDemo = &v1beta1.BatchRelease{ TypeMeta: metav1.TypeMeta{ - APIVersion: "rollouts.kruise.io/v1alpha1", + APIVersion: "rollouts.kruise.io/v1beta1", Kind: "BatchRelease", }, ObjectMeta: metav1.ObjectMeta{ @@ -121,9 +121,9 @@ var ( Namespace: stsKey.Namespace, UID: uuid.NewUUID(), }, - Spec: v1alpha1.BatchReleaseSpec{ - ReleasePlan: v1alpha1.ReleasePlan{ - Batches: []v1alpha1.ReleaseBatch{ + Spec: v1beta1.BatchReleaseSpec{ + ReleasePlan: v1beta1.ReleasePlan{ + Batches: []v1beta1.ReleaseBatch{ { CanaryReplicas: intstr.FromString("10%"), }, @@ -135,16 +135,16 @@ var ( }, }, }, - TargetRef: v1alpha1.ObjectRef{ - WorkloadRef: &v1alpha1.WorkloadRef{ + TargetRef: v1beta1.ObjectRef{ + WorkloadRef: &v1beta1.WorkloadRef{ APIVersion: stsDemo.APIVersion, Kind: stsDemo.Kind, Name: stsDemo.Name, }, }, }, - Status: v1alpha1.BatchReleaseStatus{ - CanaryStatus: v1alpha1.BatchReleaseCanaryStatus{ + Status: v1beta1.BatchReleaseStatus{ + CanaryStatus: v1beta1.BatchReleaseCanaryStatus{ CurrentBatch: 0, }, }, @@ -155,7 +155,7 @@ func init() { rand.Seed(87076677) apps.AddToScheme(scheme) corev1.AddToScheme(scheme) - v1alpha1.AddToScheme(scheme) + v1beta1.AddToScheme(scheme) kruiseappsv1alpha1.AddToScheme(scheme) kruiseappsv1beta1.AddToScheme(scheme) } @@ -166,7 +166,7 @@ func TestCalculateBatchContextForNativeStatefulSet(t *testing.T) { percent := intstr.FromString("20%") cases := map[string]struct { workload func() *apps.StatefulSet - release func() *v1alpha1.BatchRelease + release func() *v1beta1.BatchRelease pods func() []*corev1.Pod result *batchcontext.BatchContext }{ @@ -206,24 +206,24 @@ func TestCalculateBatchContextForNativeStatefulSet(t *testing.T) { updatedReadyPods := generatePods(5, "update-version", "True") return append(stablePods, updatedReadyPods...) }, - release: func() *v1alpha1.BatchRelease { - r := &v1alpha1.BatchRelease{ + release: func() *v1beta1.BatchRelease { + r := &v1beta1.BatchRelease{ ObjectMeta: metav1.ObjectMeta{ Name: "test-br", Namespace: "test", }, - Spec: v1alpha1.BatchReleaseSpec{ - ReleasePlan: v1alpha1.ReleasePlan{ + Spec: v1beta1.BatchReleaseSpec{ + ReleasePlan: v1beta1.ReleasePlan{ FailureThreshold: &percent, - Batches: []v1alpha1.ReleaseBatch{ + Batches: []v1beta1.ReleaseBatch{ { CanaryReplicas: percent, }, }, }, }, - Status: v1alpha1.BatchReleaseStatus{ - CanaryStatus: v1alpha1.BatchReleaseCanaryStatus{ + Status: v1beta1.BatchReleaseStatus{ + CanaryStatus: v1beta1.BatchReleaseCanaryStatus{ CurrentBatch: 0, }, UpdateRevision: "update-version", @@ -281,24 +281,24 @@ func TestCalculateBatchContextForNativeStatefulSet(t *testing.T) { updatedReadyPods := generatePods(10, "update-version", "True") return append(stablePods, updatedReadyPods...) }, - release: func() *v1alpha1.BatchRelease { - r := &v1alpha1.BatchRelease{ + release: func() *v1beta1.BatchRelease { + r := &v1beta1.BatchRelease{ ObjectMeta: metav1.ObjectMeta{ Name: "test-br", Namespace: "test", }, - Spec: v1alpha1.BatchReleaseSpec{ - ReleasePlan: v1alpha1.ReleasePlan{ + Spec: v1beta1.BatchReleaseSpec{ + ReleasePlan: v1beta1.ReleasePlan{ FailureThreshold: &percent, - Batches: []v1alpha1.ReleaseBatch{ + Batches: []v1beta1.ReleaseBatch{ { CanaryReplicas: percent, }, }, }, }, - Status: v1alpha1.BatchReleaseStatus{ - CanaryStatus: v1alpha1.BatchReleaseCanaryStatus{ + Status: v1beta1.BatchReleaseStatus{ + CanaryStatus: v1beta1.BatchReleaseCanaryStatus{ CurrentBatch: 0, NoNeedUpdateReplicas: pointer.Int32(10), }, @@ -360,7 +360,7 @@ func TestCalculateBatchContextForAdvancedStatefulSet(t *testing.T) { percent := intstr.FromString("20%") cases := map[string]struct { workload func() *kruiseappsv1beta1.StatefulSet - release func() *v1alpha1.BatchRelease + release func() *v1beta1.BatchRelease pods func() []*corev1.Pod result *batchcontext.BatchContext }{ @@ -409,24 +409,24 @@ func TestCalculateBatchContextForAdvancedStatefulSet(t *testing.T) { updatedReadyPods := generatePods(5, "update-version", "True") return append(stablePods, updatedReadyPods...) }, - release: func() *v1alpha1.BatchRelease { - r := &v1alpha1.BatchRelease{ + release: func() *v1beta1.BatchRelease { + r := &v1beta1.BatchRelease{ ObjectMeta: metav1.ObjectMeta{ Name: "test-br", Namespace: "test", }, - Spec: v1alpha1.BatchReleaseSpec{ - ReleasePlan: v1alpha1.ReleasePlan{ + Spec: v1beta1.BatchReleaseSpec{ + ReleasePlan: v1beta1.ReleasePlan{ FailureThreshold: &percent, - Batches: []v1alpha1.ReleaseBatch{ + Batches: []v1beta1.ReleaseBatch{ { CanaryReplicas: percent, }, }, }, }, - Status: v1alpha1.BatchReleaseStatus{ - CanaryStatus: v1alpha1.BatchReleaseCanaryStatus{ + Status: v1beta1.BatchReleaseStatus{ + CanaryStatus: v1beta1.BatchReleaseCanaryStatus{ CurrentBatch: 0, }, UpdateRevision: "update-version", @@ -493,24 +493,24 @@ func TestCalculateBatchContextForAdvancedStatefulSet(t *testing.T) { updatedReadyPods := generatePods(10, "update-version", "True") return append(stablePods, updatedReadyPods...) }, - release: func() *v1alpha1.BatchRelease { - r := &v1alpha1.BatchRelease{ + release: func() *v1beta1.BatchRelease { + r := &v1beta1.BatchRelease{ ObjectMeta: metav1.ObjectMeta{ Name: "test-br", Namespace: "test", }, - Spec: v1alpha1.BatchReleaseSpec{ - ReleasePlan: v1alpha1.ReleasePlan{ + Spec: v1beta1.BatchReleaseSpec{ + ReleasePlan: v1beta1.ReleasePlan{ FailureThreshold: &percent, - Batches: []v1alpha1.ReleaseBatch{ + Batches: []v1beta1.ReleaseBatch{ { CanaryReplicas: percent, }, }, }, }, - Status: v1alpha1.BatchReleaseStatus{ - CanaryStatus: v1alpha1.BatchReleaseCanaryStatus{ + Status: v1beta1.BatchReleaseStatus{ + CanaryStatus: v1beta1.BatchReleaseCanaryStatus{ CurrentBatch: 0, NoNeedUpdateReplicas: pointer.Int32(10), }, @@ -629,7 +629,7 @@ func checkWorkloadInfo(stableInfo *util.WorkloadInfo, sts *kruiseappsv1beta1.Sta Expect(stableInfo.Status.ObservedGeneration).Should(Equal(sts.Status.ObservedGeneration)) } -func getControlInfo(release *v1alpha1.BatchRelease) string { +func getControlInfo(release *v1beta1.BatchRelease) string { owner, _ := json.Marshal(metav1.NewControllerRef(release, release.GetObjectKind().GroupVersionKind())) return string(owner) } diff --git a/pkg/controller/batchrelease/control/util.go b/pkg/controller/batchrelease/control/util.go index 12acc420..0c0e36bd 100644 --- a/pkg/controller/batchrelease/control/util.go +++ b/pkg/controller/batchrelease/control/util.go @@ -21,7 +21,7 @@ import ( "fmt" "strings" - "github.com/openkruise/rollouts/api/v1alpha1" + "github.com/openkruise/rollouts/api/v1beta1" "github.com/openkruise/rollouts/pkg/util" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -32,7 +32,7 @@ import ( ) // CalculateBatchReplicas return the planned updated replicas of current batch. -func CalculateBatchReplicas(release *v1alpha1.BatchRelease, workloadReplicas, currentBatch int) int { +func CalculateBatchReplicas(release *v1beta1.BatchRelease, workloadReplicas, currentBatch int) int { batchSize, _ := intstr.GetScaledValueFromIntOrPercent(&release.Spec.ReleasePlan.Batches[currentBatch].CanaryReplicas, workloadReplicas, true) if batchSize > workloadReplicas { klog.Warningf("releasePlan has wrong batch replicas, batches[%d].replicas %v is more than workload.replicas %v", currentBatch, batchSize, workloadReplicas) @@ -49,7 +49,7 @@ func CalculateBatchReplicas(release *v1alpha1.BatchRelease, workloadReplicas, cu // IsControlledByBatchRelease return true if // * object ownerReference has referred release; // * object has batchRelease control info annotation about release. -func IsControlledByBatchRelease(release *v1alpha1.BatchRelease, object client.Object) bool { +func IsControlledByBatchRelease(release *v1beta1.BatchRelease, object client.Object) bool { if owner := metav1.GetControllerOfNoCopy(object); owner != nil && owner.UID == release.UID { return true } @@ -64,7 +64,7 @@ func IsControlledByBatchRelease(release *v1alpha1.BatchRelease, object client.Ob } // BuildReleaseControlInfo return a NewControllerRef of release with escaped `"`. -func BuildReleaseControlInfo(release *v1alpha1.BatchRelease) string { +func BuildReleaseControlInfo(release *v1beta1.BatchRelease) string { owner, _ := json.Marshal(metav1.NewControllerRef(release, release.GetObjectKind().GroupVersionKind())) return strings.Replace(string(owner), `"`, `\"`, -1) } @@ -102,8 +102,8 @@ func GenerateNotFoundError(name, resource string) error { } // ShouldWaitResume return true if FinalizingPolicy is "waitResume". -func ShouldWaitResume(release *v1alpha1.BatchRelease) bool { - return release.Spec.ReleasePlan.FinalizingPolicy == v1alpha1.WaitResumeFinalizingPolicyType +func ShouldWaitResume(release *v1beta1.BatchRelease) bool { + return release.Spec.ReleasePlan.FinalizingPolicy == v1beta1.WaitResumeFinalizingPolicyType } // IsCurrentMoreThanOrEqualToDesired return true if current >= desired diff --git a/pkg/controller/batchrelease/control/util_test.go b/pkg/controller/batchrelease/control/util_test.go index baef4387..98f5c671 100644 --- a/pkg/controller/batchrelease/control/util_test.go +++ b/pkg/controller/batchrelease/control/util_test.go @@ -24,7 +24,7 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "github.com/openkruise/rollouts/api/v1alpha1" + "github.com/openkruise/rollouts/api/v1beta1" "github.com/openkruise/rollouts/pkg/util" apps "k8s.io/api/apps/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -96,10 +96,10 @@ func TestCalculateBatchReplicas(t *testing.T) { for name, cs := range cases { t.Run(name, func(t *testing.T) { - release := &v1alpha1.BatchRelease{ - Spec: v1alpha1.BatchReleaseSpec{ - ReleasePlan: v1alpha1.ReleasePlan{ - Batches: []v1alpha1.ReleaseBatch{ + release := &v1beta1.BatchRelease{ + Spec: v1beta1.BatchReleaseSpec{ + ReleasePlan: v1beta1.ReleasePlan{ + Batches: []v1beta1.ReleaseBatch{ { CanaryReplicas: cs.batchReplicas, }, @@ -116,9 +116,9 @@ func TestCalculateBatchReplicas(t *testing.T) { func TestIsControlledByBatchRelease(t *testing.T) { RegisterFailHandler(Fail) - release := &v1alpha1.BatchRelease{ + release := &v1beta1.BatchRelease{ TypeMeta: metav1.TypeMeta{ - APIVersion: "rollouts.kruise.io/v1alpha1", + APIVersion: "rollouts.kruise.io/v1beta1", Kind: "BatchRelease", }, ObjectMeta: metav1.ObjectMeta{ diff --git a/pkg/controller/batchrelease/labelpatch/filter.go b/pkg/controller/batchrelease/labelpatch/filter.go index f963bfef..315109b1 100644 --- a/pkg/controller/batchrelease/labelpatch/filter.go +++ b/pkg/controller/batchrelease/labelpatch/filter.go @@ -21,7 +21,7 @@ import ( "strconv" "strings" - "github.com/openkruise/rollouts/api/v1alpha1" + "github.com/openkruise/rollouts/api/v1beta1" batchcontext "github.com/openkruise/rollouts/pkg/controller/batchrelease/context" "github.com/openkruise/rollouts/pkg/util" corev1 "k8s.io/api/core/v1" @@ -60,7 +60,7 @@ func FilterPodsForUnorderedUpdate(pods []*corev1.Pod, ctx *batchcontext.BatchCon if !util.IsConsistentWithRevision(pod, ctx.UpdateRevision) { continue } - if pod.Labels[util.NoNeedUpdatePodLabel] == ctx.RolloutID && pod.Labels[v1alpha1.RolloutIDLabel] != ctx.RolloutID { + if pod.Labels[util.NoNeedUpdatePodLabel] == ctx.RolloutID && pod.Labels[v1beta1.RolloutIDLabel] != ctx.RolloutID { noNeedUpdate++ lowPriorityPods = append(lowPriorityPods, pod) } else { diff --git a/pkg/controller/batchrelease/labelpatch/patcher.go b/pkg/controller/batchrelease/labelpatch/patcher.go index 3f53b1e7..a0175b45 100644 --- a/pkg/controller/batchrelease/labelpatch/patcher.go +++ b/pkg/controller/batchrelease/labelpatch/patcher.go @@ -20,7 +20,7 @@ import ( "context" "fmt" - "github.com/openkruise/rollouts/api/v1alpha1" + "github.com/openkruise/rollouts/api/v1beta1" batchcontext "github.com/openkruise/rollouts/pkg/controller/batchrelease/context" "github.com/openkruise/rollouts/pkg/util" corev1 "k8s.io/api/core/v1" @@ -65,7 +65,7 @@ func (r *realPatcher) patchPodBatchLabel(pods []*corev1.Pod, ctx *batchcontext.B continue } - podRolloutID := pod.Labels[v1alpha1.RolloutIDLabel] + podRolloutID := pod.Labels[v1beta1.RolloutIDLabel] if pod.DeletionTimestamp.IsZero() && podRolloutID == ctx.RolloutID { patchedUpdatedReplicas++ } @@ -89,13 +89,13 @@ func (r *realPatcher) patchPodBatchLabel(pods []*corev1.Pod, ctx *batchcontext.B } // if it has been patched, just ignore - if pod.Labels[v1alpha1.RolloutIDLabel] == ctx.RolloutID { + if pod.Labels[v1beta1.RolloutIDLabel] == ctx.RolloutID { continue } clone := util.GetEmptyObjectWithKey(pod) by := fmt.Sprintf(`{"metadata":{"labels":{"%s":"%s","%s":"%d"}}}`, - v1alpha1.RolloutIDLabel, ctx.RolloutID, v1alpha1.RolloutBatchIDLabel, ctx.CurrentBatch+1) + v1beta1.RolloutIDLabel, ctx.RolloutID, v1beta1.RolloutBatchIDLabel, ctx.CurrentBatch+1) if err := r.Patch(context.TODO(), clone, client.RawPatch(types.StrategicMergePatchType, []byte(by))); err != nil { return err } diff --git a/pkg/controller/batchrelease/labelpatch/patcher_test.go b/pkg/controller/batchrelease/labelpatch/patcher_test.go index fb31cb4c..3ed8e145 100644 --- a/pkg/controller/batchrelease/labelpatch/patcher_test.go +++ b/pkg/controller/batchrelease/labelpatch/patcher_test.go @@ -23,7 +23,7 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "github.com/openkruise/rollouts/api/v1alpha1" + "github.com/openkruise/rollouts/api/v1beta1" batchcontext "github.com/openkruise/rollouts/pkg/controller/batchrelease/context" apps "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" @@ -156,7 +156,7 @@ func TestLabelPatcher(t *testing.T) { Expect(err).NotTo(HaveOccurred()) patched := 0 for _, pod := range podList.Items { - if pod.Labels[v1alpha1.RolloutIDLabel] == ctx.RolloutID { + if pod.Labels[v1beta1.RolloutIDLabel] == ctx.RolloutID { patched++ } } @@ -170,8 +170,8 @@ func TestLabelPatcher(t *testing.T) { func generatePods(ordinalBegin, ordinalEnd, labeled int32, rolloutID, batchID, version string) []*corev1.Pod { podsWithLabel := generateLabeledPods(map[string]string{ - v1alpha1.RolloutIDLabel: rolloutID, - v1alpha1.RolloutBatchIDLabel: batchID, + v1beta1.RolloutIDLabel: rolloutID, + v1beta1.RolloutBatchIDLabel: batchID, apps.ControllerRevisionHashLabelKey: version, }, int(labeled), int(ordinalBegin)) diff --git a/pkg/controller/deployment/controller.go b/pkg/controller/deployment/controller.go index 89515ea7..ec3023ed 100644 --- a/pkg/controller/deployment/controller.go +++ b/pkg/controller/deployment/controller.go @@ -45,7 +45,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/reconcile" "sigs.k8s.io/controller-runtime/pkg/source" - rolloutsv1alpha1 "github.com/openkruise/rollouts/api/v1alpha1" + rolloutsv1beta1 "github.com/openkruise/rollouts/api/v1beta1" deploymentutil "github.com/openkruise/rollouts/pkg/controller/deployment/util" "github.com/openkruise/rollouts/pkg/feature" "github.com/openkruise/rollouts/pkg/util" @@ -251,15 +251,15 @@ func (f *controllerFactory) NewController(deployment *appsv1.Deployment) *Deploy return nil } - strategy := rolloutsv1alpha1.DeploymentStrategy{} - strategyAnno := deployment.Annotations[rolloutsv1alpha1.DeploymentStrategyAnnotation] + strategy := rolloutsv1beta1.DeploymentStrategy{} + strategyAnno := deployment.Annotations[rolloutsv1beta1.DeploymentStrategyAnnotation] if err := json.Unmarshal([]byte(strategyAnno), &strategy); err != nil { klog.Errorf("Failed to unmarshal strategy for deployment %v: %v", klog.KObj(deployment), strategyAnno) return nil } // We do NOT process such deployment with canary rolling style - if strategy.RollingStyle == rolloutsv1alpha1.CanaryRollingStyle { + if strategy.RollingStyle == rolloutsv1beta1.CanaryRollingStyle { return nil } diff --git a/pkg/controller/deployment/deployment_controller.go b/pkg/controller/deployment/deployment_controller.go index 6150942e..f195a4ce 100644 --- a/pkg/controller/deployment/deployment_controller.go +++ b/pkg/controller/deployment/deployment_controller.go @@ -38,7 +38,7 @@ import ( "k8s.io/client-go/tools/record" "k8s.io/klog/v2" - rolloutsv1alpha1 "github.com/openkruise/rollouts/api/v1alpha1" + rolloutsv1beta1 "github.com/openkruise/rollouts/api/v1beta1" deploymentutil "github.com/openkruise/rollouts/pkg/controller/deployment/util" ) @@ -68,7 +68,7 @@ type DeploymentController struct { rsLister appslisters.ReplicaSetLister // we will use this strategy to replace spec.strategy of deployment - strategy rolloutsv1alpha1.DeploymentStrategy + strategy rolloutsv1beta1.DeploymentStrategy } // getReplicaSetsForDeployment uses ControllerRefManager to reconcile @@ -147,7 +147,7 @@ func (dc *DeploymentController) patchExtraStatus(deployment *apps.Deployment) er updatedReadyReplicas = newRS.Status.ReadyReplicas } - extraStatus := &rolloutsv1alpha1.DeploymentExtraStatus{ + extraStatus := &rolloutsv1beta1.DeploymentExtraStatus{ UpdatedReadyReplicas: updatedReadyReplicas, ExpectedUpdatedReplicas: deploymentutil.NewRSReplicasLimit(dc.strategy.Partition, deployment), } @@ -159,12 +159,12 @@ func (dc *DeploymentController) patchExtraStatus(deployment *apps.Deployment) er } extraStatusAnno := string(extraStatusByte) - if deployment.Annotations[rolloutsv1alpha1.DeploymentExtraStatusAnnotation] == extraStatusAnno { + if deployment.Annotations[rolloutsv1beta1.DeploymentExtraStatusAnnotation] == extraStatusAnno { return nil // no need to update } body := fmt.Sprintf(`{"metadata":{"annotations":{"%s":"%s"}}}`, - rolloutsv1alpha1.DeploymentExtraStatusAnnotation, + rolloutsv1beta1.DeploymentExtraStatusAnnotation, strings.Replace(extraStatusAnno, `"`, `\"`, -1)) _, err = dc.client.AppsV1().Deployments(deployment.Namespace). diff --git a/pkg/controller/deployment/deployment_controller_test.go b/pkg/controller/deployment/deployment_controller_test.go index 4a36a34e..b432f321 100644 --- a/pkg/controller/deployment/deployment_controller_test.go +++ b/pkg/controller/deployment/deployment_controller_test.go @@ -32,7 +32,7 @@ import ( "k8s.io/client-go/tools/record" "k8s.io/utils/pointer" - rolloutsv1alpha1 "github.com/openkruise/rollouts/api/v1alpha1" + rolloutsv1beta1 "github.com/openkruise/rollouts/api/v1beta1" "github.com/openkruise/rollouts/pkg/controller/deployment/util" ) @@ -198,7 +198,7 @@ func TestSyncDeployment(t *testing.T) { eventRecorder: fakeRecord, dLister: appslisters.NewDeploymentLister(dInformer.GetIndexer()), rsLister: appslisters.NewReplicaSetLister(rsInformer.GetIndexer()), - strategy: rolloutsv1alpha1.DeploymentStrategy{ + strategy: rolloutsv1beta1.DeploymentStrategy{ RollingUpdate: &apps.RollingUpdateDeployment{ MaxSurge: &test.maxSurge, MaxUnavailable: &test.maxUnavailable, diff --git a/pkg/controller/deployment/deployment_event_handler.go b/pkg/controller/deployment/deployment_event_handler.go index 23e98d4f..31a6e449 100644 --- a/pkg/controller/deployment/deployment_event_handler.go +++ b/pkg/controller/deployment/deployment_event_handler.go @@ -11,7 +11,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/event" "sigs.k8s.io/controller-runtime/pkg/reconcile" - "github.com/openkruise/rollouts/api/v1alpha1" + "github.com/openkruise/rollouts/api/v1beta1" "github.com/openkruise/rollouts/pkg/webhook/util/configuration" ) @@ -53,7 +53,7 @@ func (m MutatingWebhookEventHandler) Delete(evt event.DeleteEvent, q workqueue.R func (m MutatingWebhookEventHandler) enqueue(q workqueue.RateLimitingInterface) { deploymentLister := appsv1.DeploymentList{} - err := m.List(context.TODO(), &deploymentLister, client.MatchingLabels(map[string]string{v1alpha1.AdvancedDeploymentControlLabel: "true"})) + err := m.List(context.TODO(), &deploymentLister, client.MatchingLabels(map[string]string{v1beta1.AdvancedDeploymentControlLabel: "true"})) if err != nil { klog.Errorf("Failed to list deployment, error: %v", err) } diff --git a/pkg/controller/deployment/rolling_test.go b/pkg/controller/deployment/rolling_test.go index b6f3c7fb..51ff19b3 100644 --- a/pkg/controller/deployment/rolling_test.go +++ b/pkg/controller/deployment/rolling_test.go @@ -32,7 +32,7 @@ import ( "k8s.io/client-go/tools/record" "k8s.io/utils/pointer" - rolloutsv1alpha1 "github.com/openkruise/rollouts/api/v1alpha1" + rolloutsv1beta1 "github.com/openkruise/rollouts/api/v1beta1" ) func newDControllerRef(d *apps.Deployment) *metav1.OwnerReference { @@ -258,7 +258,7 @@ func TestReconcileNewReplicaSet(t *testing.T) { dc := &DeploymentController{ client: fakeClient, eventRecorder: fakeRecord, - strategy: rolloutsv1alpha1.DeploymentStrategy{ + strategy: rolloutsv1beta1.DeploymentStrategy{ RollingUpdate: &apps.RollingUpdateDeployment{ MaxSurge: &test.maxSurge, }, @@ -384,7 +384,7 @@ func TestReconcileOldReplicaSet(t *testing.T) { dc := &DeploymentController{ client: fakeClient, eventRecorder: fakeRecord, - strategy: rolloutsv1alpha1.DeploymentStrategy{ + strategy: rolloutsv1beta1.DeploymentStrategy{ RollingUpdate: &apps.RollingUpdateDeployment{ MaxSurge: &test.maxSurge, MaxUnavailable: &test.maxUnavailable, diff --git a/pkg/controller/deployment/sync.go b/pkg/controller/deployment/sync.go index afa6c4df..15c89e16 100644 --- a/pkg/controller/deployment/sync.go +++ b/pkg/controller/deployment/sync.go @@ -31,7 +31,7 @@ import ( "k8s.io/klog/v2" "k8s.io/utils/integer" - rolloutsv1alpha1 "github.com/openkruise/rollouts/api/v1alpha1" + rolloutsv1beta1 "github.com/openkruise/rollouts/api/v1beta1" deploymentutil "github.com/openkruise/rollouts/pkg/controller/deployment/util" "github.com/openkruise/rollouts/pkg/util" labelsutil "github.com/openkruise/rollouts/pkg/util/labels" @@ -476,7 +476,7 @@ func (dc *DeploymentController) syncDeploymentStatus(ctx context.Context, allRSs } // calculateStatus calculates the latest status for the provided deployment by looking into the provided replica sets. -func calculateStatus(allRSs []*apps.ReplicaSet, newRS *apps.ReplicaSet, deployment *apps.Deployment, strategy *rolloutsv1alpha1.DeploymentStrategy) apps.DeploymentStatus { +func calculateStatus(allRSs []*apps.ReplicaSet, newRS *apps.ReplicaSet, deployment *apps.Deployment, strategy *rolloutsv1beta1.DeploymentStrategy) apps.DeploymentStatus { availableReplicas := deploymentutil.GetAvailableReplicaCountForReplicaSets(allRSs) totalReplicas := deploymentutil.GetReplicaCountForReplicaSets(allRSs) unavailableReplicas := totalReplicas - availableReplicas diff --git a/pkg/controller/deployment/util/deployment_util.go b/pkg/controller/deployment/util/deployment_util.go index 0b904d52..79a7539e 100644 --- a/pkg/controller/deployment/util/deployment_util.go +++ b/pkg/controller/deployment/util/deployment_util.go @@ -35,7 +35,7 @@ import ( "k8s.io/klog/v2" "k8s.io/utils/integer" - rolloutsv1alpha1 "github.com/openkruise/rollouts/api/v1alpha1" + rolloutsv1beta1 "github.com/openkruise/rollouts/api/v1beta1" "github.com/openkruise/rollouts/pkg/util" ) @@ -201,7 +201,7 @@ func Revision(obj runtime.Object) (int64, error) { // SetNewReplicaSetAnnotations sets new replica set's annotations appropriately by updating its revision and // copying required deployment annotations to it; it returns true if replica set's annotation is changed. -func SetNewReplicaSetAnnotations(deployment *apps.Deployment, newRS *apps.ReplicaSet, strategy *rolloutsv1alpha1.DeploymentStrategy, newRevision string, exists bool, revHistoryLimitInChars int) bool { +func SetNewReplicaSetAnnotations(deployment *apps.Deployment, newRS *apps.ReplicaSet, strategy *rolloutsv1beta1.DeploymentStrategy, newRevision string, exists bool, revHistoryLimitInChars int) bool { // First, copy deployment's annotations (except for apply and revision annotations) annotationChanged := copyDeploymentAnnotationsToReplicaSet(deployment, newRS) // Then, update replica set's revision annotation @@ -383,7 +383,7 @@ func ReplicasAnnotationsNeedUpdate(rs *apps.ReplicaSet, desiredReplicas, maxRepl } // MaxUnavailable returns the maximum unavailable pods a rolling deployment can take. -func MaxUnavailable(deployment *apps.Deployment, strategy *rolloutsv1alpha1.DeploymentStrategy) int32 { +func MaxUnavailable(deployment *apps.Deployment, strategy *rolloutsv1beta1.DeploymentStrategy) int32 { if strategy == nil || strategy.RollingUpdate == nil || *(deployment.Spec.Replicas) == 0 { return int32(0) } @@ -396,7 +396,7 @@ func MaxUnavailable(deployment *apps.Deployment, strategy *rolloutsv1alpha1.Depl } // MinAvailable returns the minimum available pods of a given deployment -func MinAvailable(deployment *apps.Deployment, strategy *rolloutsv1alpha1.DeploymentStrategy) int32 { +func MinAvailable(deployment *apps.Deployment, strategy *rolloutsv1beta1.DeploymentStrategy) int32 { if strategy == nil || strategy.RollingUpdate == nil { return int32(0) } @@ -404,7 +404,7 @@ func MinAvailable(deployment *apps.Deployment, strategy *rolloutsv1alpha1.Deploy } // MaxSurge returns the maximum surge pods a rolling deployment can take. -func MaxSurge(deployment *apps.Deployment, strategy *rolloutsv1alpha1.DeploymentStrategy) int32 { +func MaxSurge(deployment *apps.Deployment, strategy *rolloutsv1beta1.DeploymentStrategy) int32 { if strategy == nil || strategy.RollingUpdate == nil { return int32(0) } @@ -416,7 +416,7 @@ func MaxSurge(deployment *apps.Deployment, strategy *rolloutsv1alpha1.Deployment // GetProportion will estimate the proportion for the provided replica set using 1. the current size // of the parent deployment, 2. the replica count that needs be added on the replica sets of the // deployment, and 3. the total replicas added in the replica sets of the deployment so far. -func GetProportion(rs *apps.ReplicaSet, d apps.Deployment, strategy *rolloutsv1alpha1.DeploymentStrategy, deploymentReplicasToAdd, deploymentReplicasAdded int32) int32 { +func GetProportion(rs *apps.ReplicaSet, d apps.Deployment, strategy *rolloutsv1beta1.DeploymentStrategy, deploymentReplicasToAdd, deploymentReplicasAdded int32) int32 { if rs == nil || *(rs.Spec.Replicas) == 0 || deploymentReplicasToAdd == 0 || deploymentReplicasToAdd == deploymentReplicasAdded { return int32(0) } @@ -438,7 +438,7 @@ func GetProportion(rs *apps.ReplicaSet, d apps.Deployment, strategy *rolloutsv1a // getReplicaSetFraction estimates the fraction of replicas a replica set can have in // 1. a scaling event during a rollout or 2. when scaling a paused deployment. -func getReplicaSetFraction(rs apps.ReplicaSet, d apps.Deployment, strategy *rolloutsv1alpha1.DeploymentStrategy) int32 { +func getReplicaSetFraction(rs apps.ReplicaSet, d apps.Deployment, strategy *rolloutsv1beta1.DeploymentStrategy) int32 { // If we are scaling down to zero then the fraction of this replica set is its whole size (negative) if *(d.Spec.Replicas) == int32(0) { return -*(rs.Spec.Replicas) @@ -705,7 +705,7 @@ func DeploymentTimedOut(deployment *apps.Deployment, newStatus *apps.DeploymentS // When one of the followings is true, we're rolling out the deployment; otherwise, we're scaling it. // 1) The new RS is saturated: newRS's replicas == deployment's replicas // 2) Max number of pods allowed is reached: deployment's replicas + maxSurge == all RSs' replicas -func NewRSNewReplicas(deployment *apps.Deployment, allRSs []*apps.ReplicaSet, newRS *apps.ReplicaSet, strategy *rolloutsv1alpha1.DeploymentStrategy) (int32, error) { +func NewRSNewReplicas(deployment *apps.Deployment, allRSs []*apps.ReplicaSet, newRS *apps.ReplicaSet, strategy *rolloutsv1beta1.DeploymentStrategy) (int32, error) { // Find the total number of pods currentPodCount := GetReplicaCountForReplicaSets(allRSs) switch { @@ -959,7 +959,7 @@ func DeploymentRolloutSatisfied(deployment *apps.Deployment, partition intstruti // NewRSReplicasLowerBound ensure that newReplicasLowerBound is greater than 0 when create newRS // unless deployment is 0 or MaxSurge > 0, this is because if we set new replicas as 0, the native // deployment controller will flight with ours. -func NewRSReplicasLowerBound(deployment *apps.Deployment, strategy *rolloutsv1alpha1.DeploymentStrategy) int32 { +func NewRSReplicasLowerBound(deployment *apps.Deployment, strategy *rolloutsv1beta1.DeploymentStrategy) int32 { if MaxSurge(deployment, strategy) > 0 { return int32(0) } diff --git a/pkg/controller/deployment/util/deployment_util_test.go b/pkg/controller/deployment/util/deployment_util_test.go index ca17d11f..32931bad 100644 --- a/pkg/controller/deployment/util/deployment_util_test.go +++ b/pkg/controller/deployment/util/deployment_util_test.go @@ -34,7 +34,7 @@ import ( "k8s.io/utils/integer" "k8s.io/utils/pointer" - rolloutsv1alpha1 "github.com/openkruise/rollouts/api/v1alpha1" + rolloutsv1beta1 "github.com/openkruise/rollouts/api/v1beta1" ) func newDControllerRef(d *apps.Deployment) *metav1.OwnerReference { @@ -542,7 +542,7 @@ func TestNewRSNewReplicas(t *testing.T) { for _, test := range tests { t.Run(test.Name, func(t *testing.T) { *(newDeployment.Spec.Replicas) = test.depReplicas - strategy := &rolloutsv1alpha1.DeploymentStrategy{ + strategy := &rolloutsv1beta1.DeploymentStrategy{ RollingUpdate: &apps.RollingUpdateDeployment{ MaxUnavailable: func(i int) *intstr.IntOrString { x := intstr.FromInt(i) @@ -1055,7 +1055,7 @@ func TestMaxUnavailable(t *testing.T) { for _, test := range tests { t.Log(test.name) t.Run(test.name, func(t *testing.T) { - strategy := rolloutsv1alpha1.DeploymentStrategy{ + strategy := rolloutsv1beta1.DeploymentStrategy{ RollingUpdate: test.deployment.Spec.Strategy.RollingUpdate, } maxUnavailable := MaxUnavailable(&test.deployment, &strategy) @@ -1080,7 +1080,7 @@ func TestAnnotationUtils(t *testing.T) { for i := 10; i < 20; i++ { nextRevision := fmt.Sprintf("%d", i+1) - strategy := rolloutsv1alpha1.DeploymentStrategy{ + strategy := rolloutsv1beta1.DeploymentStrategy{ RollingUpdate: tDeployment.Spec.Strategy.RollingUpdate, } SetNewReplicaSetAnnotations(&tDeployment, &tRS, &strategy, nextRevision, true, 5) diff --git a/pkg/controller/rollout/rollout_canary.go b/pkg/controller/rollout/rollout_canary.go index 9cd18e13..3e3c0599 100644 --- a/pkg/controller/rollout/rollout_canary.go +++ b/pkg/controller/rollout/rollout_canary.go @@ -23,7 +23,7 @@ import ( "strconv" "time" - "github.com/openkruise/rollouts/api/v1alpha1" + "github.com/openkruise/rollouts/api/v1beta1" "github.com/openkruise/rollouts/pkg/trafficrouting" "github.com/openkruise/rollouts/pkg/util" corev1 "k8s.io/api/core/v1" @@ -83,20 +83,20 @@ func (m *canaryReleaseManager) runCanary(c *RolloutContext) error { } } switch canaryStatus.CurrentStepState { - case v1alpha1.CanaryStepStateUpgrade: - klog.Infof("rollout(%s/%s) run canary strategy, and state(%s)", c.Rollout.Namespace, c.Rollout.Name, v1alpha1.CanaryStepStateUpgrade) + case v1beta1.CanaryStepStateUpgrade: + klog.Infof("rollout(%s/%s) run canary strategy, and state(%s)", c.Rollout.Namespace, c.Rollout.Name, v1beta1.CanaryStepStateUpgrade) done, err := m.doCanaryUpgrade(c) if err != nil { return err } else if done { - canaryStatus.CurrentStepState = v1alpha1.CanaryStepStateTrafficRouting + canaryStatus.CurrentStepState = v1beta1.CanaryStepStateTrafficRouting canaryStatus.LastUpdateTime = &metav1.Time{Time: time.Now()} klog.Infof("rollout(%s/%s) step(%d) state from(%s) -> to(%s)", c.Rollout.Namespace, c.Rollout.Name, - canaryStatus.CurrentStepIndex, v1alpha1.CanaryStepStateUpgrade, canaryStatus.CurrentStepState) + canaryStatus.CurrentStepIndex, v1beta1.CanaryStepStateUpgrade, canaryStatus.CurrentStepState) } - case v1alpha1.CanaryStepStateTrafficRouting: - klog.Infof("rollout(%s/%s) run canary strategy, and state(%s)", c.Rollout.Namespace, c.Rollout.Name, v1alpha1.CanaryStepStateTrafficRouting) + case v1beta1.CanaryStepStateTrafficRouting: + klog.Infof("rollout(%s/%s) run canary strategy, and state(%s)", c.Rollout.Namespace, c.Rollout.Name, v1beta1.CanaryStepStateTrafficRouting) tr := newTrafficRoutingContext(c) done, err := m.trafficRoutingManager.DoTrafficRouting(tr) c.NewStatus.CanaryStatus.LastUpdateTime = tr.LastUpdateTime @@ -104,55 +104,55 @@ func (m *canaryReleaseManager) runCanary(c *RolloutContext) error { return err } else if done { canaryStatus.LastUpdateTime = &metav1.Time{Time: time.Now()} - canaryStatus.CurrentStepState = v1alpha1.CanaryStepStateMetricsAnalysis + canaryStatus.CurrentStepState = v1beta1.CanaryStepStateMetricsAnalysis klog.Infof("rollout(%s/%s) step(%d) state from(%s) -> to(%s)", c.Rollout.Namespace, c.Rollout.Name, - canaryStatus.CurrentStepIndex, v1alpha1.CanaryStepStateTrafficRouting, canaryStatus.CurrentStepState) + canaryStatus.CurrentStepIndex, v1beta1.CanaryStepStateTrafficRouting, canaryStatus.CurrentStepState) } expectedTime := time.Now().Add(time.Duration(defaultGracePeriodSeconds) * time.Second) c.RecheckTime = &expectedTime - case v1alpha1.CanaryStepStateMetricsAnalysis: - klog.Infof("rollout(%s/%s) run canary strategy, and state(%s)", c.Rollout.Namespace, c.Rollout.Name, v1alpha1.CanaryStepStateMetricsAnalysis) + case v1beta1.CanaryStepStateMetricsAnalysis: + klog.Infof("rollout(%s/%s) run canary strategy, and state(%s)", c.Rollout.Namespace, c.Rollout.Name, v1beta1.CanaryStepStateMetricsAnalysis) done, err := m.doCanaryMetricsAnalysis(c) if err != nil { return err } else if done { - canaryStatus.CurrentStepState = v1alpha1.CanaryStepStatePaused + canaryStatus.CurrentStepState = v1beta1.CanaryStepStatePaused klog.Infof("rollout(%s/%s) step(%d) state from(%s) -> to(%s)", c.Rollout.Namespace, c.Rollout.Name, - canaryStatus.CurrentStepIndex, v1alpha1.CanaryStepStateMetricsAnalysis, canaryStatus.CurrentStepState) + canaryStatus.CurrentStepIndex, v1beta1.CanaryStepStateMetricsAnalysis, canaryStatus.CurrentStepState) } - case v1alpha1.CanaryStepStatePaused: - klog.Infof("rollout(%s/%s) run canary strategy, and state(%s)", c.Rollout.Namespace, c.Rollout.Name, v1alpha1.CanaryStepStatePaused) + case v1beta1.CanaryStepStatePaused: + klog.Infof("rollout(%s/%s) run canary strategy, and state(%s)", c.Rollout.Namespace, c.Rollout.Name, v1beta1.CanaryStepStatePaused) done, err := m.doCanaryPaused(c) if err != nil { return err } else if done { canaryStatus.LastUpdateTime = &metav1.Time{Time: time.Now()} - canaryStatus.CurrentStepState = v1alpha1.CanaryStepStateReady + canaryStatus.CurrentStepState = v1beta1.CanaryStepStateReady klog.Infof("rollout(%s/%s) step(%d) state from(%s) -> to(%s)", c.Rollout.Namespace, c.Rollout.Name, - canaryStatus.CurrentStepIndex, v1alpha1.CanaryStepStatePaused, canaryStatus.CurrentStepState) + canaryStatus.CurrentStepIndex, v1beta1.CanaryStepStatePaused, canaryStatus.CurrentStepState) } - case v1alpha1.CanaryStepStateReady: - klog.Infof("rollout(%s/%s) run canary strategy, and state(%s)", c.Rollout.Namespace, c.Rollout.Name, v1alpha1.CanaryStepStateReady) + case v1beta1.CanaryStepStateReady: + klog.Infof("rollout(%s/%s) run canary strategy, and state(%s)", c.Rollout.Namespace, c.Rollout.Name, v1beta1.CanaryStepStateReady) // run next step if len(c.Rollout.Spec.Strategy.Canary.Steps) > int(canaryStatus.CurrentStepIndex) { canaryStatus.LastUpdateTime = &metav1.Time{Time: time.Now()} canaryStatus.CurrentStepIndex++ - canaryStatus.CurrentStepState = v1alpha1.CanaryStepStateUpgrade + canaryStatus.CurrentStepState = v1beta1.CanaryStepStateUpgrade klog.Infof("rollout(%s/%s) canary step from(%d) -> to(%d)", c.Rollout.Namespace, c.Rollout.Name, canaryStatus.CurrentStepIndex-1, canaryStatus.CurrentStepIndex) } else { klog.Infof("rollout(%s/%s) canary run all steps, and completed", c.Rollout.Namespace, c.Rollout.Name) canaryStatus.LastUpdateTime = &metav1.Time{Time: time.Now()} - canaryStatus.CurrentStepState = v1alpha1.CanaryStepStateCompleted + canaryStatus.CurrentStepState = v1beta1.CanaryStepStateCompleted return nil } klog.Infof("rollout(%s/%s) step(%d) state from(%s) -> to(%s)", c.Rollout.Namespace, c.Rollout.Name, - canaryStatus.CurrentStepIndex, v1alpha1.CanaryStepStateReady, canaryStatus.CurrentStepState) + canaryStatus.CurrentStepIndex, v1beta1.CanaryStepStateReady, canaryStatus.CurrentStepState) // canary completed - case v1alpha1.CanaryStepStateCompleted: - klog.Infof("rollout(%s/%s) run canary strategy, and state(%s)", c.Rollout.Namespace, c.Rollout.Name, v1alpha1.CanaryStepStateCompleted) + case v1beta1.CanaryStepStateCompleted: + klog.Infof("rollout(%s/%s) run canary strategy, and state(%s)", c.Rollout.Namespace, c.Rollout.Name, v1beta1.CanaryStepStateCompleted) } return nil @@ -162,7 +162,7 @@ func (m *canaryReleaseManager) doCanaryUpgrade(c *RolloutContext) (bool, error) // verify whether batchRelease configuration is the latest steps := len(c.Rollout.Spec.Strategy.Canary.Steps) canaryStatus := c.NewStatus.CanaryStatus - cond := util.GetRolloutCondition(*c.NewStatus, v1alpha1.RolloutConditionProgressing) + cond := util.GetRolloutCondition(*c.NewStatus, v1beta1.RolloutConditionProgressing) cond.Message = fmt.Sprintf("Rollout is in step(%d/%d), and upgrade workload to new version", canaryStatus.CurrentStepIndex, steps) c.NewStatus.Message = cond.Message // run batch release to upgrade the workloads @@ -178,7 +178,7 @@ func (m *canaryReleaseManager) doCanaryUpgrade(c *RolloutContext) (bool, error) return false, nil } // check whether batchRelease is ready(whether new pods is ready.) - if br.Status.CanaryStatus.CurrentBatchState != v1alpha1.ReadyBatchState || + if br.Status.CanaryStatus.CurrentBatchState != v1beta1.ReadyBatchState || br.Status.CanaryStatus.CurrentBatch+1 < canaryStatus.CurrentStepIndex { klog.Infof("rollout(%s/%s) batchRelease status(%s) is not ready, and wait a moment", c.Rollout.Namespace, c.Rollout.Name, util.DumpJSON(br.Status)) return false, nil @@ -205,7 +205,7 @@ func (m *canaryReleaseManager) doCanaryPaused(c *RolloutContext) (bool, error) { return true, nil } } - cond := util.GetRolloutCondition(*c.NewStatus, v1alpha1.RolloutConditionProgressing) + cond := util.GetRolloutCondition(*c.NewStatus, v1beta1.RolloutConditionProgressing) // need manual confirmation if currentStep.Pause.Duration == nil { klog.Infof("rollout(%s/%s) don't set pause duration, and need manual confirmation", c.Rollout.Namespace, c.Rollout.Name) @@ -289,7 +289,7 @@ func (m *canaryReleaseManager) removeRolloutProgressingAnnotation(c *RolloutCont return nil } -func (m *canaryReleaseManager) runBatchRelease(rollout *v1alpha1.Rollout, rolloutId string, batch int32, isRollback bool) (bool, *v1alpha1.BatchRelease, error) { +func (m *canaryReleaseManager) runBatchRelease(rollout *v1beta1.Rollout, rolloutId string, batch int32, isRollback bool) (bool, *v1beta1.BatchRelease, error) { batch = batch - 1 br, err := m.fetchBatchRelease(rollout.Namespace, rollout.Name) if errors.IsNotFound(err) { @@ -330,37 +330,37 @@ func (m *canaryReleaseManager) runBatchRelease(rollout *v1alpha1.Rollout, rollou return false, br, nil } -func (m *canaryReleaseManager) fetchBatchRelease(ns, name string) (*v1alpha1.BatchRelease, error) { - br := &v1alpha1.BatchRelease{} +func (m *canaryReleaseManager) fetchBatchRelease(ns, name string) (*v1beta1.BatchRelease, error) { + br := &v1beta1.BatchRelease{} // batchRelease.name is equal related rollout.name err := m.Get(context.TODO(), client.ObjectKey{Namespace: ns, Name: name}, br) return br, err } -func createBatchRelease(rollout *v1alpha1.Rollout, rolloutID string, batch int32, isRollback bool) *v1alpha1.BatchRelease { - var batches []v1alpha1.ReleaseBatch +func createBatchRelease(rollout *v1beta1.Rollout, rolloutID string, batch int32, isRollback bool) *v1beta1.BatchRelease { + var batches []v1beta1.ReleaseBatch for _, step := range rollout.Spec.Strategy.Canary.Steps { if step.Replicas == nil { - batches = append(batches, v1alpha1.ReleaseBatch{CanaryReplicas: intstr.FromString(strconv.Itoa(int(*step.Weight)) + "%")}) + batches = append(batches, v1beta1.ReleaseBatch{CanaryReplicas: intstr.FromString(strconv.Itoa(int(*step.Weight)) + "%")}) } else { - batches = append(batches, v1alpha1.ReleaseBatch{CanaryReplicas: *step.Replicas}) + batches = append(batches, v1beta1.ReleaseBatch{CanaryReplicas: *step.Replicas}) } } - br := &v1alpha1.BatchRelease{ + br := &v1beta1.BatchRelease{ ObjectMeta: metav1.ObjectMeta{ Namespace: rollout.Namespace, Name: rollout.Name, OwnerReferences: []metav1.OwnerReference{*metav1.NewControllerRef(rollout, rolloutControllerKind)}, }, - Spec: v1alpha1.BatchReleaseSpec{ - TargetRef: v1alpha1.ObjectRef{ - WorkloadRef: &v1alpha1.WorkloadRef{ + Spec: v1beta1.BatchReleaseSpec{ + TargetRef: v1beta1.ObjectRef{ + WorkloadRef: &v1beta1.WorkloadRef{ APIVersion: rollout.Spec.ObjectRef.WorkloadRef.APIVersion, Kind: rollout.Spec.ObjectRef.WorkloadRef.Kind, Name: rollout.Spec.ObjectRef.WorkloadRef.Name, }, }, - ReleasePlan: v1alpha1.ReleasePlan{ + ReleasePlan: v1beta1.ReleasePlan{ Batches: batches, RolloutID: rolloutID, BatchPartition: utilpointer.Int32Ptr(batch), @@ -371,10 +371,10 @@ func createBatchRelease(rollout *v1alpha1.Rollout, rolloutID string, batch int32 } annotations := map[string]string{} if isRollback { - annotations[v1alpha1.RollbackInBatchAnnotation] = rollout.Annotations[v1alpha1.RollbackInBatchAnnotation] + annotations[v1beta1.RollbackInBatchAnnotation] = rollout.Annotations[v1beta1.RollbackInBatchAnnotation] } - if style, ok := rollout.Annotations[v1alpha1.RolloutStyleAnnotation]; ok { - annotations[v1alpha1.RolloutStyleAnnotation] = style + if style, ok := rollout.Annotations[v1beta1.RolloutStyleAnnotation]; ok { + annotations[v1beta1.RolloutStyleAnnotation] = style } if len(annotations) > 0 { br.Annotations = annotations @@ -383,7 +383,7 @@ func createBatchRelease(rollout *v1alpha1.Rollout, rolloutID string, batch int32 } func (m *canaryReleaseManager) removeBatchRelease(c *RolloutContext) (bool, error) { - batch := &v1alpha1.BatchRelease{} + batch := &v1beta1.BatchRelease{} err := m.Get(context.TODO(), client.ObjectKey{Namespace: c.Rollout.Namespace, Name: c.Rollout.Name}, batch) if err != nil && errors.IsNotFound(err) { return true, nil @@ -418,7 +418,7 @@ func (m *canaryReleaseManager) finalizingBatchRelease(c *RolloutContext) (bool, // The Completed phase means batchRelease controller has processed all it // should process. If BatchRelease phase is completed, we can do nothing. if br.Spec.ReleasePlan.BatchPartition == nil && - br.Status.Phase == v1alpha1.RolloutPhaseCompleted { + br.Status.Phase == v1beta1.RolloutPhaseCompleted { klog.Infof("rollout(%s/%s) finalizing batchRelease(%s) done", c.Rollout.Namespace, c.Rollout.Name, util.DumpJSON(br.Status)) return true, nil } @@ -431,7 +431,7 @@ func (m *canaryReleaseManager) finalizingBatchRelease(c *RolloutContext) (bool, // - If checkReady is false, finalizing policy must be NOT "WaitResume"; // Otherwise, we should correct it. switch br.Spec.ReleasePlan.FinalizingPolicy { - case v1alpha1.WaitResumeFinalizingPolicyType: + case v1beta1.WaitResumeFinalizingPolicyType: if waitReady { // no need to patch again return false, nil } @@ -443,9 +443,9 @@ func (m *canaryReleaseManager) finalizingBatchRelease(c *RolloutContext) (bool, } // Correct finalizing policy. - policy := v1alpha1.ImmediateFinalizingPolicyType + policy := v1beta1.ImmediateFinalizingPolicyType if waitReady { - policy = v1alpha1.WaitResumeFinalizingPolicyType + policy = v1beta1.WaitResumeFinalizingPolicyType } // Patch BatchPartition and FinalizingPolicy, BatchPartition always patch null here. @@ -458,7 +458,7 @@ func (m *canaryReleaseManager) finalizingBatchRelease(c *RolloutContext) (bool, } // syncBatchRelease sync status of br to canaryStatus, and sync rollout-id of canaryStatus to br. -func (m *canaryReleaseManager) syncBatchRelease(br *v1alpha1.BatchRelease, canaryStatus *v1alpha1.CanaryStatus) error { +func (m *canaryReleaseManager) syncBatchRelease(br *v1beta1.BatchRelease, canaryStatus *v1beta1.CanaryStatus) error { // sync from BatchRelease status to Rollout canaryStatus canaryStatus.CanaryReplicas = br.Status.CanaryStatus.UpdatedReplicas canaryStatus.CanaryReadyReplicas = br.Status.CanaryStatus.UpdatedReadyReplicas diff --git a/pkg/controller/rollout/rollout_canary_test.go b/pkg/controller/rollout/rollout_canary_test.go index 0bf93690..934f38e4 100644 --- a/pkg/controller/rollout/rollout_canary_test.go +++ b/pkg/controller/rollout/rollout_canary_test.go @@ -21,7 +21,7 @@ import ( "reflect" "testing" - "github.com/openkruise/rollouts/api/v1alpha1" + "github.com/openkruise/rollouts/api/v1beta1" "github.com/openkruise/rollouts/pkg/trafficrouting" "github.com/openkruise/rollouts/pkg/util" apps "k8s.io/api/apps/v1" @@ -40,9 +40,9 @@ func TestRunCanary(t *testing.T) { name string getObj func() ([]*apps.Deployment, []*apps.ReplicaSet) getNetwork func() ([]*corev1.Service, []*netv1.Ingress) - getRollout func() (*v1alpha1.Rollout, *v1alpha1.BatchRelease) - expectStatus func() *v1alpha1.RolloutStatus - expectBr func() *v1alpha1.BatchRelease + getRollout func() (*v1beta1.Rollout, *v1beta1.BatchRelease) + expectStatus func() *v1beta1.RolloutStatus + expectBr func() *v1beta1.BatchRelease }{ { name: "run canary upgrade1", @@ -54,35 +54,35 @@ func TestRunCanary(t *testing.T) { getNetwork: func() ([]*corev1.Service, []*netv1.Ingress) { return []*corev1.Service{demoService.DeepCopy()}, []*netv1.Ingress{demoIngress.DeepCopy()} }, - getRollout: func() (*v1alpha1.Rollout, *v1alpha1.BatchRelease) { + getRollout: func() (*v1beta1.Rollout, *v1beta1.BatchRelease) { obj := rolloutDemo.DeepCopy() obj.Status.CanaryStatus.ObservedWorkloadGeneration = 2 obj.Status.CanaryStatus.RolloutHash = "f55bvd874d5f2fzvw46bv966x4bwbdv4wx6bd9f7b46ww788954b8z8w29b7wxfd" obj.Status.CanaryStatus.StableRevision = "pod-template-hash-v1" obj.Status.CanaryStatus.CanaryRevision = "56855c89f9" obj.Status.CanaryStatus.CurrentStepIndex = 1 - obj.Status.CanaryStatus.CurrentStepState = v1alpha1.CanaryStepStateUpgrade - cond := util.GetRolloutCondition(obj.Status, v1alpha1.RolloutConditionProgressing) - cond.Reason = v1alpha1.ProgressingReasonInRolling + obj.Status.CanaryStatus.CurrentStepState = v1beta1.CanaryStepStateUpgrade + cond := util.GetRolloutCondition(obj.Status, v1beta1.RolloutConditionProgressing) + cond.Reason = v1beta1.ProgressingReasonInRolling util.SetRolloutCondition(&obj.Status, *cond) return obj, nil }, - expectStatus: func() *v1alpha1.RolloutStatus { + expectStatus: func() *v1beta1.RolloutStatus { s := rolloutDemo.Status.DeepCopy() s.CanaryStatus.ObservedWorkloadGeneration = 2 s.CanaryStatus.RolloutHash = "f55bvd874d5f2fzvw46bv966x4bwbdv4wx6bd9f7b46ww788954b8z8w29b7wxfd" s.CanaryStatus.StableRevision = "pod-template-hash-v1" s.CanaryStatus.CanaryRevision = "56855c89f9" s.CanaryStatus.CurrentStepIndex = 1 - s.CanaryStatus.CurrentStepState = v1alpha1.CanaryStepStateUpgrade - cond := util.GetRolloutCondition(*s, v1alpha1.RolloutConditionProgressing) - cond.Reason = v1alpha1.ProgressingReasonInRolling + s.CanaryStatus.CurrentStepState = v1beta1.CanaryStepStateUpgrade + cond := util.GetRolloutCondition(*s, v1beta1.RolloutConditionProgressing) + cond.Reason = v1beta1.ProgressingReasonInRolling util.SetRolloutCondition(s, *cond) return s }, - expectBr: func() *v1alpha1.BatchRelease { + expectBr: func() *v1beta1.BatchRelease { br := batchDemo.DeepCopy() - br.Spec.ReleasePlan.Batches = []v1alpha1.ReleaseBatch{ + br.Spec.ReleasePlan.Batches = []v1beta1.ReleaseBatch{ { CanaryReplicas: intstr.FromInt(1), }, @@ -127,19 +127,19 @@ func TestRunCanary(t *testing.T) { getNetwork: func() ([]*corev1.Service, []*netv1.Ingress) { return []*corev1.Service{demoService.DeepCopy()}, []*netv1.Ingress{demoIngress.DeepCopy()} }, - getRollout: func() (*v1alpha1.Rollout, *v1alpha1.BatchRelease) { + getRollout: func() (*v1beta1.Rollout, *v1beta1.BatchRelease) { obj := rolloutDemo.DeepCopy() obj.Status.CanaryStatus.ObservedWorkloadGeneration = 2 obj.Status.CanaryStatus.RolloutHash = "f55bvd874d5f2fzvw46bv966x4bwbdv4wx6bd9f7b46ww788954b8z8w29b7wxfd" obj.Status.CanaryStatus.StableRevision = "pod-template-hash-v1" obj.Status.CanaryStatus.CanaryRevision = "56855c89f9" obj.Status.CanaryStatus.CurrentStepIndex = 1 - obj.Status.CanaryStatus.CurrentStepState = v1alpha1.CanaryStepStateUpgrade - cond := util.GetRolloutCondition(obj.Status, v1alpha1.RolloutConditionProgressing) - cond.Reason = v1alpha1.ProgressingReasonInRolling + obj.Status.CanaryStatus.CurrentStepState = v1beta1.CanaryStepStateUpgrade + cond := util.GetRolloutCondition(obj.Status, v1beta1.RolloutConditionProgressing) + cond.Reason = v1beta1.ProgressingReasonInRolling util.SetRolloutCondition(&obj.Status, *cond) br := batchDemo.DeepCopy() - br.Spec.ReleasePlan.Batches = []v1alpha1.ReleaseBatch{ + br.Spec.ReleasePlan.Batches = []v1beta1.ReleaseBatch{ { CanaryReplicas: intstr.FromInt(1), }, @@ -154,11 +154,11 @@ func TestRunCanary(t *testing.T) { }, } br.Spec.ReleasePlan.BatchPartition = utilpointer.Int32(0) - br.Status = v1alpha1.BatchReleaseStatus{ + br.Status = v1beta1.BatchReleaseStatus{ ObservedGeneration: 1, ObservedReleasePlanHash: "6d6a40791161e88ec0483688e951b589a4cbd0bf351974827706b79f99378fd5", - CanaryStatus: v1alpha1.BatchReleaseCanaryStatus{ - CurrentBatchState: v1alpha1.ReadyBatchState, + CanaryStatus: v1beta1.BatchReleaseCanaryStatus{ + CurrentBatchState: v1beta1.ReadyBatchState, CurrentBatch: 0, UpdatedReplicas: 1, UpdatedReadyReplicas: 1, @@ -166,7 +166,7 @@ func TestRunCanary(t *testing.T) { } return obj, br }, - expectStatus: func() *v1alpha1.RolloutStatus { + expectStatus: func() *v1beta1.RolloutStatus { s := rolloutDemo.Status.DeepCopy() s.CanaryStatus.ObservedWorkloadGeneration = 2 s.CanaryStatus.RolloutHash = "f55bvd874d5f2fzvw46bv966x4bwbdv4wx6bd9f7b46ww788954b8z8w29b7wxfd" @@ -176,15 +176,15 @@ func TestRunCanary(t *testing.T) { s.CanaryStatus.CanaryReplicas = 1 s.CanaryStatus.CanaryReadyReplicas = 1 s.CanaryStatus.CurrentStepIndex = 1 - s.CanaryStatus.CurrentStepState = v1alpha1.CanaryStepStateTrafficRouting - cond := util.GetRolloutCondition(*s, v1alpha1.RolloutConditionProgressing) - cond.Reason = v1alpha1.ProgressingReasonInRolling + s.CanaryStatus.CurrentStepState = v1beta1.CanaryStepStateTrafficRouting + cond := util.GetRolloutCondition(*s, v1beta1.RolloutConditionProgressing) + cond.Reason = v1beta1.ProgressingReasonInRolling util.SetRolloutCondition(s, *cond) return s }, - expectBr: func() *v1alpha1.BatchRelease { + expectBr: func() *v1beta1.BatchRelease { br := batchDemo.DeepCopy() - br.Spec.ReleasePlan.Batches = []v1alpha1.ReleaseBatch{ + br.Spec.ReleasePlan.Batches = []v1beta1.ReleaseBatch{ { CanaryReplicas: intstr.FromInt(1), }, @@ -253,7 +253,7 @@ func TestRunCanary(t *testing.T) { cStatus.CanaryStatus.LastUpdateTime = nil cStatus.CanaryStatus.Message = "" } - cond := util.GetRolloutCondition(*cStatus, v1alpha1.RolloutConditionProgressing) + cond := util.GetRolloutCondition(*cStatus, v1beta1.RolloutConditionProgressing) cond.Message = "" util.SetRolloutCondition(cStatus, *cond) expectStatus := cs.expectStatus() @@ -267,12 +267,12 @@ func TestRunCanary(t *testing.T) { func TestRunCanaryPaused(t *testing.T) { cases := []struct { name string - getRollout func() *v1alpha1.Rollout - expectStatus func() *v1alpha1.RolloutStatus + getRollout func() *v1beta1.Rollout + expectStatus func() *v1beta1.RolloutStatus }{ { name: "paused, last step, 60% weight", - getRollout: func() *v1alpha1.Rollout { + getRollout: func() *v1beta1.Rollout { obj := rolloutDemo.DeepCopy() obj.Status.CanaryStatus.ObservedWorkloadGeneration = 2 obj.Status.CanaryStatus.RolloutHash = "f55bvd874d5f2fzvw46bv966x4bwbdv4wx6bd9f7b46ww788954b8z8w29b7wxfd" @@ -280,10 +280,10 @@ func TestRunCanaryPaused(t *testing.T) { obj.Status.CanaryStatus.CanaryRevision = "56855c89f9" obj.Status.CanaryStatus.CurrentStepIndex = 3 obj.Status.CanaryStatus.PodTemplateHash = "pod-template-hash-v2" - obj.Status.CanaryStatus.CurrentStepState = v1alpha1.CanaryStepStatePaused + obj.Status.CanaryStatus.CurrentStepState = v1beta1.CanaryStepStatePaused return obj }, - expectStatus: func() *v1alpha1.RolloutStatus { + expectStatus: func() *v1beta1.RolloutStatus { obj := rolloutDemo.Status.DeepCopy() obj.CanaryStatus.ObservedWorkloadGeneration = 2 obj.CanaryStatus.RolloutHash = "f55bvd874d5f2fzvw46bv966x4bwbdv4wx6bd9f7b46ww788954b8z8w29b7wxfd" @@ -291,7 +291,7 @@ func TestRunCanaryPaused(t *testing.T) { obj.CanaryStatus.CanaryRevision = "56855c89f9" obj.CanaryStatus.CurrentStepIndex = 3 obj.CanaryStatus.PodTemplateHash = "pod-template-hash-v2" - obj.CanaryStatus.CurrentStepState = v1alpha1.CanaryStepStatePaused + obj.CanaryStatus.CurrentStepState = v1beta1.CanaryStepStatePaused return obj }, }, @@ -332,8 +332,8 @@ func TestRunCanaryPaused(t *testing.T) { } } -func checkBatchReleaseEqual(c client.WithWatch, t *testing.T, key client.ObjectKey, expect *v1alpha1.BatchRelease) { - obj := &v1alpha1.BatchRelease{} +func checkBatchReleaseEqual(c client.WithWatch, t *testing.T, key client.ObjectKey, expect *v1beta1.BatchRelease) { + obj := &v1beta1.BatchRelease{} err := c.Get(context.TODO(), key, obj) if err != nil { t.Fatalf("get object failed: %s", err.Error()) diff --git a/pkg/controller/rollout/rollout_controller.go b/pkg/controller/rollout/rollout_controller.go index cffeb2df..314f9da1 100755 --- a/pkg/controller/rollout/rollout_controller.go +++ b/pkg/controller/rollout/rollout_controller.go @@ -22,7 +22,7 @@ import ( "sync" "time" - "github.com/openkruise/rollouts/api/v1alpha1" + "github.com/openkruise/rollouts/api/v1beta1" "github.com/openkruise/rollouts/pkg/trafficrouting" "github.com/openkruise/rollouts/pkg/util" "k8s.io/apimachinery/pkg/api/errors" @@ -42,7 +42,7 @@ var ( workloadHandler handler.EventHandler watchedWorkload sync.Map - rolloutControllerKind = v1alpha1.SchemeGroupVersion.WithKind("Rollout") + rolloutControllerKind = v1beta1.SchemeGroupVersion.WithKind("Rollout") ) func init() { @@ -95,7 +95,7 @@ type RolloutReconciler struct { // - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.8.3/pkg/reconcile func (r *RolloutReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { // Fetch the Rollout instance - rollout := &v1alpha1.Rollout{} + rollout := &v1beta1.Rollout{} err := r.Get(context.TODO(), req.NamespacedName, rollout) if err != nil { if errors.IsNotFound(err) { @@ -146,11 +146,11 @@ func (r *RolloutReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct var recheckTime *time.Time switch rollout.Status.Phase { - case v1alpha1.RolloutPhaseProgressing: + case v1beta1.RolloutPhaseProgressing: recheckTime, err = r.reconcileRolloutProgressing(rollout, newStatus) - case v1alpha1.RolloutPhaseTerminating: + case v1beta1.RolloutPhaseTerminating: recheckTime, err = r.reconcileRolloutTerminating(rollout, newStatus) - case v1alpha1.RolloutPhaseDisabling: + case v1beta1.RolloutPhaseDisabling: recheckTime, err = r.reconcileRolloutDisabling(rollout, newStatus) } if err != nil { @@ -178,11 +178,11 @@ func (r *RolloutReconciler) SetupWithManager(mgr ctrl.Manager) error { return err } // Watch for changes to rollout - if err = c.Watch(&source.Kind{Type: &v1alpha1.Rollout{}}, &handler.EnqueueRequestForObject{}); err != nil { + if err = c.Watch(&source.Kind{Type: &v1beta1.Rollout{}}, &handler.EnqueueRequestForObject{}); err != nil { return err } // Watch for changes to batchRelease - if err = c.Watch(&source.Kind{Type: &v1alpha1.BatchRelease{}}, &enqueueRequestForBatchRelease{reader: mgr.GetCache()}); err != nil { + if err = c.Watch(&source.Kind{Type: &v1beta1.BatchRelease{}}, &enqueueRequestForBatchRelease{reader: mgr.GetCache()}); err != nil { return err } runtimeController = c diff --git a/pkg/controller/rollout/rollout_controller_test.go b/pkg/controller/rollout/rollout_controller_test.go index 8afa8346..535246ef 100644 --- a/pkg/controller/rollout/rollout_controller_test.go +++ b/pkg/controller/rollout/rollout_controller_test.go @@ -20,7 +20,7 @@ import ( "fmt" kruisev1aplphal "github.com/openkruise/kruise-api/apps/v1alpha1" - "github.com/openkruise/rollouts/api/v1alpha1" + "github.com/openkruise/rollouts/api/v1beta1" "github.com/openkruise/rollouts/pkg/util" "github.com/openkruise/rollouts/pkg/util/configuration" apps "k8s.io/api/apps/v1" @@ -38,7 +38,7 @@ import ( var ( scheme *runtime.Scheme - rolloutDemo = &v1alpha1.Rollout{ + rolloutDemo = &v1beta1.Rollout{ ObjectMeta: metav1.ObjectMeta{ Name: "rollout-demo", Labels: map[string]string{}, @@ -46,46 +46,46 @@ var ( util.RolloutHashAnnotation: "f55bvd874d5f2fzvw46bv966x4bwbdv4wx6bd9f7b46ww788954b8z8w29b7wxfd", }, }, - Spec: v1alpha1.RolloutSpec{ - ObjectRef: v1alpha1.ObjectRef{ - WorkloadRef: &v1alpha1.WorkloadRef{ + Spec: v1beta1.RolloutSpec{ + ObjectRef: v1beta1.ObjectRef{ + WorkloadRef: &v1beta1.WorkloadRef{ APIVersion: "apps/v1", Kind: "Deployment", Name: "echoserver", }, }, - Strategy: v1alpha1.RolloutStrategy{ - Canary: &v1alpha1.CanaryStrategy{ - Steps: []v1alpha1.CanaryStep{ + Strategy: v1beta1.RolloutStrategy{ + Canary: &v1beta1.CanaryStrategy{ + Steps: []v1beta1.CanaryStep{ { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(5), }, Replicas: &intstr.IntOrString{IntVal: 1}, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(20), }, Replicas: &intstr.IntOrString{IntVal: 2}, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(60), }, Replicas: &intstr.IntOrString{IntVal: 6}, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(100), }, Replicas: &intstr.IntOrString{IntVal: 10}, }, }, - TrafficRoutings: []v1alpha1.TrafficRoutingRef{ + TrafficRoutings: []v1beta1.TrafficRoutingRef{ { Service: "echoserver", - Ingress: &v1alpha1.IngressTrafficRouting{ + Ingress: &v1beta1.IngressTrafficRouting{ Name: "echoserver", }, }, @@ -93,13 +93,13 @@ var ( }, }, }, - Status: v1alpha1.RolloutStatus{ - Phase: v1alpha1.RolloutPhaseProgressing, - CanaryStatus: &v1alpha1.CanaryStatus{}, - Conditions: []v1alpha1.RolloutCondition{ + Status: v1beta1.RolloutStatus{ + Phase: v1beta1.RolloutPhaseProgressing, + CanaryStatus: &v1beta1.CanaryStatus{}, + Conditions: []v1beta1.RolloutCondition{ { - Type: v1alpha1.RolloutConditionProgressing, - Reason: v1alpha1.ProgressingReasonInitializing, + Type: v1beta1.RolloutConditionProgressing, + Reason: v1beta1.ProgressingReasonInitializing, Status: corev1.ConditionTrue, }, }, @@ -199,22 +199,22 @@ var ( }, } - batchDemo = &v1alpha1.BatchRelease{ + batchDemo = &v1beta1.BatchRelease{ ObjectMeta: metav1.ObjectMeta{ Name: "rollout-demo", Labels: map[string]string{}, Generation: 1, }, - Spec: v1alpha1.BatchReleaseSpec{ - TargetRef: v1alpha1.ObjectRef{ - WorkloadRef: &v1alpha1.WorkloadRef{ + Spec: v1beta1.BatchReleaseSpec{ + TargetRef: v1beta1.ObjectRef{ + WorkloadRef: &v1beta1.WorkloadRef{ APIVersion: "apps/v1", Kind: "Deployment", Name: "echoserver", }, }, }, - Status: v1alpha1.BatchReleaseStatus{}, + Status: v1beta1.BatchReleaseStatus{}, } demoService = corev1.Service{ @@ -318,22 +318,22 @@ var ( }, } - demoTR = &v1alpha1.TrafficRouting{ + demoTR = &v1beta1.TrafficRouting{ ObjectMeta: metav1.ObjectMeta{ Name: "tr-demo", Labels: map[string]string{}, }, - Spec: v1alpha1.TrafficRoutingSpec{ - ObjectRef: []v1alpha1.TrafficRoutingRef{ + Spec: v1beta1.TrafficRoutingSpec{ + ObjectRef: []v1beta1.TrafficRoutingRef{ { Service: "echoserver", - Ingress: &v1alpha1.IngressTrafficRouting{ + Ingress: &v1beta1.IngressTrafficRouting{ Name: "echoserver", }, }, }, - Strategy: v1alpha1.TrafficRoutingStrategy{ - Matches: []v1alpha1.HttpRouteMatch{ + Strategy: v1beta1.TrafficRoutingStrategy{ + Matches: []v1beta1.HttpRouteMatch{ // header { Headers: []gatewayv1alpha2.HTTPHeaderMatch{ @@ -353,5 +353,5 @@ func init() { scheme = runtime.NewScheme() _ = clientgoscheme.AddToScheme(scheme) _ = kruisev1aplphal.AddToScheme(scheme) - _ = v1alpha1.AddToScheme(scheme) + _ = v1beta1.AddToScheme(scheme) } diff --git a/pkg/controller/rollout/rollout_event_handler.go b/pkg/controller/rollout/rollout_event_handler.go index 6dc2930d..321bcda6 100644 --- a/pkg/controller/rollout/rollout_event_handler.go +++ b/pkg/controller/rollout/rollout_event_handler.go @@ -19,7 +19,7 @@ package rollout import ( "context" - rolloutv1alpha1 "github.com/openkruise/rollouts/api/v1alpha1" + rolloutv1beta1 "github.com/openkruise/rollouts/api/v1beta1" utilclient "github.com/openkruise/rollouts/pkg/util/client" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" @@ -77,8 +77,8 @@ func (w *enqueueRequestForWorkload) handleEvent(q workqueue.RateLimitingInterfac } } -func (w *enqueueRequestForWorkload) getRolloutForWorkload(key types.NamespacedName, gvk schema.GroupVersionKind) (*rolloutv1alpha1.Rollout, error) { - rList := &rolloutv1alpha1.RolloutList{} +func (w *enqueueRequestForWorkload) getRolloutForWorkload(key types.NamespacedName, gvk schema.GroupVersionKind) (*rolloutv1beta1.Rollout, error) { + rList := &rolloutv1beta1.RolloutList{} if err := w.reader.List(context.TODO(), rList, client.InNamespace(key.Namespace), utilclient.DisableDeepCopy); err != nil { klog.Errorf("List WorkloadSpread failed: %s", err.Error()) return nil, err diff --git a/pkg/controller/rollout/rollout_progressing.go b/pkg/controller/rollout/rollout_progressing.go index 9635d6d0..68ecf204 100644 --- a/pkg/controller/rollout/rollout_progressing.go +++ b/pkg/controller/rollout/rollout_progressing.go @@ -22,7 +22,7 @@ import ( "strconv" "time" - "github.com/openkruise/rollouts/api/v1alpha1" + "github.com/openkruise/rollouts/api/v1beta1" "github.com/openkruise/rollouts/pkg/trafficrouting" "github.com/openkruise/rollouts/pkg/util" corev1 "k8s.io/api/core/v1" @@ -37,8 +37,8 @@ import ( var defaultGracePeriodSeconds int32 = 3 type RolloutContext struct { - Rollout *v1alpha1.Rollout - NewStatus *v1alpha1.RolloutStatus + Rollout *v1beta1.Rollout + NewStatus *v1beta1.RolloutStatus // related workload Workload *util.Workload // reconcile RequeueAfter recheckTime @@ -48,8 +48,8 @@ type RolloutContext struct { } // parameter1 retryReconcile, parameter2 error -func (r *RolloutReconciler) reconcileRolloutProgressing(rollout *v1alpha1.Rollout, newStatus *v1alpha1.RolloutStatus) (*time.Time, error) { - cond := util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionProgressing) +func (r *RolloutReconciler) reconcileRolloutProgressing(rollout *v1beta1.Rollout, newStatus *v1beta1.RolloutStatus) (*time.Time, error) { + cond := util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionProgressing) klog.Infof("reconcile rollout(%s/%s) progressing action...", rollout.Namespace, rollout.Name) workload, err := r.finder.GetWorkloadForRef(rollout) if err != nil { @@ -64,17 +64,17 @@ func (r *RolloutReconciler) reconcileRolloutProgressing(rollout *v1alpha1.Rollou } rolloutContext := &RolloutContext{Rollout: rollout, NewStatus: newStatus, Workload: workload} switch cond.Reason { - case v1alpha1.ProgressingReasonInitializing: + case v1beta1.ProgressingReasonInitializing: klog.Infof("rollout(%s/%s) is Progressing, and in reason(%s)", rollout.Namespace, rollout.Name, cond.Reason) // new canaryStatus - newStatus.CanaryStatus = &v1alpha1.CanaryStatus{ + newStatus.CanaryStatus = &v1beta1.CanaryStatus{ ObservedWorkloadGeneration: rolloutContext.Workload.Generation, RolloutHash: rolloutContext.Rollout.Annotations[util.RolloutHashAnnotation], ObservedRolloutID: getRolloutID(rolloutContext.Workload), StableRevision: rolloutContext.Workload.StableRevision, CanaryRevision: rolloutContext.Workload.CanaryRevision, CurrentStepIndex: 1, - CurrentStepState: v1alpha1.CanaryStepStateUpgrade, + CurrentStepState: v1beta1.CanaryStepStateUpgrade, LastUpdateTime: &metav1.Time{Time: time.Now()}, } done, err := r.doProgressingInitializing(rolloutContext) @@ -82,7 +82,7 @@ func (r *RolloutReconciler) reconcileRolloutProgressing(rollout *v1alpha1.Rollou klog.Errorf("rollout(%s/%s) doProgressingInitializing error(%s)", rollout.Namespace, rollout.Name, err.Error()) return nil, err } else if done { - progressingStateTransition(newStatus, corev1.ConditionTrue, v1alpha1.ProgressingReasonInRolling, "Rollout is in Progressing") + progressingStateTransition(newStatus, corev1.ConditionTrue, v1beta1.ProgressingReasonInRolling, "Rollout is in Progressing") } else { // Incomplete, recheck expectedTime := time.Now().Add(time.Duration(defaultGracePeriodSeconds) * time.Second) @@ -90,14 +90,14 @@ func (r *RolloutReconciler) reconcileRolloutProgressing(rollout *v1alpha1.Rollou klog.Infof("rollout(%s/%s) doProgressingInitializing is incomplete, and recheck(%s)", rollout.Namespace, rollout.Name, expectedTime.String()) } - case v1alpha1.ProgressingReasonInRolling: + case v1beta1.ProgressingReasonInRolling: klog.Infof("rollout(%s/%s) is Progressing, and in reason(%s)", rollout.Namespace, rollout.Name, cond.Reason) err = r.doProgressingInRolling(rolloutContext) if err != nil { return nil, err } - case v1alpha1.ProgressingReasonFinalising: + case v1beta1.ProgressingReasonFinalising: klog.Infof("rollout(%s/%s) is Progressing, and in reason(%s)", rollout.Namespace, rollout.Name, cond.Reason) var done bool rolloutContext.WaitReady = true @@ -106,7 +106,7 @@ func (r *RolloutReconciler) reconcileRolloutProgressing(rollout *v1alpha1.Rollou return nil, err // finalizer is finished } else if done { - progressingStateTransition(newStatus, corev1.ConditionFalse, v1alpha1.ProgressingReasonCompleted, "Rollout progressing has been completed") + progressingStateTransition(newStatus, corev1.ConditionFalse, v1beta1.ProgressingReasonCompleted, "Rollout progressing has been completed") setRolloutSucceededCondition(newStatus, corev1.ConditionTrue) } else { // Incomplete, recheck @@ -115,14 +115,14 @@ func (r *RolloutReconciler) reconcileRolloutProgressing(rollout *v1alpha1.Rollou klog.Infof("rollout(%s/%s) doProgressingFinalising is incomplete, and recheck(%s)", rollout.Namespace, rollout.Name, expectedTime.String()) } - case v1alpha1.ProgressingReasonPaused: + case v1beta1.ProgressingReasonPaused: // from paused to rolling progressing if !rollout.Spec.Strategy.Paused { klog.Infof("rollout(%s/%s) is Progressing, from paused to rolling", rollout.Namespace, rollout.Name) - progressingStateTransition(newStatus, corev1.ConditionTrue, v1alpha1.ProgressingReasonInRolling, "") + progressingStateTransition(newStatus, corev1.ConditionTrue, v1beta1.ProgressingReasonInRolling, "") } - case v1alpha1.ProgressingReasonCancelling: + case v1beta1.ProgressingReasonCancelling: klog.Infof("rollout(%s/%s) is Progressing, and in reason(%s)", rollout.Namespace, rollout.Name, cond.Reason) var done bool done, err = r.doFinalising(rolloutContext) @@ -130,7 +130,7 @@ func (r *RolloutReconciler) reconcileRolloutProgressing(rollout *v1alpha1.Rollou return nil, err // finalizer is finished } else if done { - progressingStateTransition(newStatus, corev1.ConditionFalse, v1alpha1.ProgressingReasonCompleted, "Rollout progressing has been cancelled") + progressingStateTransition(newStatus, corev1.ConditionFalse, v1beta1.ProgressingReasonCompleted, "Rollout progressing has been cancelled") setRolloutSucceededCondition(newStatus, corev1.ConditionFalse) } else { // Incomplete, recheck @@ -139,10 +139,10 @@ func (r *RolloutReconciler) reconcileRolloutProgressing(rollout *v1alpha1.Rollou klog.Infof("rollout(%s/%s) doProgressingCancelling is incomplete, and recheck(%s)", rollout.Namespace, rollout.Name, expectedTime.String()) } - case v1alpha1.ProgressingReasonCompleted: + case v1beta1.ProgressingReasonCompleted: // rollout phase from progressing to healthy klog.Infof("rollout(%s/%s) phase is from progressing to healthy", rollout.Namespace, rollout.Name) - newStatus.Phase = v1alpha1.RolloutPhaseHealthy + newStatus.Phase = v1beta1.RolloutPhaseHealthy } return rolloutContext.RecheckTime, nil @@ -160,15 +160,15 @@ func (r *RolloutReconciler) doProgressingInitializing(c *RolloutContext) (bool, // but in many scenarios the user may modify the workload and rollout spec at the same time, // and there is a possibility that the workload is released first, and due to some network or other reasons the rollout spec is delayed by a few seconds, // so this is mainly compatible with this scenario. - cond := util.GetRolloutCondition(*c.NewStatus, v1alpha1.RolloutConditionProgressing) + cond := util.GetRolloutCondition(*c.NewStatus, v1beta1.RolloutConditionProgressing) if verifyTime := cond.LastUpdateTime.Add(time.Second * time.Duration(defaultGracePeriodSeconds)); verifyTime.After(time.Now()) { klog.Infof("verify rollout(%s/%s) TrafficRouting, and wait a moment", c.Rollout.Namespace, c.Rollout.Name) return false, nil } // TrafficRouting indicates the gateway traffic routing, and rollout release will trigger the trafficRouting - if c.Rollout.Annotations[v1alpha1.TrafficRoutingAnnotation] != "" { - return r.handleTrafficRouting(c.Rollout.Namespace, c.Rollout.Name, c.Rollout.Annotations[v1alpha1.TrafficRoutingAnnotation]) + if c.Rollout.Annotations[v1beta1.TrafficRoutingAnnotation] != "" { + return r.handleTrafficRouting(c.Rollout.Namespace, c.Rollout.Name, c.Rollout.Annotations[v1beta1.TrafficRoutingAnnotation]) } return true, nil } @@ -200,9 +200,9 @@ func (r *RolloutReconciler) doProgressingInRolling(c *RolloutContext) error { return r.handleNormalRolling(c) } -func (r *RolloutReconciler) handleRolloutPaused(rollout *v1alpha1.Rollout, newStatus *v1alpha1.RolloutStatus) error { +func (r *RolloutReconciler) handleRolloutPaused(rollout *v1beta1.Rollout, newStatus *v1beta1.RolloutStatus) error { klog.Infof("rollout(%s/%s) is Progressing, but paused", rollout.Namespace, rollout.Name) - progressingStateTransition(newStatus, corev1.ConditionTrue, v1alpha1.ProgressingReasonPaused, "Rollout has been paused, you can resume it by kube-cli") + progressingStateTransition(newStatus, corev1.ConditionTrue, v1beta1.ProgressingReasonPaused, "Rollout has been paused, you can resume it by kube-cli") return nil } @@ -217,7 +217,7 @@ func (r *RolloutReconciler) handleContinuousRelease(c *RolloutContext) error { return err } else if done { c.NewStatus.CanaryStatus = nil - progressingStateTransition(c.NewStatus, corev1.ConditionTrue, v1alpha1.ProgressingReasonInitializing, "Workload is continuous release") + progressingStateTransition(c.NewStatus, corev1.ConditionTrue, v1beta1.ProgressingReasonInitializing, "Workload is continuous release") klog.Infof("rollout(%s/%s) workload is continuous publishing, reset complete", c.Rollout.Namespace, c.Rollout.Name) } else { // Incomplete, recheck @@ -228,19 +228,19 @@ func (r *RolloutReconciler) handleContinuousRelease(c *RolloutContext) error { return nil } -func (r *RolloutReconciler) handleRollbackDirectly(rollout *v1alpha1.Rollout, workload *util.Workload, newStatus *v1alpha1.RolloutStatus) error { +func (r *RolloutReconciler) handleRollbackDirectly(rollout *v1beta1.Rollout, workload *util.Workload, newStatus *v1beta1.RolloutStatus) error { newStatus.CanaryStatus.CanaryRevision = workload.CanaryRevision r.Recorder.Eventf(rollout, corev1.EventTypeNormal, "Progressing", "workload has been rollback, then rollout is canceled") klog.Infof("rollout(%s/%s) workload has been rollback directly, then rollout canceled", rollout.Namespace, rollout.Name) - progressingStateTransition(newStatus, corev1.ConditionTrue, v1alpha1.ProgressingReasonCancelling, "The workload has been rolled back and the rollout process will be cancelled") + progressingStateTransition(newStatus, corev1.ConditionTrue, v1beta1.ProgressingReasonCancelling, "The workload has been rolled back and the rollout process will be cancelled") return nil } -func (r *RolloutReconciler) handleRollbackInBatches(rollout *v1alpha1.Rollout, workload *util.Workload, newStatus *v1alpha1.RolloutStatus) error { +func (r *RolloutReconciler) handleRollbackInBatches(rollout *v1beta1.Rollout, workload *util.Workload, newStatus *v1beta1.RolloutStatus) error { // restart from the beginning newStatus.CanaryStatus.CurrentStepIndex = 1 newStatus.CanaryStatus.CanaryRevision = workload.CanaryRevision - newStatus.CanaryStatus.CurrentStepState = v1alpha1.CanaryStepStateUpgrade + newStatus.CanaryStatus.CurrentStepState = v1beta1.CanaryStepStateUpgrade newStatus.CanaryStatus.LastUpdateTime = &metav1.Time{Time: time.Now()} newStatus.CanaryStatus.RolloutHash = rollout.Annotations[util.RolloutHashAnnotation] klog.Infof("rollout(%s/%s) workload has been rollback in batches, then restart from beginning", rollout.Namespace, rollout.Name) @@ -255,7 +255,7 @@ func (r *RolloutReconciler) handleRolloutPlanChanged(c *RolloutContext) error { } // canary step configuration change causes current step index change c.NewStatus.CanaryStatus.CurrentStepIndex = newStepIndex - c.NewStatus.CanaryStatus.CurrentStepState = v1alpha1.CanaryStepStateUpgrade + c.NewStatus.CanaryStatus.CurrentStepState = v1beta1.CanaryStepStateUpgrade c.NewStatus.CanaryStatus.LastUpdateTime = &metav1.Time{Time: time.Now()} c.NewStatus.CanaryStatus.RolloutHash = c.Rollout.Annotations[util.RolloutHashAnnotation] klog.Infof("rollout(%s/%s) canary step configuration change, and stepIndex(%d) state(%s)", @@ -265,9 +265,9 @@ func (r *RolloutReconciler) handleRolloutPlanChanged(c *RolloutContext) error { func (r *RolloutReconciler) handleNormalRolling(c *RolloutContext) error { // check if canary is done - if c.NewStatus.CanaryStatus.CurrentStepState == v1alpha1.CanaryStepStateCompleted { + if c.NewStatus.CanaryStatus.CurrentStepState == v1beta1.CanaryStepStateCompleted { klog.Infof("rollout(%s/%s) progressing rolling done", c.Rollout.Namespace, c.Rollout.Name) - progressingStateTransition(c.NewStatus, corev1.ConditionTrue, v1alpha1.ProgressingReasonFinalising, "Rollout has been completed and some closing work is being done") + progressingStateTransition(c.NewStatus, corev1.ConditionTrue, v1beta1.ProgressingReasonFinalising, "Rollout has been completed and some closing work is being done") return nil } return r.canaryManager.runCanary(c) @@ -275,7 +275,7 @@ func (r *RolloutReconciler) handleNormalRolling(c *RolloutContext) error { // name is rollout name, tr is trafficRouting name func (r *RolloutReconciler) handleTrafficRouting(namespace, name, tr string) (bool, error) { - obj := &v1alpha1.TrafficRouting{} + obj := &v1beta1.TrafficRouting{} err := r.Get(context.TODO(), client.ObjectKey{Namespace: namespace, Name: tr}, obj) if err != nil { if errors.IsNotFound(err) { @@ -287,7 +287,7 @@ func (r *RolloutReconciler) handleTrafficRouting(namespace, name, tr string) (bo if controllerutil.ContainsFinalizer(obj, util.ProgressingRolloutFinalizer(name)) { return true, nil } - if obj.Status.Phase == v1alpha1.TrafficRoutingPhaseFinalizing || obj.Status.Phase == v1alpha1.TrafficRoutingPhaseTerminating { + if obj.Status.Phase == v1beta1.TrafficRoutingPhaseFinalizing || obj.Status.Phase == v1beta1.TrafficRoutingPhaseTerminating { klog.Infof("rollout(%s/%s) trafficRouting(%s) phase(%s), and wait a moment", namespace, name, tr, obj.Status.Phase) return false, nil } @@ -301,7 +301,7 @@ func (r *RolloutReconciler) handleTrafficRouting(namespace, name, tr string) (bo } func (r *RolloutReconciler) finalizeTrafficRouting(namespace, name, tr string) error { - obj := &v1alpha1.TrafficRouting{} + obj := &v1beta1.TrafficRouting{} err := r.Get(context.TODO(), client.ObjectKey{Namespace: namespace, Name: tr}, obj) if err != nil { if errors.IsNotFound(err) { @@ -330,27 +330,27 @@ func (r *RolloutReconciler) finalizeTrafficRouting(namespace, name, tr string) e *********************************************************************** */ -func isRolloutPaused(rollout *v1alpha1.Rollout) bool { +func isRolloutPaused(rollout *v1beta1.Rollout) bool { return rollout.Spec.Strategy.Paused } -func isRolloutPlanChanged(rollout *v1alpha1.Rollout) bool { +func isRolloutPlanChanged(rollout *v1beta1.Rollout) bool { status := &rollout.Status return status.CanaryStatus.RolloutHash != "" && status.CanaryStatus.RolloutHash != rollout.Annotations[util.RolloutHashAnnotation] } -func isContinuousRelease(rollout *v1alpha1.Rollout, workload *util.Workload) bool { +func isContinuousRelease(rollout *v1beta1.Rollout, workload *util.Workload) bool { status := &rollout.Status return status.CanaryStatus.CanaryRevision != "" && workload.CanaryRevision != status.CanaryStatus.CanaryRevision && !workload.IsInRollback } -func isRollingBackDirectly(rollout *v1alpha1.Rollout, workload *util.Workload) bool { +func isRollingBackDirectly(rollout *v1beta1.Rollout, workload *util.Workload) bool { status := &rollout.Status inBatch := util.IsRollbackInBatchPolicy(rollout, workload.Labels) return workload.IsInRollback && workload.CanaryRevision != status.CanaryStatus.CanaryRevision && !inBatch } -func isRollingBackInBatches(rollout *v1alpha1.Rollout, workload *util.Workload) bool { +func isRollingBackInBatches(rollout *v1beta1.Rollout, workload *util.Workload) bool { status := &rollout.Status inBatch := util.IsRollbackInBatchPolicy(rollout, workload.Labels) return workload.IsInRollback && workload.CanaryRevision != status.CanaryStatus.CanaryRevision && inBatch @@ -407,8 +407,8 @@ func (r *RolloutReconciler) recalculateCanaryStep(c *RolloutContext) (int32, err func (r *RolloutReconciler) doFinalising(c *RolloutContext) (bool, error) { klog.Infof("reconcile rollout(%s/%s) doFinalising", c.Rollout.Namespace, c.Rollout.Name) // TrafficRouting indicates the gateway traffic routing, and rollout finalizer will trigger the trafficRouting finalizer - if c.Rollout.Annotations[v1alpha1.TrafficRoutingAnnotation] != "" { - err := r.finalizeTrafficRouting(c.Rollout.Namespace, c.Rollout.Name, c.Rollout.Annotations[v1alpha1.TrafficRoutingAnnotation]) + if c.Rollout.Annotations[v1beta1.TrafficRoutingAnnotation] != "" { + err := r.finalizeTrafficRouting(c.Rollout.Namespace, c.Rollout.Name, c.Rollout.Annotations[v1beta1.TrafficRoutingAnnotation]) if err != nil { return false, err } @@ -425,10 +425,10 @@ func (r *RolloutReconciler) doFinalising(c *RolloutContext) (bool, error) { return true, nil } -func progressingStateTransition(status *v1alpha1.RolloutStatus, condStatus corev1.ConditionStatus, reason, message string) { - cond := util.GetRolloutCondition(*status, v1alpha1.RolloutConditionProgressing) +func progressingStateTransition(status *v1beta1.RolloutStatus, condStatus corev1.ConditionStatus, reason, message string) { + cond := util.GetRolloutCondition(*status, v1beta1.RolloutConditionProgressing) if cond == nil { - cond = util.NewRolloutCondition(v1alpha1.RolloutConditionProgressing, condStatus, reason, message) + cond = util.NewRolloutCondition(v1beta1.RolloutConditionProgressing, condStatus, reason, message) } else { cond.Status = condStatus cond.Reason = reason @@ -440,10 +440,10 @@ func progressingStateTransition(status *v1alpha1.RolloutStatus, condStatus corev status.Message = cond.Message } -func setRolloutSucceededCondition(status *v1alpha1.RolloutStatus, condStatus corev1.ConditionStatus) { - cond := util.GetRolloutCondition(*status, v1alpha1.RolloutConditionSucceeded) +func setRolloutSucceededCondition(status *v1beta1.RolloutStatus, condStatus corev1.ConditionStatus) { + cond := util.GetRolloutCondition(*status, v1beta1.RolloutConditionSucceeded) if cond == nil { - cond = util.NewRolloutCondition(v1alpha1.RolloutConditionSucceeded, condStatus, "", "") + cond = util.NewRolloutCondition(v1beta1.RolloutConditionSucceeded, condStatus, "", "") } else { cond.Status = condStatus } diff --git a/pkg/controller/rollout/rollout_progressing_test.go b/pkg/controller/rollout/rollout_progressing_test.go index c1443b0e..984371af 100644 --- a/pkg/controller/rollout/rollout_progressing_test.go +++ b/pkg/controller/rollout/rollout_progressing_test.go @@ -21,7 +21,7 @@ import ( "reflect" "testing" - "github.com/openkruise/rollouts/api/v1alpha1" + "github.com/openkruise/rollouts/api/v1beta1" "github.com/openkruise/rollouts/pkg/trafficrouting" "github.com/openkruise/rollouts/pkg/util" apps "k8s.io/api/apps/v1" @@ -40,9 +40,9 @@ func TestReconcileRolloutProgressing(t *testing.T) { name string getObj func() ([]*apps.Deployment, []*apps.ReplicaSet) getNetwork func() ([]*corev1.Service, []*netv1.Ingress) - getRollout func() (*v1alpha1.Rollout, *v1alpha1.BatchRelease, *v1alpha1.TrafficRouting) - expectStatus func() *v1alpha1.RolloutStatus - expectTr func() *v1alpha1.TrafficRouting + getRollout func() (*v1beta1.Rollout, *v1beta1.BatchRelease, *v1beta1.TrafficRouting) + expectStatus func() *v1beta1.RolloutStatus + expectTr func() *v1beta1.TrafficRouting }{ { name: "ReconcileRolloutProgressing init trafficRouting", @@ -54,22 +54,22 @@ func TestReconcileRolloutProgressing(t *testing.T) { getNetwork: func() ([]*corev1.Service, []*netv1.Ingress) { return []*corev1.Service{demoService.DeepCopy()}, []*netv1.Ingress{demoIngress.DeepCopy()} }, - getRollout: func() (*v1alpha1.Rollout, *v1alpha1.BatchRelease, *v1alpha1.TrafficRouting) { + getRollout: func() (*v1beta1.Rollout, *v1beta1.BatchRelease, *v1beta1.TrafficRouting) { obj := rolloutDemo.DeepCopy() - obj.Annotations[v1alpha1.TrafficRoutingAnnotation] = "tr-demo" + obj.Annotations[v1beta1.TrafficRoutingAnnotation] = "tr-demo" return obj, nil, demoTR.DeepCopy() }, - expectStatus: func() *v1alpha1.RolloutStatus { + expectStatus: func() *v1beta1.RolloutStatus { s := rolloutDemo.Status.DeepCopy() s.CanaryStatus.ObservedWorkloadGeneration = 2 s.CanaryStatus.RolloutHash = "f55bvd874d5f2fzvw46bv966x4bwbdv4wx6bd9f7b46ww788954b8z8w29b7wxfd" s.CanaryStatus.StableRevision = "pod-template-hash-v1" s.CanaryStatus.CanaryRevision = "56855c89f9" s.CanaryStatus.CurrentStepIndex = 1 - s.CanaryStatus.CurrentStepState = v1alpha1.CanaryStepStateUpgrade + s.CanaryStatus.CurrentStepState = v1beta1.CanaryStepStateUpgrade return s }, - expectTr: func() *v1alpha1.TrafficRouting { + expectTr: func() *v1beta1.TrafficRouting { tr := demoTR.DeepCopy() tr.Finalizers = []string{util.ProgressingRolloutFinalizer(rolloutDemo.Name)} return tr @@ -85,22 +85,22 @@ func TestReconcileRolloutProgressing(t *testing.T) { getNetwork: func() ([]*corev1.Service, []*netv1.Ingress) { return []*corev1.Service{demoService.DeepCopy()}, []*netv1.Ingress{demoIngress.DeepCopy()} }, - getRollout: func() (*v1alpha1.Rollout, *v1alpha1.BatchRelease, *v1alpha1.TrafficRouting) { + getRollout: func() (*v1beta1.Rollout, *v1beta1.BatchRelease, *v1beta1.TrafficRouting) { obj := rolloutDemo.DeepCopy() tr := demoTR.DeepCopy() tr.Finalizers = []string{util.ProgressingRolloutFinalizer(rolloutDemo.Name)} return obj, nil, tr }, - expectStatus: func() *v1alpha1.RolloutStatus { + expectStatus: func() *v1beta1.RolloutStatus { s := rolloutDemo.Status.DeepCopy() s.CanaryStatus.ObservedWorkloadGeneration = 2 s.CanaryStatus.RolloutHash = "f55bvd874d5f2fzvw46bv966x4bwbdv4wx6bd9f7b46ww788954b8z8w29b7wxfd" s.CanaryStatus.StableRevision = "pod-template-hash-v1" s.CanaryStatus.CanaryRevision = "56855c89f9" s.CanaryStatus.CurrentStepIndex = 1 - s.CanaryStatus.CurrentStepState = v1alpha1.CanaryStepStateUpgrade - cond := util.GetRolloutCondition(*s, v1alpha1.RolloutConditionProgressing) - cond.Reason = v1alpha1.ProgressingReasonInRolling + s.CanaryStatus.CurrentStepState = v1beta1.CanaryStepStateUpgrade + cond := util.GetRolloutCondition(*s, v1beta1.RolloutConditionProgressing) + cond.Reason = v1beta1.ProgressingReasonInRolling util.SetRolloutCondition(s, *cond) return s }, @@ -132,20 +132,20 @@ func TestReconcileRolloutProgressing(t *testing.T) { getNetwork: func() ([]*corev1.Service, []*netv1.Ingress) { return []*corev1.Service{demoService.DeepCopy()}, []*netv1.Ingress{demoIngress.DeepCopy()} }, - getRollout: func() (*v1alpha1.Rollout, *v1alpha1.BatchRelease, *v1alpha1.TrafficRouting) { + getRollout: func() (*v1beta1.Rollout, *v1beta1.BatchRelease, *v1beta1.TrafficRouting) { obj := rolloutDemo.DeepCopy() obj.Status.CanaryStatus.ObservedWorkloadGeneration = 2 obj.Status.CanaryStatus.RolloutHash = "f55bvd874d5f2fzvw46bv966x4bwbdv4wx6bd9f7b46ww788954b8z8w29b7wxfd" obj.Status.CanaryStatus.StableRevision = "pod-template-hash-v1" obj.Status.CanaryStatus.CanaryRevision = "56855c89f9" obj.Status.CanaryStatus.CurrentStepIndex = 1 - obj.Status.CanaryStatus.CurrentStepState = v1alpha1.CanaryStepStateUpgrade - cond := util.GetRolloutCondition(obj.Status, v1alpha1.RolloutConditionProgressing) - cond.Reason = v1alpha1.ProgressingReasonInRolling + obj.Status.CanaryStatus.CurrentStepState = v1beta1.CanaryStepStateUpgrade + cond := util.GetRolloutCondition(obj.Status, v1beta1.RolloutConditionProgressing) + cond.Reason = v1beta1.ProgressingReasonInRolling util.SetRolloutCondition(&obj.Status, *cond) return obj, nil, nil }, - expectStatus: func() *v1alpha1.RolloutStatus { + expectStatus: func() *v1beta1.RolloutStatus { s := rolloutDemo.Status.DeepCopy() s.CanaryStatus.ObservedWorkloadGeneration = 2 s.CanaryStatus.RolloutHash = "f55bvd874d5f2fzvw46bv966x4bwbdv4wx6bd9f7b46ww788954b8z8w29b7wxfd" @@ -153,9 +153,9 @@ func TestReconcileRolloutProgressing(t *testing.T) { s.CanaryStatus.CanaryRevision = "56855c89f9" s.CanaryStatus.PodTemplateHash = "pod-template-hash-v2" s.CanaryStatus.CurrentStepIndex = 1 - s.CanaryStatus.CurrentStepState = v1alpha1.CanaryStepStateUpgrade - cond := util.GetRolloutCondition(*s, v1alpha1.RolloutConditionProgressing) - cond.Reason = v1alpha1.ProgressingReasonInRolling + s.CanaryStatus.CurrentStepState = v1beta1.CanaryStepStateUpgrade + cond := util.GetRolloutCondition(*s, v1beta1.RolloutConditionProgressing) + cond.Reason = v1beta1.ProgressingReasonInRolling util.SetRolloutCondition(s, *cond) return s }, @@ -187,7 +187,7 @@ func TestReconcileRolloutProgressing(t *testing.T) { getNetwork: func() ([]*corev1.Service, []*netv1.Ingress) { return []*corev1.Service{demoService.DeepCopy()}, []*netv1.Ingress{demoIngress.DeepCopy()} }, - getRollout: func() (*v1alpha1.Rollout, *v1alpha1.BatchRelease, *v1alpha1.TrafficRouting) { + getRollout: func() (*v1beta1.Rollout, *v1beta1.BatchRelease, *v1beta1.TrafficRouting) { obj := rolloutDemo.DeepCopy() obj.Status.CanaryStatus.ObservedWorkloadGeneration = 2 obj.Status.CanaryStatus.RolloutHash = "f55bvd874d5f2fzvw46bv966x4bwbdv4wx6bd9f7b46ww788954b8z8w29b7wxfd" @@ -195,13 +195,13 @@ func TestReconcileRolloutProgressing(t *testing.T) { obj.Status.CanaryStatus.CanaryRevision = "56855c89f9" obj.Status.CanaryStatus.PodTemplateHash = "pod-template-hash-v2" obj.Status.CanaryStatus.CurrentStepIndex = 4 - obj.Status.CanaryStatus.CurrentStepState = v1alpha1.CanaryStepStateCompleted - cond := util.GetRolloutCondition(obj.Status, v1alpha1.RolloutConditionProgressing) - cond.Reason = v1alpha1.ProgressingReasonInRolling + obj.Status.CanaryStatus.CurrentStepState = v1beta1.CanaryStepStateCompleted + cond := util.GetRolloutCondition(obj.Status, v1beta1.RolloutConditionProgressing) + cond.Reason = v1beta1.ProgressingReasonInRolling util.SetRolloutCondition(&obj.Status, *cond) return obj, nil, nil }, - expectStatus: func() *v1alpha1.RolloutStatus { + expectStatus: func() *v1beta1.RolloutStatus { s := rolloutDemo.Status.DeepCopy() s.CanaryStatus.ObservedWorkloadGeneration = 2 s.CanaryStatus.RolloutHash = "f55bvd874d5f2fzvw46bv966x4bwbdv4wx6bd9f7b46ww788954b8z8w29b7wxfd" @@ -209,9 +209,9 @@ func TestReconcileRolloutProgressing(t *testing.T) { s.CanaryStatus.CanaryRevision = "56855c89f9" s.CanaryStatus.PodTemplateHash = "pod-template-hash-v2" s.CanaryStatus.CurrentStepIndex = 4 - s.CanaryStatus.CurrentStepState = v1alpha1.CanaryStepStateCompleted - cond := util.GetRolloutCondition(*s, v1alpha1.RolloutConditionProgressing) - cond.Reason = v1alpha1.ProgressingReasonFinalising + s.CanaryStatus.CurrentStepState = v1beta1.CanaryStepStateCompleted + cond := util.GetRolloutCondition(*s, v1beta1.RolloutConditionProgressing) + cond.Reason = v1beta1.ProgressingReasonFinalising cond.Status = corev1.ConditionTrue util.SetRolloutCondition(s, *cond) return s @@ -235,22 +235,22 @@ func TestReconcileRolloutProgressing(t *testing.T) { getNetwork: func() ([]*corev1.Service, []*netv1.Ingress) { return []*corev1.Service{demoService.DeepCopy()}, []*netv1.Ingress{demoIngress.DeepCopy()} }, - getRollout: func() (*v1alpha1.Rollout, *v1alpha1.BatchRelease, *v1alpha1.TrafficRouting) { + getRollout: func() (*v1beta1.Rollout, *v1beta1.BatchRelease, *v1beta1.TrafficRouting) { obj := rolloutDemo.DeepCopy() - obj.Annotations[v1alpha1.TrafficRoutingAnnotation] = "tr-demo" + obj.Annotations[v1beta1.TrafficRoutingAnnotation] = "tr-demo" obj.Status.CanaryStatus.ObservedWorkloadGeneration = 2 obj.Status.CanaryStatus.RolloutHash = "f55bvd874d5f2fzvw46bv966x4bwbdv4wx6bd9f7b46ww788954b8z8w29b7wxfd" obj.Status.CanaryStatus.StableRevision = "pod-template-hash-v1" obj.Status.CanaryStatus.CanaryRevision = "56855c89f9" obj.Status.CanaryStatus.PodTemplateHash = "pod-template-hash-v2" obj.Status.CanaryStatus.CurrentStepIndex = 4 - obj.Status.CanaryStatus.CurrentStepState = v1alpha1.CanaryStepStateCompleted - cond := util.GetRolloutCondition(obj.Status, v1alpha1.RolloutConditionProgressing) - cond.Reason = v1alpha1.ProgressingReasonFinalising + obj.Status.CanaryStatus.CurrentStepState = v1beta1.CanaryStepStateCompleted + cond := util.GetRolloutCondition(obj.Status, v1beta1.RolloutConditionProgressing) + cond.Reason = v1beta1.ProgressingReasonFinalising cond.Status = corev1.ConditionTrue util.SetRolloutCondition(&obj.Status, *cond) br := batchDemo.DeepCopy() - br.Spec.ReleasePlan.Batches = []v1alpha1.ReleaseBatch{ + br.Spec.ReleasePlan.Batches = []v1beta1.ReleaseBatch{ { CanaryReplicas: intstr.FromInt(1), }, @@ -259,7 +259,7 @@ func TestReconcileRolloutProgressing(t *testing.T) { tr.Finalizers = []string{util.ProgressingRolloutFinalizer(rolloutDemo.Name)} return obj, br, tr }, - expectStatus: func() *v1alpha1.RolloutStatus { + expectStatus: func() *v1beta1.RolloutStatus { s := rolloutDemo.Status.DeepCopy() s.CanaryStatus.ObservedWorkloadGeneration = 2 s.CanaryStatus.RolloutHash = "f55bvd874d5f2fzvw46bv966x4bwbdv4wx6bd9f7b46ww788954b8z8w29b7wxfd" @@ -267,14 +267,14 @@ func TestReconcileRolloutProgressing(t *testing.T) { s.CanaryStatus.CanaryRevision = "56855c89f9" s.CanaryStatus.PodTemplateHash = "pod-template-hash-v2" s.CanaryStatus.CurrentStepIndex = 4 - s.CanaryStatus.CurrentStepState = v1alpha1.CanaryStepStateCompleted - cond := util.GetRolloutCondition(*s, v1alpha1.RolloutConditionProgressing) - cond.Reason = v1alpha1.ProgressingReasonFinalising + s.CanaryStatus.CurrentStepState = v1beta1.CanaryStepStateCompleted + cond := util.GetRolloutCondition(*s, v1beta1.RolloutConditionProgressing) + cond.Reason = v1beta1.ProgressingReasonFinalising cond.Status = corev1.ConditionTrue util.SetRolloutCondition(s, *cond) return s }, - expectTr: func() *v1alpha1.TrafficRouting { + expectTr: func() *v1beta1.TrafficRouting { tr := demoTR.DeepCopy() return tr }, @@ -297,7 +297,7 @@ func TestReconcileRolloutProgressing(t *testing.T) { getNetwork: func() ([]*corev1.Service, []*netv1.Ingress) { return []*corev1.Service{demoService.DeepCopy()}, []*netv1.Ingress{demoIngress.DeepCopy()} }, - getRollout: func() (*v1alpha1.Rollout, *v1alpha1.BatchRelease, *v1alpha1.TrafficRouting) { + getRollout: func() (*v1beta1.Rollout, *v1beta1.BatchRelease, *v1beta1.TrafficRouting) { obj := rolloutDemo.DeepCopy() obj.Status.CanaryStatus.ObservedWorkloadGeneration = 2 obj.Status.CanaryStatus.RolloutHash = "f55bvd874d5f2fzvw46bv966x4bwbdv4wx6bd9f7b46ww788954b8z8w29b7wxfd" @@ -305,21 +305,21 @@ func TestReconcileRolloutProgressing(t *testing.T) { obj.Status.CanaryStatus.CanaryRevision = "56855c89f9" obj.Status.CanaryStatus.PodTemplateHash = "pod-template-hash-v2" obj.Status.CanaryStatus.CurrentStepIndex = 4 - obj.Status.CanaryStatus.CurrentStepState = v1alpha1.CanaryStepStateCompleted - cond := util.GetRolloutCondition(obj.Status, v1alpha1.RolloutConditionProgressing) - cond.Reason = v1alpha1.ProgressingReasonFinalising + obj.Status.CanaryStatus.CurrentStepState = v1beta1.CanaryStepStateCompleted + cond := util.GetRolloutCondition(obj.Status, v1beta1.RolloutConditionProgressing) + cond.Reason = v1beta1.ProgressingReasonFinalising cond.Status = corev1.ConditionTrue util.SetRolloutCondition(&obj.Status, *cond) br := batchDemo.DeepCopy() - br.Spec.ReleasePlan.Batches = []v1alpha1.ReleaseBatch{ + br.Spec.ReleasePlan.Batches = []v1beta1.ReleaseBatch{ { CanaryReplicas: intstr.FromInt(1), }, } - br.Status.Phase = v1alpha1.RolloutPhaseCompleted + br.Status.Phase = v1beta1.RolloutPhaseCompleted return obj, br, nil }, - expectStatus: func() *v1alpha1.RolloutStatus { + expectStatus: func() *v1beta1.RolloutStatus { s := rolloutDemo.Status.DeepCopy() s.CanaryStatus.ObservedWorkloadGeneration = 2 s.CanaryStatus.RolloutHash = "f55bvd874d5f2fzvw46bv966x4bwbdv4wx6bd9f7b46ww788954b8z8w29b7wxfd" @@ -327,9 +327,9 @@ func TestReconcileRolloutProgressing(t *testing.T) { s.CanaryStatus.CanaryRevision = "56855c89f9" s.CanaryStatus.PodTemplateHash = "pod-template-hash-v2" s.CanaryStatus.CurrentStepIndex = 4 - s.CanaryStatus.CurrentStepState = v1alpha1.CanaryStepStateCompleted - cond2 := util.GetRolloutCondition(*s, v1alpha1.RolloutConditionProgressing) - cond2.Reason = v1alpha1.ProgressingReasonFinalising + s.CanaryStatus.CurrentStepState = v1beta1.CanaryStepStateCompleted + cond2 := util.GetRolloutCondition(*s, v1beta1.RolloutConditionProgressing) + cond2.Reason = v1beta1.ProgressingReasonFinalising cond2.Status = corev1.ConditionTrue util.SetRolloutCondition(s, *cond2) return s @@ -353,7 +353,7 @@ func TestReconcileRolloutProgressing(t *testing.T) { getNetwork: func() ([]*corev1.Service, []*netv1.Ingress) { return []*corev1.Service{demoService.DeepCopy()}, []*netv1.Ingress{demoIngress.DeepCopy()} }, - getRollout: func() (*v1alpha1.Rollout, *v1alpha1.BatchRelease, *v1alpha1.TrafficRouting) { + getRollout: func() (*v1beta1.Rollout, *v1beta1.BatchRelease, *v1beta1.TrafficRouting) { obj := rolloutDemo.DeepCopy() obj.Status.CanaryStatus.ObservedWorkloadGeneration = 2 obj.Status.CanaryStatus.RolloutHash = "f55bvd874d5f2fzvw46bv966x4bwbdv4wx6bd9f7b46ww788954b8z8w29b7wxfd" @@ -361,14 +361,14 @@ func TestReconcileRolloutProgressing(t *testing.T) { obj.Status.CanaryStatus.CanaryRevision = "56855c89f9" obj.Status.CanaryStatus.PodTemplateHash = "pod-template-hash-v2" obj.Status.CanaryStatus.CurrentStepIndex = 4 - obj.Status.CanaryStatus.CurrentStepState = v1alpha1.CanaryStepStateCompleted - cond := util.GetRolloutCondition(obj.Status, v1alpha1.RolloutConditionProgressing) - cond.Reason = v1alpha1.ProgressingReasonFinalising + obj.Status.CanaryStatus.CurrentStepState = v1beta1.CanaryStepStateCompleted + cond := util.GetRolloutCondition(obj.Status, v1beta1.RolloutConditionProgressing) + cond.Reason = v1beta1.ProgressingReasonFinalising cond.Status = corev1.ConditionTrue util.SetRolloutCondition(&obj.Status, *cond) return obj, nil, nil }, - expectStatus: func() *v1alpha1.RolloutStatus { + expectStatus: func() *v1beta1.RolloutStatus { s := rolloutDemo.Status.DeepCopy() s.CanaryStatus.ObservedWorkloadGeneration = 2 s.CanaryStatus.RolloutHash = "f55bvd874d5f2fzvw46bv966x4bwbdv4wx6bd9f7b46ww788954b8z8w29b7wxfd" @@ -376,12 +376,12 @@ func TestReconcileRolloutProgressing(t *testing.T) { s.CanaryStatus.CanaryRevision = "56855c89f9" s.CanaryStatus.PodTemplateHash = "pod-template-hash-v2" s.CanaryStatus.CurrentStepIndex = 4 - s.CanaryStatus.CurrentStepState = v1alpha1.CanaryStepStateCompleted - cond2 := util.GetRolloutCondition(*s, v1alpha1.RolloutConditionProgressing) - cond2.Reason = v1alpha1.ProgressingReasonCompleted + s.CanaryStatus.CurrentStepState = v1beta1.CanaryStepStateCompleted + cond2 := util.GetRolloutCondition(*s, v1beta1.RolloutConditionProgressing) + cond2.Reason = v1beta1.ProgressingReasonCompleted cond2.Status = corev1.ConditionFalse util.SetRolloutCondition(s, *cond2) - cond1 := util.NewRolloutCondition(v1alpha1.RolloutConditionSucceeded, corev1.ConditionTrue, "", "") + cond1 := util.NewRolloutCondition(v1beta1.RolloutConditionSucceeded, corev1.ConditionTrue, "", "") cond1.LastUpdateTime = metav1.Time{} cond1.LastTransitionTime = metav1.Time{} util.SetRolloutCondition(s, *cond1) @@ -416,7 +416,7 @@ func TestReconcileRolloutProgressing(t *testing.T) { getNetwork: func() ([]*corev1.Service, []*netv1.Ingress) { return []*corev1.Service{demoService.DeepCopy()}, []*netv1.Ingress{demoIngress.DeepCopy()} }, - getRollout: func() (*v1alpha1.Rollout, *v1alpha1.BatchRelease, *v1alpha1.TrafficRouting) { + getRollout: func() (*v1beta1.Rollout, *v1beta1.BatchRelease, *v1beta1.TrafficRouting) { obj := rolloutDemo.DeepCopy() obj.Status.CanaryStatus.ObservedWorkloadGeneration = 2 obj.Status.CanaryStatus.RolloutHash = "f55bvd874d5f2fzvw46bv966x4bwbdv4wx6bd9f7b46ww788954b8z8w29b7wxfd" @@ -424,13 +424,13 @@ func TestReconcileRolloutProgressing(t *testing.T) { obj.Status.CanaryStatus.CanaryRevision = "56855c89f9" obj.Status.CanaryStatus.CurrentStepIndex = 1 obj.Status.CanaryStatus.PodTemplateHash = "pod-template-hash-v2" - obj.Status.CanaryStatus.CurrentStepState = v1alpha1.CanaryStepStateUpgrade - cond := util.GetRolloutCondition(obj.Status, v1alpha1.RolloutConditionProgressing) - cond.Reason = v1alpha1.ProgressingReasonInRolling + obj.Status.CanaryStatus.CurrentStepState = v1beta1.CanaryStepStateUpgrade + cond := util.GetRolloutCondition(obj.Status, v1beta1.RolloutConditionProgressing) + cond.Reason = v1beta1.ProgressingReasonInRolling util.SetRolloutCondition(&obj.Status, *cond) return obj, nil, nil }, - expectStatus: func() *v1alpha1.RolloutStatus { + expectStatus: func() *v1beta1.RolloutStatus { s := rolloutDemo.Status.DeepCopy() s.CanaryStatus.ObservedWorkloadGeneration = 2 s.CanaryStatus.RolloutHash = "f55bvd874d5f2fzvw46bv966x4bwbdv4wx6bd9f7b46ww788954b8z8w29b7wxfd" @@ -438,9 +438,9 @@ func TestReconcileRolloutProgressing(t *testing.T) { s.CanaryStatus.CanaryRevision = "5d48f79ff8" s.CanaryStatus.PodTemplateHash = "pod-template-hash-v2" s.CanaryStatus.CurrentStepIndex = 1 - s.CanaryStatus.CurrentStepState = v1alpha1.CanaryStepStateUpgrade - cond := util.GetRolloutCondition(*s, v1alpha1.RolloutConditionProgressing) - cond.Reason = v1alpha1.ProgressingReasonCancelling + s.CanaryStatus.CurrentStepState = v1beta1.CanaryStepStateUpgrade + cond := util.GetRolloutCondition(*s, v1beta1.RolloutConditionProgressing) + cond.Reason = v1beta1.ProgressingReasonCancelling util.SetRolloutCondition(s, *cond) return s }, @@ -473,7 +473,7 @@ func TestReconcileRolloutProgressing(t *testing.T) { getNetwork: func() ([]*corev1.Service, []*netv1.Ingress) { return []*corev1.Service{demoService.DeepCopy()}, []*netv1.Ingress{demoIngress.DeepCopy()} }, - getRollout: func() (*v1alpha1.Rollout, *v1alpha1.BatchRelease, *v1alpha1.TrafficRouting) { + getRollout: func() (*v1beta1.Rollout, *v1beta1.BatchRelease, *v1beta1.TrafficRouting) { obj := rolloutDemo.DeepCopy() obj.Status.CanaryStatus.ObservedWorkloadGeneration = 2 obj.Status.CanaryStatus.RolloutHash = "f55bvd874d5f2fzvw46bv966x4bwbdv4wx6bd9f7b46ww788954b8z8w29b7wxfd" @@ -481,13 +481,13 @@ func TestReconcileRolloutProgressing(t *testing.T) { obj.Status.CanaryStatus.CanaryRevision = "56855c89f9" obj.Status.CanaryStatus.CurrentStepIndex = 1 obj.Status.CanaryStatus.PodTemplateHash = "pod-template-hash-v2" - obj.Status.CanaryStatus.CurrentStepState = v1alpha1.CanaryStepStateUpgrade - cond := util.GetRolloutCondition(obj.Status, v1alpha1.RolloutConditionProgressing) - cond.Reason = v1alpha1.ProgressingReasonInRolling + obj.Status.CanaryStatus.CurrentStepState = v1beta1.CanaryStepStateUpgrade + cond := util.GetRolloutCondition(obj.Status, v1beta1.RolloutConditionProgressing) + cond.Reason = v1beta1.ProgressingReasonInRolling util.SetRolloutCondition(&obj.Status, *cond) return obj, nil, nil }, - expectStatus: func() *v1alpha1.RolloutStatus { + expectStatus: func() *v1beta1.RolloutStatus { s := rolloutDemo.Status.DeepCopy() s.CanaryStatus.ObservedWorkloadGeneration = 2 s.CanaryStatus.RolloutHash = "f55bvd874d5f2fzvw46bv966x4bwbdv4wx6bd9f7b46ww788954b8z8w29b7wxfd" @@ -495,9 +495,9 @@ func TestReconcileRolloutProgressing(t *testing.T) { s.CanaryStatus.CanaryRevision = "5d48f79ff8" s.CanaryStatus.PodTemplateHash = "pod-template-hash-v2" s.CanaryStatus.CurrentStepIndex = 1 - s.CanaryStatus.CurrentStepState = v1alpha1.CanaryStepStateUpgrade - cond := util.GetRolloutCondition(*s, v1alpha1.RolloutConditionProgressing) - cond.Reason = v1alpha1.ProgressingReasonCancelling + s.CanaryStatus.CurrentStepState = v1beta1.CanaryStepStateUpgrade + cond := util.GetRolloutCondition(*s, v1beta1.RolloutConditionProgressing) + cond.Reason = v1beta1.ProgressingReasonCancelling util.SetRolloutCondition(s, *cond) return s }, @@ -530,7 +530,7 @@ func TestReconcileRolloutProgressing(t *testing.T) { getNetwork: func() ([]*corev1.Service, []*netv1.Ingress) { return []*corev1.Service{demoService.DeepCopy()}, []*netv1.Ingress{demoIngress.DeepCopy()} }, - getRollout: func() (*v1alpha1.Rollout, *v1alpha1.BatchRelease, *v1alpha1.TrafficRouting) { + getRollout: func() (*v1beta1.Rollout, *v1beta1.BatchRelease, *v1beta1.TrafficRouting) { obj := rolloutDemo.DeepCopy() obj.Status.CanaryStatus.ObservedWorkloadGeneration = 2 obj.Status.CanaryStatus.RolloutHash = "f55bvd874d5f2fzvw46bv966x4bwbdv4wx6bd9f7b46ww788954b8z8w29b7wxfd" @@ -540,17 +540,17 @@ func TestReconcileRolloutProgressing(t *testing.T) { obj.Status.CanaryStatus.CanaryReplicas = 5 obj.Status.CanaryStatus.CanaryReadyReplicas = 3 obj.Status.CanaryStatus.PodTemplateHash = "pod-template-hash-v2" - obj.Status.CanaryStatus.CurrentStepState = v1alpha1.CanaryStepStateUpgrade - cond := util.GetRolloutCondition(obj.Status, v1alpha1.RolloutConditionProgressing) - cond.Reason = v1alpha1.ProgressingReasonInRolling + obj.Status.CanaryStatus.CurrentStepState = v1beta1.CanaryStepStateUpgrade + cond := util.GetRolloutCondition(obj.Status, v1beta1.RolloutConditionProgressing) + cond.Reason = v1beta1.ProgressingReasonInRolling util.SetRolloutCondition(&obj.Status, *cond) return obj, nil, nil }, - expectStatus: func() *v1alpha1.RolloutStatus { + expectStatus: func() *v1beta1.RolloutStatus { s := rolloutDemo.Status.DeepCopy() s.CanaryStatus = nil - cond := util.GetRolloutCondition(*s, v1alpha1.RolloutConditionProgressing) - cond.Reason = v1alpha1.ProgressingReasonInitializing + cond := util.GetRolloutCondition(*s, v1beta1.RolloutConditionProgressing) + cond.Reason = v1beta1.ProgressingReasonInitializing util.SetRolloutCondition(s, *cond) return s }, @@ -602,7 +602,7 @@ func TestReconcileRolloutProgressing(t *testing.T) { checkRolloutEqual(fc, t, client.ObjectKey{Name: rollout.Name}, cs.expectStatus()) if cs.expectTr != nil { expectTr := cs.expectTr() - obj := &v1alpha1.TrafficRouting{} + obj := &v1beta1.TrafficRouting{} err = fc.Get(context.TODO(), client.ObjectKey{Name: expectTr.Name}, obj) if err != nil { t.Fatalf("get object failed: %s", err.Error()) @@ -615,8 +615,8 @@ func TestReconcileRolloutProgressing(t *testing.T) { } } -func checkRolloutEqual(c client.WithWatch, t *testing.T, key client.ObjectKey, expect *v1alpha1.RolloutStatus) { - obj := &v1alpha1.Rollout{} +func checkRolloutEqual(c client.WithWatch, t *testing.T, key client.ObjectKey, expect *v1beta1.RolloutStatus) { + obj := &v1beta1.Rollout{} err := c.Get(context.TODO(), key, obj) if err != nil { t.Fatalf("get object failed: %s", err.Error()) @@ -626,12 +626,12 @@ func checkRolloutEqual(c client.WithWatch, t *testing.T, key client.ObjectKey, e if cStatus.CanaryStatus != nil { cStatus.CanaryStatus.LastUpdateTime = nil } - cond1 := util.GetRolloutCondition(*cStatus, v1alpha1.RolloutConditionProgressing) + cond1 := util.GetRolloutCondition(*cStatus, v1beta1.RolloutConditionProgressing) cond1.Message = "" util.SetRolloutCondition(cStatus, *cond1) - cond2 := util.GetRolloutCondition(*cStatus, v1alpha1.RolloutConditionSucceeded) + cond2 := util.GetRolloutCondition(*cStatus, v1beta1.RolloutConditionSucceeded) if cond2 != nil { - util.RemoveRolloutCondition(cStatus, v1alpha1.RolloutConditionSucceeded) + util.RemoveRolloutCondition(cStatus, v1beta1.RolloutConditionSucceeded) cond2.LastUpdateTime = metav1.Time{} cond2.LastTransitionTime = metav1.Time{} util.SetRolloutCondition(cStatus, *cond2) @@ -645,8 +645,8 @@ func TestReCalculateCanaryStepIndex(t *testing.T) { cases := []struct { name string getObj func() (*apps.Deployment, *apps.ReplicaSet) - getRollout func() *v1alpha1.Rollout - getBatchRelease func() *v1alpha1.BatchRelease + getRollout func() *v1beta1.Rollout + getBatchRelease func() *v1beta1.BatchRelease expectStepIndex int32 }{ { @@ -655,30 +655,30 @@ func TestReCalculateCanaryStepIndex(t *testing.T) { obj := deploymentDemo.DeepCopy() return obj, rsDemo.DeepCopy() }, - getRollout: func() *v1alpha1.Rollout { + getRollout: func() *v1beta1.Rollout { obj := rolloutDemo.DeepCopy() - obj.Spec.Strategy.Canary.Steps = []v1alpha1.CanaryStep{ + obj.Spec.Strategy.Canary.Steps = []v1beta1.CanaryStep{ { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(20), }, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(50), }, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(100), }, }, } return obj }, - getBatchRelease: func() *v1alpha1.BatchRelease { + getBatchRelease: func() *v1beta1.BatchRelease { obj := batchDemo.DeepCopy() - obj.Spec.ReleasePlan.Batches = []v1alpha1.ReleaseBatch{ + obj.Spec.ReleasePlan.Batches = []v1beta1.ReleaseBatch{ { CanaryReplicas: intstr.FromString("40%"), }, @@ -700,30 +700,30 @@ func TestReCalculateCanaryStepIndex(t *testing.T) { obj := deploymentDemo.DeepCopy() return obj, rsDemo.DeepCopy() }, - getRollout: func() *v1alpha1.Rollout { + getRollout: func() *v1beta1.Rollout { obj := rolloutDemo.DeepCopy() - obj.Spec.Strategy.Canary.Steps = []v1alpha1.CanaryStep{ + obj.Spec.Strategy.Canary.Steps = []v1beta1.CanaryStep{ { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(20), }, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(40), }, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(100), }, }, } return obj }, - getBatchRelease: func() *v1alpha1.BatchRelease { + getBatchRelease: func() *v1beta1.BatchRelease { obj := batchDemo.DeepCopy() - obj.Spec.ReleasePlan.Batches = []v1alpha1.ReleaseBatch{ + obj.Spec.ReleasePlan.Batches = []v1beta1.ReleaseBatch{ { CanaryReplicas: intstr.FromString("40%"), }, @@ -745,30 +745,30 @@ func TestReCalculateCanaryStepIndex(t *testing.T) { obj := deploymentDemo.DeepCopy() return obj, rsDemo.DeepCopy() }, - getRollout: func() *v1alpha1.Rollout { + getRollout: func() *v1beta1.Rollout { obj := rolloutDemo.DeepCopy() - obj.Spec.Strategy.Canary.Steps = []v1alpha1.CanaryStep{ + obj.Spec.Strategy.Canary.Steps = []v1beta1.CanaryStep{ { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(40), }, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(60), }, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(100), }, }, } return obj }, - getBatchRelease: func() *v1alpha1.BatchRelease { + getBatchRelease: func() *v1beta1.BatchRelease { obj := batchDemo.DeepCopy() - obj.Spec.ReleasePlan.Batches = []v1alpha1.ReleaseBatch{ + obj.Spec.ReleasePlan.Batches = []v1beta1.ReleaseBatch{ { CanaryReplicas: intstr.FromString("20%"), }, @@ -790,30 +790,30 @@ func TestReCalculateCanaryStepIndex(t *testing.T) { obj := deploymentDemo.DeepCopy() return obj, rsDemo.DeepCopy() }, - getRollout: func() *v1alpha1.Rollout { + getRollout: func() *v1beta1.Rollout { obj := rolloutDemo.DeepCopy() - obj.Spec.Strategy.Canary.Steps = []v1alpha1.CanaryStep{ + obj.Spec.Strategy.Canary.Steps = []v1beta1.CanaryStep{ { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(10), }, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(30), }, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(100), }, }, } return obj }, - getBatchRelease: func() *v1alpha1.BatchRelease { + getBatchRelease: func() *v1beta1.BatchRelease { obj := batchDemo.DeepCopy() - obj.Spec.ReleasePlan.Batches = []v1alpha1.ReleaseBatch{ + obj.Spec.ReleasePlan.Batches = []v1beta1.ReleaseBatch{ { CanaryReplicas: intstr.FromString("20%"), }, @@ -835,11 +835,11 @@ func TestReCalculateCanaryStepIndex(t *testing.T) { obj := deploymentDemo.DeepCopy() return obj, rsDemo.DeepCopy() }, - getRollout: func() *v1alpha1.Rollout { + getRollout: func() *v1beta1.Rollout { obj := rolloutDemo.DeepCopy() - obj.Spec.Strategy.Canary.Steps = []v1alpha1.CanaryStep{ + obj.Spec.Strategy.Canary.Steps = []v1beta1.CanaryStep{ { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(2), }, Replicas: &intstr.IntOrString{ @@ -848,7 +848,7 @@ func TestReCalculateCanaryStepIndex(t *testing.T) { }, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(3), }, Replicas: &intstr.IntOrString{ @@ -859,9 +859,9 @@ func TestReCalculateCanaryStepIndex(t *testing.T) { } return obj }, - getBatchRelease: func() *v1alpha1.BatchRelease { + getBatchRelease: func() *v1beta1.BatchRelease { obj := batchDemo.DeepCopy() - obj.Spec.ReleasePlan.Batches = []v1alpha1.ReleaseBatch{ + obj.Spec.ReleasePlan.Batches = []v1beta1.ReleaseBatch{ { CanaryReplicas: intstr.FromString("10%"), }, diff --git a/pkg/controller/rollout/rollout_status.go b/pkg/controller/rollout/rollout_status.go index 161523cf..0aabb282 100755 --- a/pkg/controller/rollout/rollout_status.go +++ b/pkg/controller/rollout/rollout_status.go @@ -22,7 +22,7 @@ import ( "reflect" "time" - "github.com/openkruise/rollouts/api/v1alpha1" + "github.com/openkruise/rollouts/api/v1beta1" "github.com/openkruise/rollouts/pkg/util" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime/schema" @@ -34,7 +34,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" ) -func (r *RolloutReconciler) calculateRolloutStatus(rollout *v1alpha1.Rollout) (retry bool, newStatus *v1alpha1.RolloutStatus, err error) { +func (r *RolloutReconciler) calculateRolloutStatus(rollout *v1beta1.Rollout) (retry bool, newStatus *v1beta1.RolloutStatus, err error) { // hash rollout if err = r.calculateRolloutHash(rollout); err != nil { return false, nil, err @@ -43,27 +43,27 @@ func (r *RolloutReconciler) calculateRolloutStatus(rollout *v1alpha1.Rollout) (r newStatus.ObservedGeneration = rollout.GetGeneration() // delete rollout CRD if !rollout.DeletionTimestamp.IsZero() { - if newStatus.Phase != v1alpha1.RolloutPhaseTerminating { - newStatus.Phase = v1alpha1.RolloutPhaseTerminating - cond := util.NewRolloutCondition(v1alpha1.RolloutConditionTerminating, corev1.ConditionTrue, v1alpha1.TerminatingReasonInTerminating, "Rollout is in terminating") + if newStatus.Phase != v1beta1.RolloutPhaseTerminating { + newStatus.Phase = v1beta1.RolloutPhaseTerminating + cond := util.NewRolloutCondition(v1beta1.RolloutConditionTerminating, corev1.ConditionTrue, v1beta1.TerminatingReasonInTerminating, "Rollout is in terminating") util.SetRolloutCondition(newStatus, *cond) } return false, newStatus, nil } - if rollout.Spec.Disabled && newStatus.Phase != v1alpha1.RolloutPhaseDisabled && newStatus.Phase != v1alpha1.RolloutPhaseDisabling { + if rollout.Spec.Disabled && newStatus.Phase != v1beta1.RolloutPhaseDisabled && newStatus.Phase != v1beta1.RolloutPhaseDisabling { // if rollout in progressing, indicates a working rollout is disabled, then the rollout should be finalized - if newStatus.Phase == v1alpha1.RolloutPhaseProgressing { - newStatus.Phase = v1alpha1.RolloutPhaseDisabling + if newStatus.Phase == v1beta1.RolloutPhaseProgressing { + newStatus.Phase = v1beta1.RolloutPhaseDisabling newStatus.Message = "Disabling rollout, release resources" } else { - newStatus.Phase = v1alpha1.RolloutPhaseDisabled + newStatus.Phase = v1beta1.RolloutPhaseDisabled newStatus.Message = "Rollout is disabled" } } if newStatus.Phase == "" { - newStatus.Phase = v1alpha1.RolloutPhaseInitial + newStatus.Phase = v1beta1.RolloutPhaseInitial } // get ref workload workload, err := r.finder.GetWorkloadForRef(rollout) @@ -72,9 +72,9 @@ func (r *RolloutReconciler) calculateRolloutStatus(rollout *v1alpha1.Rollout) (r return false, nil, err } else if workload == nil { if !rollout.Spec.Disabled { - newStatus = &v1alpha1.RolloutStatus{ + newStatus = &v1beta1.RolloutStatus{ ObservedGeneration: rollout.Generation, - Phase: v1alpha1.RolloutPhaseInitial, + Phase: v1beta1.RolloutPhaseInitial, Message: "Workload Not Found", } klog.Infof("rollout(%s/%s) workload not found, and reset status be Initial", rollout.Namespace, rollout.Name) @@ -97,18 +97,18 @@ func (r *RolloutReconciler) calculateRolloutStatus(rollout *v1alpha1.Rollout) (r } switch newStatus.Phase { - case v1alpha1.RolloutPhaseInitial: - klog.Infof("rollout(%s/%s) status phase from(%s) -> to(%s)", rollout.Namespace, rollout.Name, v1alpha1.RolloutPhaseInitial, v1alpha1.RolloutPhaseHealthy) - newStatus.Phase = v1alpha1.RolloutPhaseHealthy + case v1beta1.RolloutPhaseInitial: + klog.Infof("rollout(%s/%s) status phase from(%s) -> to(%s)", rollout.Namespace, rollout.Name, v1beta1.RolloutPhaseInitial, v1beta1.RolloutPhaseHealthy) + newStatus.Phase = v1beta1.RolloutPhaseHealthy newStatus.Message = "rollout is healthy" - case v1alpha1.RolloutPhaseHealthy: + case v1beta1.RolloutPhaseHealthy: // workload released, entering the rollout progressing phase if workload.InRolloutProgressing { - klog.Infof("rollout(%s/%s) status phase from(%s) -> to(%s)", rollout.Namespace, rollout.Name, v1alpha1.RolloutPhaseHealthy, v1alpha1.RolloutPhaseProgressing) - newStatus.Phase = v1alpha1.RolloutPhaseProgressing - cond := util.NewRolloutCondition(v1alpha1.RolloutConditionProgressing, corev1.ConditionTrue, v1alpha1.ProgressingReasonInitializing, "Rollout is in Progressing") + klog.Infof("rollout(%s/%s) status phase from(%s) -> to(%s)", rollout.Namespace, rollout.Name, v1beta1.RolloutPhaseHealthy, v1beta1.RolloutPhaseProgressing) + newStatus.Phase = v1beta1.RolloutPhaseProgressing + cond := util.NewRolloutCondition(v1beta1.RolloutConditionProgressing, corev1.ConditionTrue, v1beta1.ProgressingReasonInitializing, "Rollout is in Progressing") util.SetRolloutCondition(newStatus, *cond) - util.RemoveRolloutCondition(newStatus, v1alpha1.RolloutConditionSucceeded) + util.RemoveRolloutCondition(newStatus, v1beta1.RolloutConditionSucceeded) } else if newStatus.CanaryStatus == nil { // The following logic is to make PaaS be able to judge whether the rollout is ready // at the first deployment of the Rollout/Workload. For example: generally, a PaaS @@ -123,21 +123,21 @@ func (r *RolloutReconciler) calculateRolloutStatus(rollout *v1alpha1.Rollout) (r // and PaaS platform cannot judge whether the deployment is completed base on the code above. So we have // to update the status just like the rollout was completed. - newStatus.CanaryStatus = &v1alpha1.CanaryStatus{ + newStatus.CanaryStatus = &v1beta1.CanaryStatus{ ObservedRolloutID: getRolloutID(workload), ObservedWorkloadGeneration: workload.Generation, PodTemplateHash: workload.PodTemplateHash, CanaryRevision: workload.CanaryRevision, StableRevision: workload.StableRevision, CurrentStepIndex: int32(len(rollout.Spec.Strategy.Canary.Steps)), - CurrentStepState: v1alpha1.CanaryStepStateCompleted, + CurrentStepState: v1beta1.CanaryStepStateCompleted, RolloutHash: rollout.Annotations[util.RolloutHashAnnotation], } newStatus.Message = "workload deployment is completed" } - case v1alpha1.RolloutPhaseDisabled: + case v1beta1.RolloutPhaseDisabled: if !rollout.Spec.Disabled { - newStatus.Phase = v1alpha1.RolloutPhaseHealthy + newStatus.Phase = v1beta1.RolloutPhaseHealthy newStatus.Message = "rollout is healthy" } } @@ -146,13 +146,13 @@ func (r *RolloutReconciler) calculateRolloutStatus(rollout *v1alpha1.Rollout) (r // rolloutHash mainly records the step batch information, when the user step changes, // the current batch can be recalculated -func (r *RolloutReconciler) calculateRolloutHash(rollout *v1alpha1.Rollout) error { +func (r *RolloutReconciler) calculateRolloutHash(rollout *v1beta1.Rollout) error { canary := rollout.Spec.Strategy.Canary.DeepCopy() canary.FailureThreshold = nil canary.Steps = nil for i := range rollout.Spec.Strategy.Canary.Steps { step := rollout.Spec.Strategy.Canary.Steps[i].DeepCopy() - step.Pause = v1alpha1.RolloutPause{} + step.Pause = v1beta1.RolloutPause{} canary.Steps = append(canary.Steps, *step) } data := util.DumpJSON(canary) @@ -176,7 +176,7 @@ func (r *RolloutReconciler) calculateRolloutHash(rollout *v1alpha1.Rollout) erro return nil } -func (r *RolloutReconciler) updateRolloutStatusInternal(rollout *v1alpha1.Rollout, newStatus v1alpha1.RolloutStatus) error { +func (r *RolloutReconciler) updateRolloutStatusInternal(rollout *v1beta1.Rollout, newStatus v1beta1.RolloutStatus) error { if reflect.DeepEqual(rollout.Status, newStatus) { return nil } @@ -197,9 +197,9 @@ func (r *RolloutReconciler) updateRolloutStatusInternal(rollout *v1alpha1.Rollou return nil } -func (r *RolloutReconciler) reconcileRolloutTerminating(rollout *v1alpha1.Rollout, newStatus *v1alpha1.RolloutStatus) (*time.Time, error) { - cond := util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionTerminating) - if cond.Reason == v1alpha1.TerminatingReasonCompleted { +func (r *RolloutReconciler) reconcileRolloutTerminating(rollout *v1beta1.Rollout, newStatus *v1beta1.RolloutStatus) (*time.Time, error) { + cond := util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionTerminating) + if cond.Reason == v1beta1.TerminatingReasonCompleted { return nil, nil } workload, err := r.finder.GetWorkloadForRef(rollout) @@ -212,8 +212,8 @@ func (r *RolloutReconciler) reconcileRolloutTerminating(rollout *v1alpha1.Rollou if err != nil { return nil, err } else if done { - klog.Infof("rollout(%s/%s) is terminating, and state from(%s) -> to(%s)", rollout.Namespace, rollout.Name, cond.Reason, v1alpha1.TerminatingReasonCompleted) - cond.Reason = v1alpha1.TerminatingReasonCompleted + klog.Infof("rollout(%s/%s) is terminating, and state from(%s) -> to(%s)", rollout.Namespace, rollout.Name, cond.Reason, v1beta1.TerminatingReasonCompleted) + cond.Reason = v1beta1.TerminatingReasonCompleted cond.Status = corev1.ConditionFalse util.SetRolloutCondition(newStatus, *cond) } else { @@ -225,7 +225,7 @@ func (r *RolloutReconciler) reconcileRolloutTerminating(rollout *v1alpha1.Rollou return c.RecheckTime, nil } -func (r *RolloutReconciler) reconcileRolloutDisabling(rollout *v1alpha1.Rollout, newStatus *v1alpha1.RolloutStatus) (*time.Time, error) { +func (r *RolloutReconciler) reconcileRolloutDisabling(rollout *v1beta1.Rollout, newStatus *v1beta1.RolloutStatus) (*time.Time, error) { workload, err := r.finder.GetWorkloadForRef(rollout) if err != nil { klog.Errorf("rollout(%s/%s) get workload failed: %s", rollout.Namespace, rollout.Name, err.Error()) @@ -237,7 +237,7 @@ func (r *RolloutReconciler) reconcileRolloutDisabling(rollout *v1alpha1.Rollout, return nil, err } else if done { klog.Infof("rollout(%s/%s) is disabled", rollout.Namespace, rollout.Name) - newStatus.Phase = v1alpha1.RolloutPhaseDisabled + newStatus.Phase = v1beta1.RolloutPhaseDisabled newStatus.Message = "Rollout is disabled" } else { // Incomplete, recheck @@ -248,7 +248,7 @@ func (r *RolloutReconciler) reconcileRolloutDisabling(rollout *v1alpha1.Rollout, return c.RecheckTime, nil } -func (r *RolloutReconciler) patchWorkloadRolloutWebhookLabel(rollout *v1alpha1.Rollout) error { +func (r *RolloutReconciler) patchWorkloadRolloutWebhookLabel(rollout *v1beta1.Rollout) error { // get ref workload workload, err := r.finder.GetWorkloadForRef(rollout) if err != nil { @@ -285,11 +285,11 @@ func (r *RolloutReconciler) patchWorkloadRolloutWebhookLabel(rollout *v1alpha1.R } // handle adding and handle finalizer logic, it turns if we should continue to reconcile -func (r *RolloutReconciler) handleFinalizer(rollout *v1alpha1.Rollout) error { +func (r *RolloutReconciler) handleFinalizer(rollout *v1beta1.Rollout) error { // delete rollout crd, remove finalizer if !rollout.DeletionTimestamp.IsZero() { - cond := util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionTerminating) - if cond != nil && cond.Reason == v1alpha1.TerminatingReasonCompleted { + cond := util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionTerminating) + if cond != nil && cond.Reason == v1beta1.TerminatingReasonCompleted { // Completed if controllerutil.ContainsFinalizer(rollout, util.KruiseRolloutFinalizer) { err := util.UpdateFinalizer(r.Client, rollout, util.RemoveFinalizerOpType, util.KruiseRolloutFinalizer) @@ -318,7 +318,7 @@ func (r *RolloutReconciler) handleFinalizer(rollout *v1alpha1.Rollout) error { func getRolloutID(workload *util.Workload) string { if workload != nil { - return workload.Labels[v1alpha1.RolloutIDLabel] + return workload.Labels[v1beta1.RolloutIDLabel] } return "" } diff --git a/pkg/controller/rollout/rollout_status_test.go b/pkg/controller/rollout/rollout_status_test.go index 62c75c10..9d7e9108 100755 --- a/pkg/controller/rollout/rollout_status_test.go +++ b/pkg/controller/rollout/rollout_status_test.go @@ -20,7 +20,7 @@ import ( "context" "testing" - "github.com/openkruise/rollouts/api/v1alpha1" + "github.com/openkruise/rollouts/api/v1beta1" "github.com/openkruise/rollouts/pkg/trafficrouting" "github.com/openkruise/rollouts/pkg/util" "k8s.io/apimachinery/pkg/util/intstr" @@ -32,12 +32,12 @@ import ( func TestCalculateRolloutHash(t *testing.T) { cases := []struct { name string - getRollout func() *v1alpha1.Rollout + getRollout func() *v1beta1.Rollout expectHash func() string }{ { name: "hash, test1", - getRollout: func() *v1alpha1.Rollout { + getRollout: func() *v1beta1.Rollout { obj := rolloutDemo.DeepCopy() return obj }, @@ -47,11 +47,11 @@ func TestCalculateRolloutHash(t *testing.T) { }, { name: "hash, test2", - getRollout: func() *v1alpha1.Rollout { + getRollout: func() *v1beta1.Rollout { obj := rolloutDemo.DeepCopy() obj.Spec.Strategy.Paused = true obj.Spec.Strategy.Canary.FailureThreshold = &intstr.IntOrString{Type: intstr.Int} - obj.Spec.Strategy.Canary.Steps[0].Pause = v1alpha1.RolloutPause{Duration: utilpointer.Int32(10)} + obj.Spec.Strategy.Canary.Steps[0].Pause = v1beta1.RolloutPause{Duration: utilpointer.Int32(10)} return obj }, expectHash: func() string { @@ -60,16 +60,16 @@ func TestCalculateRolloutHash(t *testing.T) { }, { name: "hash, test3", - getRollout: func() *v1alpha1.Rollout { + getRollout: func() *v1beta1.Rollout { obj := rolloutDemo.DeepCopy() - obj.Spec.Strategy.Canary.Steps = []v1alpha1.CanaryStep{ + obj.Spec.Strategy.Canary.Steps = []v1beta1.CanaryStep{ { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(50), }, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(100), }, }, @@ -109,41 +109,41 @@ func TestCalculateRolloutHash(t *testing.T) { func TestCalculateRolloutStatus(t *testing.T) { cases := []struct { name string - getRollout func() *v1alpha1.Rollout - expectPhase v1alpha1.RolloutPhase + getRollout func() *v1beta1.Rollout + expectPhase v1beta1.RolloutPhase }{ { name: "apply an enabled rollout", - getRollout: func() *v1alpha1.Rollout { + getRollout: func() *v1beta1.Rollout { obj := rolloutDemo.DeepCopy() obj.Name = "Rollout-demo1" - obj.Status = v1alpha1.RolloutStatus{} + obj.Status = v1beta1.RolloutStatus{} obj.Spec.Disabled = false return obj }, - expectPhase: v1alpha1.RolloutPhaseInitial, + expectPhase: v1beta1.RolloutPhaseInitial, }, { name: "disable an working rollout", - getRollout: func() *v1alpha1.Rollout { + getRollout: func() *v1beta1.Rollout { obj := rolloutDemo.DeepCopy() obj.Name = "Rollout-demo1" - obj.Status = v1alpha1.RolloutStatus{} + obj.Status = v1beta1.RolloutStatus{} obj.Spec.Disabled = true return obj }, - expectPhase: v1alpha1.RolloutPhaseDisabled, + expectPhase: v1beta1.RolloutPhaseDisabled, }, { name: "enable an disabled rollout", - getRollout: func() *v1alpha1.Rollout { + getRollout: func() *v1beta1.Rollout { obj := rolloutDemo.DeepCopy() obj.Name = "Rollout-demo2" - obj.Status = v1alpha1.RolloutStatus{} + obj.Status = v1beta1.RolloutStatus{} obj.Spec.Disabled = false return obj }, - expectPhase: v1alpha1.RolloutPhaseInitial, + expectPhase: v1beta1.RolloutPhaseInitial, }, } diff --git a/pkg/controller/rollouthistory/rollouthistory_controller.go b/pkg/controller/rollouthistory/rollouthistory_controller.go index a9601972..b0e2b356 100644 --- a/pkg/controller/rollouthistory/rollouthistory_controller.go +++ b/pkg/controller/rollouthistory/rollouthistory_controller.go @@ -24,7 +24,7 @@ import ( "fmt" "reflect" - rolloutv1alpha1 "github.com/openkruise/rollouts/api/v1alpha1" + rolloutv1beta1 "github.com/openkruise/rollouts/api/v1beta1" "github.com/openkruise/rollouts/pkg/feature" utilfeature "github.com/openkruise/rollouts/pkg/util/feature" @@ -79,11 +79,11 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error { return err } // Watch for changes to rollout - if err = c.Watch(&source.Kind{Type: &rolloutv1alpha1.Rollout{}}, &enqueueRequestForRollout{}); err != nil { + if err = c.Watch(&source.Kind{Type: &rolloutv1beta1.Rollout{}}, &enqueueRequestForRollout{}); err != nil { return err } // watch for changes to rolloutHistory - if err = c.Watch(&source.Kind{Type: &rolloutv1alpha1.RolloutHistory{}}, &enqueueRequestForRolloutHistory{}); err != nil { + if err = c.Watch(&source.Kind{Type: &rolloutv1beta1.RolloutHistory{}}, &enqueueRequestForRolloutHistory{}); err != nil { return err } return nil @@ -111,7 +111,7 @@ type RolloutHistoryReconciler struct { // - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.10.0/pkg/reconcile func (r *RolloutHistoryReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { // get rollout - rollout := &rolloutv1alpha1.Rollout{} + rollout := &rolloutv1beta1.Rollout{} err := r.Get(ctx, req.NamespacedName, rollout) if err != nil { return ctrl.Result{}, client.IgnoreNotFound(err) @@ -125,7 +125,7 @@ func (r *RolloutHistoryReconciler) Reconcile(ctx context.Context, req ctrl.Reque return ctrl.Result{}, nil } // get RolloutHistory which is not completed and related to the rollout (only one or zero) - var rolloutHistory *rolloutv1alpha1.RolloutHistory + var rolloutHistory *rolloutv1beta1.RolloutHistory if rolloutHistory, err = r.getRolloutHistoryForRollout(rollout); err != nil { klog.Errorf("get rollout(%s/%s) rolloutHistory(%s=%s) failed: %s", rollout.Namespace, rollout.Name, rolloutIDLabel, rollout.Status.CanaryStatus.ObservedRolloutID, err.Error()) return ctrl.Result{}, err @@ -133,7 +133,7 @@ func (r *RolloutHistoryReconciler) Reconcile(ctx context.Context, req ctrl.Reque // create a rolloutHistory when user does a new rollout if rolloutHistory == nil { // just create rolloutHistory for rollouts which are progressing, otherwise it's possible to create more than one rollouthistory when user does one rollout - if rollout.Status.Phase != rolloutv1alpha1.RolloutPhaseProgressing { + if rollout.Status.Phase != rolloutv1beta1.RolloutPhaseProgressing { return ctrl.Result{}, nil } if err = r.createRolloutHistoryForProgressingRollout(rollout); err != nil { @@ -147,7 +147,7 @@ func (r *RolloutHistoryReconciler) Reconcile(ctx context.Context, req ctrl.Reque klog.Infof("get rollout(%s/%s) rolloutHistory(%s) success", rollout.Namespace, rollout.Name, rolloutHistory.Name) // update RolloutHistory which is waiting for rollout completed - if rolloutHistory.Status.Phase != rolloutv1alpha1.PhaseCompleted { + if rolloutHistory.Status.Phase != rolloutv1beta1.PhaseCompleted { // update RolloutHistory when rollout .status.phase is equl to RolloutPhaseHealthy if err = r.updateRolloutHistoryWhenRolloutIsCompeleted(rollout, rolloutHistory); err != nil { klog.Errorf("update rollout(%s/%s) rolloutHistory(%s=%s) failed: %s", rollout.Namespace, rollout.Name, rolloutIDLabel, rollout.Status.CanaryStatus.ObservedRolloutID, err.Error()) @@ -161,7 +161,7 @@ func (r *RolloutHistoryReconciler) Reconcile(ctx context.Context, req ctrl.Reque } // getRolloutHistoryForRollout get rolloutHistory according to rolloutID and rolloutName for this new rollout. -func (r *RolloutHistoryReconciler) getRolloutHistoryForRollout(rollout *rolloutv1alpha1.Rollout) (*rolloutv1alpha1.RolloutHistory, error) { +func (r *RolloutHistoryReconciler) getRolloutHistoryForRollout(rollout *rolloutv1beta1.Rollout) (*rolloutv1beta1.RolloutHistory, error) { // get labelSelector including rolloutBathID, rolloutID lableSelectorString := fmt.Sprintf("%v=%v,%v=%v", rolloutIDLabel, rollout.Status.CanaryStatus.ObservedRolloutID, rolloutNameLabel, rollout.Name) labelSelector, err := labels.Parse(lableSelectorString) @@ -169,7 +169,7 @@ func (r *RolloutHistoryReconciler) getRolloutHistoryForRollout(rollout *rolloutv return nil, err } // get rollouthistories according to labels, in fact there is only one or zero rolloutHistory with the labelSelector - rollouthistories := &rolloutv1alpha1.RolloutHistoryList{} + rollouthistories := &rolloutv1beta1.RolloutHistoryList{} err = r.List(context.TODO(), rollouthistories, &client.ListOptions{LabelSelector: labelSelector}, client.InNamespace(rollout.Namespace)) if err != nil { return nil, err @@ -183,9 +183,9 @@ func (r *RolloutHistoryReconciler) getRolloutHistoryForRollout(rollout *rolloutv } // createRolloutHistoryForProgressingRollout create a new rolloutHistory, which indicates that user does a new rollout -func (r *RolloutHistoryReconciler) createRolloutHistoryForProgressingRollout(rollout *rolloutv1alpha1.Rollout) error { +func (r *RolloutHistoryReconciler) createRolloutHistoryForProgressingRollout(rollout *rolloutv1beta1.Rollout) error { // init the rolloutHistory - rolloutHistory := &rolloutv1alpha1.RolloutHistory{ + rolloutHistory := &rolloutv1beta1.RolloutHistory{ ObjectMeta: v1.ObjectMeta{ Name: rollout.Name + "-" + randAllString(6), Namespace: rollout.Namespace, @@ -200,15 +200,15 @@ func (r *RolloutHistoryReconciler) createRolloutHistoryForProgressingRollout(rol } // getRolloutHistorySpec get RolloutHistorySpec for rolloutHistory according to rollout -func (r *RolloutHistoryReconciler) getRolloutHistorySpec(rollout *rolloutv1alpha1.Rollout) (rolloutv1alpha1.RolloutHistorySpec, error) { - rolloutHistorySpec := rolloutv1alpha1.RolloutHistorySpec{} +func (r *RolloutHistoryReconciler) getRolloutHistorySpec(rollout *rolloutv1beta1.Rollout) (rolloutv1beta1.RolloutHistorySpec, error) { + rolloutHistorySpec := rolloutv1beta1.RolloutHistorySpec{} var err error // get rolloutInfo if rolloutHistorySpec.Rollout, err = r.getRolloutInfo(rollout); err != nil { return rolloutHistorySpec, err } // get workloadInfo - var workload *rolloutv1alpha1.WorkloadInfo + var workload *rolloutv1beta1.WorkloadInfo if workload, err = r.Finder.getWorkloadInfoForRef(rollout.Namespace, rollout.Spec.ObjectRef.WorkloadRef); err != nil { return rolloutHistorySpec, err } @@ -225,8 +225,8 @@ func (r *RolloutHistoryReconciler) getRolloutHistorySpec(rollout *rolloutv1alpha } // getRolloutInfo get RolloutInfo to for rolloutHistorySpec -func (r *RolloutHistoryReconciler) getRolloutInfo(rollout *rolloutv1alpha1.Rollout) (rolloutv1alpha1.RolloutInfo, error) { - rolloutInfo := rolloutv1alpha1.RolloutInfo{} +func (r *RolloutHistoryReconciler) getRolloutInfo(rollout *rolloutv1beta1.Rollout) (rolloutv1beta1.RolloutInfo, error) { + rolloutInfo := rolloutv1beta1.RolloutInfo{} var err error rolloutInfo.Name = rollout.Name rolloutInfo.RolloutID = rollout.Status.CanaryStatus.ObservedRolloutID @@ -237,10 +237,10 @@ func (r *RolloutHistoryReconciler) getRolloutInfo(rollout *rolloutv1alpha1.Rollo } // getServiceInfo get ServiceInfo for rolloutHistorySpec -func (r *RolloutHistoryReconciler) getServiceInfo(rollout *rolloutv1alpha1.Rollout) (rolloutv1alpha1.ServiceInfo, error) { +func (r *RolloutHistoryReconciler) getServiceInfo(rollout *rolloutv1beta1.Rollout) (rolloutv1beta1.ServiceInfo, error) { // get service service := &corev1.Service{} - serviceInfo := rolloutv1alpha1.ServiceInfo{} + serviceInfo := rolloutv1beta1.ServiceInfo{} err := r.Get(context.TODO(), types.NamespacedName{Namespace: rollout.Namespace, Name: rollout.Spec.Strategy.Canary.TrafficRoutings[0].Service}, service) if err != nil { return serviceInfo, errors.New("service not find") @@ -254,8 +254,8 @@ func (r *RolloutHistoryReconciler) getServiceInfo(rollout *rolloutv1alpha1.Rollo } // getTrafficRoutingInfo get TrafficRoutingInfo for rolloutHistorySpec -func (r *RolloutHistoryReconciler) getTrafficRoutingInfo(rollout *rolloutv1alpha1.Rollout) (rolloutv1alpha1.TrafficRoutingInfo, error) { - trafficRoutingInfo := rolloutv1alpha1.TrafficRoutingInfo{} +func (r *RolloutHistoryReconciler) getTrafficRoutingInfo(rollout *rolloutv1beta1.Rollout) (rolloutv1beta1.TrafficRoutingInfo, error) { + trafficRoutingInfo := rolloutv1beta1.TrafficRoutingInfo{} var err error // if gateway is configured, get it if rollout.Spec.Strategy.Canary.TrafficRoutings[0].Gateway != nil && @@ -277,7 +277,7 @@ func (r *RolloutHistoryReconciler) getTrafficRoutingInfo(rollout *rolloutv1alpha } // getGateWayInfo get HTTPRouteInfo for TrafficRoutingInfo -func (r *RolloutHistoryReconciler) getGateWayInfo(rollout *rolloutv1alpha1.Rollout) (*rolloutv1alpha1.HTTPRouteInfo, error) { +func (r *RolloutHistoryReconciler) getGateWayInfo(rollout *rolloutv1beta1.Rollout) (*rolloutv1beta1.HTTPRouteInfo, error) { // get HTTPRoute gatewayName := *rollout.Spec.Strategy.Canary.TrafficRoutings[0].Gateway.HTTPRouteName HTTPRoute := &v1alpha2.HTTPRoute{} @@ -286,7 +286,7 @@ func (r *RolloutHistoryReconciler) getGateWayInfo(rollout *rolloutv1alpha1.Rollo return nil, errors.New("initGateway error: HTTPRoute " + gatewayName + " not find") } // marshal HTTPRoute into HTTPRouteInfo for rolloutHistory - gatewayInfo := &rolloutv1alpha1.HTTPRouteInfo{} + gatewayInfo := &rolloutv1beta1.HTTPRouteInfo{} gatewayInfo.Name = HTTPRoute.Name if gatewayInfo.Data.Raw, err = json.Marshal(HTTPRoute.Spec); err != nil { return nil, err @@ -295,7 +295,7 @@ func (r *RolloutHistoryReconciler) getGateWayInfo(rollout *rolloutv1alpha1.Rollo } // getIngressInfo get IngressInfo for TrafficRoutingInfo -func (r *RolloutHistoryReconciler) getIngressInfo(rollout *rolloutv1alpha1.Rollout) (*rolloutv1alpha1.IngressInfo, error) { +func (r *RolloutHistoryReconciler) getIngressInfo(rollout *rolloutv1beta1.Rollout) (*rolloutv1beta1.IngressInfo, error) { // get Ingress ingressName := rollout.Spec.Strategy.Canary.TrafficRoutings[0].Ingress.Name ingress := &networkingv1.Ingress{} @@ -304,7 +304,7 @@ func (r *RolloutHistoryReconciler) getIngressInfo(rollout *rolloutv1alpha1.Rollo return nil, errors.New("initIngressInfo error: Ingress " + ingressName + " not find") } // marshal ingress into ingressInfo - ingressInfo := &rolloutv1alpha1.IngressInfo{} + ingressInfo := &rolloutv1beta1.IngressInfo{} ingressInfo.Name = ingressName if ingressInfo.Data.Raw, err = json.Marshal(ingress.Spec); err != nil { return nil, err @@ -313,9 +313,9 @@ func (r *RolloutHistoryReconciler) getIngressInfo(rollout *rolloutv1alpha1.Rollo } // updateRolloutHistoryWhenRolloutIsCompeleted record all pods released when rollout phase is healthy -func (r *RolloutHistoryReconciler) updateRolloutHistoryWhenRolloutIsCompeleted(rollout *rolloutv1alpha1.Rollout, rolloutHistory *rolloutv1alpha1.RolloutHistory) error { +func (r *RolloutHistoryReconciler) updateRolloutHistoryWhenRolloutIsCompeleted(rollout *rolloutv1beta1.Rollout, rolloutHistory *rolloutv1beta1.RolloutHistory) error { // do update until rollout.status.Phase is equl to RolloutPhaseHealthy - if rollout.Status.Phase != rolloutv1alpha1.RolloutPhaseHealthy { + if rollout.Status.Phase != rolloutv1beta1.RolloutPhaseHealthy { return nil } // when this rollot's phase has been healthy, rolloutHistory record steps information and rollout.spec @@ -335,7 +335,7 @@ func (r *RolloutHistoryReconciler) updateRolloutHistoryWhenRolloutIsCompeleted(r return nil } // make .status.phase PhaseCompleted - rolloutHistory.Status.Phase = rolloutv1alpha1.PhaseCompleted + rolloutHistory.Status.Phase = rolloutv1beta1.PhaseCompleted // record all pods information for rolloutHistory .status.canarySteps err = r.recordStatusCanarySteps(rollout, rolloutHistory) if err != nil { @@ -346,8 +346,8 @@ func (r *RolloutHistoryReconciler) updateRolloutHistoryWhenRolloutIsCompeleted(r } // recordStatusCanarySteps record all pods information which are canary released -func (r *RolloutHistoryReconciler) recordStatusCanarySteps(rollout *rolloutv1alpha1.Rollout, rolloutHistory *rolloutv1alpha1.RolloutHistory) error { - rolloutHistory.Status.CanarySteps = make([]rolloutv1alpha1.CanaryStepInfo, 0) +func (r *RolloutHistoryReconciler) recordStatusCanarySteps(rollout *rolloutv1beta1.Rollout, rolloutHistory *rolloutv1beta1.RolloutHistory) error { + rolloutHistory.Status.CanarySteps = make([]rolloutv1beta1.CanaryStepInfo, 0) for i := 0; i < len(rollout.Spec.Strategy.Canary.Steps); i++ { podList := &corev1.PodList{} var extraSelector labels.Selector @@ -358,7 +358,7 @@ func (r *RolloutHistoryReconciler) recordStatusCanarySteps(rollout *rolloutv1alp return err } // get extra labelSelector including rolloutBathID, rolloutID and workload selector - lableSelectorString := fmt.Sprintf("%v=%v,%v=%v,%v", rolloutv1alpha1.RolloutBatchIDLabel, len(rolloutHistory.Status.CanarySteps)+1, rolloutv1alpha1.RolloutIDLabel, rolloutHistory.Spec.Rollout.RolloutID, selector.String()) + lableSelectorString := fmt.Sprintf("%v=%v,%v=%v,%v", rolloutv1beta1.RolloutBatchIDLabel, len(rolloutHistory.Status.CanarySteps)+1, rolloutv1beta1.RolloutIDLabel, rolloutHistory.Spec.Rollout.RolloutID, selector.String()) extraSelector, err = labels.Parse(lableSelectorString) if err != nil { return err @@ -371,17 +371,17 @@ func (r *RolloutHistoryReconciler) recordStatusCanarySteps(rollout *rolloutv1alp // if num of pods is empty, append a empty CanaryStepInfo{} to canarySteps if len(podList.Items) == 0 { index := int32(len(rolloutHistory.Status.CanarySteps)) + 1 - rolloutHistory.Status.CanarySteps = append(rolloutHistory.Status.CanarySteps, rolloutv1alpha1.CanaryStepInfo{CanaryStepIndex: index}) + rolloutHistory.Status.CanarySteps = append(rolloutHistory.Status.CanarySteps, rolloutv1beta1.CanaryStepInfo{CanaryStepIndex: index}) continue } // get current step pods released - currentStepInfo := rolloutv1alpha1.CanaryStepInfo{} - var pods []rolloutv1alpha1.Pod + currentStepInfo := rolloutv1beta1.CanaryStepInfo{} + var pods []rolloutv1beta1.Pod // get pods name, ip, node and add them to .status.canarySteps for i := range podList.Items { pod := &podList.Items[i] if pod.DeletionTimestamp.IsZero() { - cur := rolloutv1alpha1.Pod{Name: pod.Name, IP: pod.Status.PodIP, NodeName: pod.Spec.NodeName} + cur := rolloutv1beta1.Pod{Name: pod.Name, IP: pod.Status.PodIP, NodeName: pod.Spec.NodeName} pods = append(pods, cur) } } diff --git a/pkg/controller/rollouthistory/rollouthistory_controller_test.go b/pkg/controller/rollouthistory/rollouthistory_controller_test.go index 52a73bd0..616fbaa6 100644 --- a/pkg/controller/rollouthistory/rollouthistory_controller_test.go +++ b/pkg/controller/rollouthistory/rollouthistory_controller_test.go @@ -36,21 +36,21 @@ import ( "github.com/openkruise/kruise-api/apps/pub" kruisev1alpha1 "github.com/openkruise/kruise-api/apps/v1alpha1" - rolloutv1alpha1 "github.com/openkruise/rollouts/api/v1alpha1" + rolloutv1beta1 "github.com/openkruise/rollouts/api/v1beta1" ) func init() { scheme = runtime.NewScheme() _ = clientgoscheme.AddToScheme(scheme) _ = kruisev1alpha1.AddToScheme(scheme) - _ = rolloutv1alpha1.AddToScheme(scheme) + _ = rolloutv1beta1.AddToScheme(scheme) _ = v1alpha2.AddToScheme(scheme) } var ( scheme *runtime.Scheme - rollouthistoryDemo = rolloutv1alpha1.RolloutHistory{ + rollouthistoryDemo = rolloutv1beta1.RolloutHistory{ TypeMeta: metav1.TypeMeta{ Kind: "RolloutHistory", APIVersion: "rollouts.kruise.io/v1alpha1", @@ -63,46 +63,46 @@ var ( rolloutNameLabel: "rollout-demo", }, }, - Spec: rolloutv1alpha1.RolloutHistorySpec{ - Rollout: rolloutv1alpha1.RolloutInfo{ + Spec: rolloutv1beta1.RolloutHistorySpec{ + Rollout: rolloutv1beta1.RolloutInfo{ RolloutID: "1", - NameAndSpecData: rolloutv1alpha1.NameAndSpecData{ + NameAndSpecData: rolloutv1beta1.NameAndSpecData{ Name: "rollout-demo", }, }, - Service: rolloutv1alpha1.ServiceInfo{ - NameAndSpecData: rolloutv1alpha1.NameAndSpecData{ + Service: rolloutv1beta1.ServiceInfo{ + NameAndSpecData: rolloutv1beta1.NameAndSpecData{ Name: "service-demo", }, }, - TrafficRouting: rolloutv1alpha1.TrafficRoutingInfo{ - Ingress: &rolloutv1alpha1.IngressInfo{ - NameAndSpecData: rolloutv1alpha1.NameAndSpecData{ + TrafficRouting: rolloutv1beta1.TrafficRoutingInfo{ + Ingress: &rolloutv1beta1.IngressInfo{ + NameAndSpecData: rolloutv1beta1.NameAndSpecData{ Name: "ingress-demo", }, }, - HTTPRoute: &rolloutv1alpha1.HTTPRouteInfo{ - NameAndSpecData: rolloutv1alpha1.NameAndSpecData{ + HTTPRoute: &rolloutv1beta1.HTTPRouteInfo{ + NameAndSpecData: rolloutv1beta1.NameAndSpecData{ Name: "HTTPRoute-demo", }, }, }, - Workload: rolloutv1alpha1.WorkloadInfo{ + Workload: rolloutv1beta1.WorkloadInfo{ TypeMeta: metav1.TypeMeta{ APIVersion: "apps.kruise.io/v1alpha1", Kind: "CloneSet", }, - NameAndSpecData: rolloutv1alpha1.NameAndSpecData{ + NameAndSpecData: rolloutv1beta1.NameAndSpecData{ Name: "workload-demo", }, }, }, - Status: rolloutv1alpha1.RolloutHistoryStatus{ + Status: rolloutv1beta1.RolloutHistoryStatus{ Phase: "", - CanarySteps: []rolloutv1alpha1.CanaryStepInfo{ + CanarySteps: []rolloutv1beta1.CanaryStepInfo{ { CanaryStepIndex: 1, - Pods: []rolloutv1alpha1.Pod{ + Pods: []rolloutv1beta1.Pod{ { Name: "pod-1", IP: "1.2.3.4", @@ -114,7 +114,7 @@ var ( }, } - rolloutDemo1 = rolloutv1alpha1.Rollout{ + rolloutDemo1 = rolloutv1beta1.Rollout{ TypeMeta: metav1.TypeMeta{ Kind: "Rollout", APIVersion: "rollouts.kruise.io/v1alpha1", @@ -124,49 +124,49 @@ var ( Namespace: "default", Labels: map[string]string{}, }, - Spec: rolloutv1alpha1.RolloutSpec{ - ObjectRef: rolloutv1alpha1.ObjectRef{ - WorkloadRef: &rolloutv1alpha1.WorkloadRef{ + Spec: rolloutv1beta1.RolloutSpec{ + ObjectRef: rolloutv1beta1.ObjectRef{ + WorkloadRef: &rolloutv1beta1.WorkloadRef{ APIVersion: "apps.kruise.io/v1alpha1", Kind: "CloneSet", Name: "workload-demo", }, }, DeprecatedRolloutID: "1", - Strategy: rolloutv1alpha1.RolloutStrategy{ - Canary: &rolloutv1alpha1.CanaryStrategy{ - Steps: []rolloutv1alpha1.CanaryStep{ + Strategy: rolloutv1beta1.RolloutStrategy{ + Canary: &rolloutv1beta1.CanaryStrategy{ + Steps: []rolloutv1beta1.CanaryStep{ { - TrafficRoutingStrategy: rolloutv1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: rolloutv1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(5), }, - Pause: rolloutv1alpha1.RolloutPause{ + Pause: rolloutv1beta1.RolloutPause{ Duration: utilpointer.Int32(0), }, }, { - TrafficRoutingStrategy: rolloutv1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: rolloutv1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(40), }, - Pause: rolloutv1alpha1.RolloutPause{}, + Pause: rolloutv1beta1.RolloutPause{}, }, { - TrafficRoutingStrategy: rolloutv1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: rolloutv1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(100), }, - Pause: rolloutv1alpha1.RolloutPause{ + Pause: rolloutv1beta1.RolloutPause{ Duration: utilpointer.Int32(0), }, }, }, - TrafficRoutings: []rolloutv1alpha1.TrafficRoutingRef{ + TrafficRoutings: []rolloutv1beta1.TrafficRoutingRef{ { Service: "service-demo", - Ingress: &rolloutv1alpha1.IngressTrafficRouting{ + Ingress: &rolloutv1beta1.IngressTrafficRouting{ ClassType: "nginx", Name: "ingress-demo", }, - Gateway: &rolloutv1alpha1.GatewayTrafficRouting{ + Gateway: &rolloutv1beta1.GatewayTrafficRouting{ HTTPRouteName: utilpointer.String("HTTPRoute-demo"), }, }, @@ -326,8 +326,8 @@ var ( Name: "pod-demo", Namespace: "default", Labels: map[string]string{ - rolloutv1alpha1.RolloutBatchIDLabel: "1", - rolloutv1alpha1.RolloutIDLabel: "1", + rolloutv1beta1.RolloutBatchIDLabel: "1", + rolloutv1beta1.RolloutIDLabel: "1", }, }, Spec: corev1.PodSpec{ @@ -345,9 +345,9 @@ func TestReconcile(t *testing.T) { getWorkload func() []*kruisev1alpha1.CloneSet getIngress func() []*networkingv1.Ingress getHTTPRoute func() []*v1alpha2.HTTPRoute - getRollout func() []*rolloutv1alpha1.Rollout - getRolloutHistory func() []*rolloutv1alpha1.RolloutHistory - expectRolloutHistory func() []*rolloutv1alpha1.RolloutHistory + getRollout func() []*rolloutv1beta1.Rollout + getRolloutHistory func() []*rolloutv1beta1.RolloutHistory + expectRolloutHistory func() []*rolloutv1beta1.RolloutHistory }{ { name: "test1, create a new rolloutHistory for rollout", @@ -377,25 +377,25 @@ func TestReconcile(t *testing.T) { httpRoutes := []*v1alpha2.HTTPRoute{} return httpRoutes }, - getRollout: func() []*rolloutv1alpha1.Rollout { + getRollout: func() []*rolloutv1beta1.Rollout { rollout := rolloutDemo1.DeepCopy() - rollout.Status = rolloutv1alpha1.RolloutStatus{ - CanaryStatus: &rolloutv1alpha1.CanaryStatus{ + rollout.Status = rolloutv1beta1.RolloutStatus{ + CanaryStatus: &rolloutv1beta1.CanaryStatus{ ObservedRolloutID: "1", }, - Phase: rolloutv1alpha1.RolloutPhaseProgressing, + Phase: rolloutv1beta1.RolloutPhaseProgressing, } - return []*rolloutv1alpha1.Rollout{rollout} + return []*rolloutv1beta1.Rollout{rollout} }, - getRolloutHistory: func() []*rolloutv1alpha1.RolloutHistory { - rollouthistories := []*rolloutv1alpha1.RolloutHistory{} + getRolloutHistory: func() []*rolloutv1beta1.RolloutHistory { + rollouthistories := []*rolloutv1beta1.RolloutHistory{} return rollouthistories }, - expectRolloutHistory: func() []*rolloutv1alpha1.RolloutHistory { + expectRolloutHistory: func() []*rolloutv1beta1.RolloutHistory { rollouthistory := rollouthistoryDemo.DeepCopy() - rollouthistory.Spec = rolloutv1alpha1.RolloutHistorySpec{} - rollouthistory.Status = rolloutv1alpha1.RolloutHistoryStatus{} - return []*rolloutv1alpha1.RolloutHistory{rollouthistory} + rollouthistory.Spec = rolloutv1beta1.RolloutHistorySpec{} + rollouthistory.Status = rolloutv1beta1.RolloutHistoryStatus{} + return []*rolloutv1beta1.RolloutHistory{rollouthistory} }, }, { @@ -414,8 +414,8 @@ func TestReconcile(t *testing.T) { PodIP: "1.2.3.1", } pod1.Labels = map[string]string{ - rolloutv1alpha1.RolloutBatchIDLabel: "1", - rolloutv1alpha1.RolloutIDLabel: "2", + rolloutv1beta1.RolloutBatchIDLabel: "1", + rolloutv1beta1.RolloutIDLabel: "2", "app": "echoserver", } @@ -426,8 +426,8 @@ func TestReconcile(t *testing.T) { PodIP: "1.2.3.2", } pod2.Labels = map[string]string{ - rolloutv1alpha1.RolloutBatchIDLabel: "2", - rolloutv1alpha1.RolloutIDLabel: "2", + rolloutv1beta1.RolloutBatchIDLabel: "2", + rolloutv1beta1.RolloutIDLabel: "2", "app": "echoserver", } @@ -438,8 +438,8 @@ func TestReconcile(t *testing.T) { PodIP: "1.2.3.3", } pod3.Labels = map[string]string{ - rolloutv1alpha1.RolloutBatchIDLabel: "3", - rolloutv1alpha1.RolloutIDLabel: "2", + rolloutv1beta1.RolloutBatchIDLabel: "3", + rolloutv1beta1.RolloutIDLabel: "2", "app": "echoserver", } @@ -450,8 +450,8 @@ func TestReconcile(t *testing.T) { PodIP: "1.2.3.4", } pod4.Labels = map[string]string{ - rolloutv1alpha1.RolloutBatchIDLabel: "3", - rolloutv1alpha1.RolloutIDLabel: "2", + rolloutv1beta1.RolloutBatchIDLabel: "3", + rolloutv1beta1.RolloutIDLabel: "2", "app": "echoserver", } @@ -462,8 +462,8 @@ func TestReconcile(t *testing.T) { PodIP: "1.2.3.5", } pod5.Labels = map[string]string{ - rolloutv1alpha1.RolloutBatchIDLabel: "3", - rolloutv1alpha1.RolloutIDLabel: "2", + rolloutv1beta1.RolloutBatchIDLabel: "3", + rolloutv1beta1.RolloutIDLabel: "2", "app": "echoserver", } @@ -485,69 +485,69 @@ func TestReconcile(t *testing.T) { httpRoutes := []*v1alpha2.HTTPRoute{httpRouteDemo.DeepCopy()} return httpRoutes }, - getRollout: func() []*rolloutv1alpha1.Rollout { + getRollout: func() []*rolloutv1beta1.Rollout { rollout := rolloutDemo1.DeepCopy() rollout.Spec.DeprecatedRolloutID = "2" - rollout.Status = rolloutv1alpha1.RolloutStatus{ - CanaryStatus: &rolloutv1alpha1.CanaryStatus{ + rollout.Status = rolloutv1beta1.RolloutStatus{ + CanaryStatus: &rolloutv1beta1.CanaryStatus{ ObservedRolloutID: "2", }, - Phase: rolloutv1alpha1.RolloutPhaseHealthy, + Phase: rolloutv1beta1.RolloutPhaseHealthy, } - return []*rolloutv1alpha1.Rollout{rollout} + return []*rolloutv1beta1.Rollout{rollout} }, - getRolloutHistory: func() []*rolloutv1alpha1.RolloutHistory { + getRolloutHistory: func() []*rolloutv1beta1.RolloutHistory { rollouthistory := rollouthistoryDemo.DeepCopy() rollouthistory.Labels = map[string]string{ rolloutIDLabel: "2", rolloutNameLabel: "rollout-demo", } - rollouthistory.Spec = rolloutv1alpha1.RolloutHistorySpec{} - rollouthistory.Status = rolloutv1alpha1.RolloutHistoryStatus{} - return []*rolloutv1alpha1.RolloutHistory{rollouthistory} + rollouthistory.Spec = rolloutv1beta1.RolloutHistorySpec{} + rollouthistory.Status = rolloutv1beta1.RolloutHistoryStatus{} + return []*rolloutv1beta1.RolloutHistory{rollouthistory} }, - expectRolloutHistory: func() []*rolloutv1alpha1.RolloutHistory { + expectRolloutHistory: func() []*rolloutv1beta1.RolloutHistory { rollouthistory := rollouthistoryDemo.DeepCopy() rollouthistory.Labels = map[string]string{ rolloutIDLabel: "2", rolloutNameLabel: "rollout-demo", } - rollouthistory.Spec = rolloutv1alpha1.RolloutHistorySpec{ - Rollout: rolloutv1alpha1.RolloutInfo{ + rollouthistory.Spec = rolloutv1beta1.RolloutHistorySpec{ + Rollout: rolloutv1beta1.RolloutInfo{ RolloutID: "2", - NameAndSpecData: rolloutv1alpha1.NameAndSpecData{ + NameAndSpecData: rolloutv1beta1.NameAndSpecData{ Name: "rollout-demo", }, }, - Workload: rolloutv1alpha1.WorkloadInfo{ - NameAndSpecData: rolloutv1alpha1.NameAndSpecData{ + Workload: rolloutv1beta1.WorkloadInfo{ + NameAndSpecData: rolloutv1beta1.NameAndSpecData{ Name: "workload-demo", }, }, - Service: rolloutv1alpha1.ServiceInfo{ - NameAndSpecData: rolloutv1alpha1.NameAndSpecData{ + Service: rolloutv1beta1.ServiceInfo{ + NameAndSpecData: rolloutv1beta1.NameAndSpecData{ Name: "service-demo", }, }, - TrafficRouting: rolloutv1alpha1.TrafficRoutingInfo{ - Ingress: &rolloutv1alpha1.IngressInfo{ - NameAndSpecData: rolloutv1alpha1.NameAndSpecData{ + TrafficRouting: rolloutv1beta1.TrafficRoutingInfo{ + Ingress: &rolloutv1beta1.IngressInfo{ + NameAndSpecData: rolloutv1beta1.NameAndSpecData{ Name: "ingress-demo", }, }, - HTTPRoute: &rolloutv1alpha1.HTTPRouteInfo{ - NameAndSpecData: rolloutv1alpha1.NameAndSpecData{ + HTTPRoute: &rolloutv1beta1.HTTPRouteInfo{ + NameAndSpecData: rolloutv1beta1.NameAndSpecData{ Name: "HTTPRoute-demo", }, }, }, } - rollouthistory.Status = rolloutv1alpha1.RolloutHistoryStatus{ - Phase: rolloutv1alpha1.PhaseCompleted, - CanarySteps: []rolloutv1alpha1.CanaryStepInfo{ + rollouthistory.Status = rolloutv1beta1.RolloutHistoryStatus{ + Phase: rolloutv1beta1.PhaseCompleted, + CanarySteps: []rolloutv1beta1.CanaryStepInfo{ { CanaryStepIndex: 1, - Pods: []rolloutv1alpha1.Pod{ + Pods: []rolloutv1beta1.Pod{ { Name: "pod1", IP: "1.2.3.1", @@ -557,7 +557,7 @@ func TestReconcile(t *testing.T) { }, { CanaryStepIndex: 2, - Pods: []rolloutv1alpha1.Pod{ + Pods: []rolloutv1beta1.Pod{ { Name: "pod2", IP: "1.2.3.2", @@ -567,7 +567,7 @@ func TestReconcile(t *testing.T) { }, { CanaryStepIndex: 3, - Pods: []rolloutv1alpha1.Pod{ + Pods: []rolloutv1beta1.Pod{ { Name: "pod3", IP: "1.2.3.3", @@ -587,7 +587,7 @@ func TestReconcile(t *testing.T) { }, }, } - return []*rolloutv1alpha1.RolloutHistory{rollouthistory} + return []*rolloutv1beta1.RolloutHistory{rollouthistory} }, }, { @@ -618,23 +618,23 @@ func TestReconcile(t *testing.T) { httpRoutes := []*v1alpha2.HTTPRoute{} return httpRoutes }, - getRollout: func() []*rolloutv1alpha1.Rollout { + getRollout: func() []*rolloutv1beta1.Rollout { rollout := rolloutDemo1.DeepCopy() rollout.Spec.DeprecatedRolloutID = "" - rollout.Status = rolloutv1alpha1.RolloutStatus{ - CanaryStatus: &rolloutv1alpha1.CanaryStatus{ + rollout.Status = rolloutv1beta1.RolloutStatus{ + CanaryStatus: &rolloutv1beta1.CanaryStatus{ ObservedRolloutID: "", }, - Phase: rolloutv1alpha1.RolloutPhaseProgressing, + Phase: rolloutv1beta1.RolloutPhaseProgressing, } - return []*rolloutv1alpha1.Rollout{rollout} + return []*rolloutv1beta1.Rollout{rollout} }, - getRolloutHistory: func() []*rolloutv1alpha1.RolloutHistory { - rollouthistories := []*rolloutv1alpha1.RolloutHistory{} + getRolloutHistory: func() []*rolloutv1beta1.RolloutHistory { + rollouthistories := []*rolloutv1beta1.RolloutHistory{} return rollouthistories }, - expectRolloutHistory: func() []*rolloutv1alpha1.RolloutHistory { - rollouthistories := []*rolloutv1alpha1.RolloutHistory{} + expectRolloutHistory: func() []*rolloutv1beta1.RolloutHistory { + rollouthistories := []*rolloutv1beta1.RolloutHistory{} return rollouthistories }, }, @@ -666,59 +666,59 @@ func TestReconcile(t *testing.T) { httpRoutes := []*v1alpha2.HTTPRoute{} return httpRoutes }, - getRollout: func() []*rolloutv1alpha1.Rollout { + getRollout: func() []*rolloutv1beta1.Rollout { rollout := rolloutDemo1.DeepCopy() rollout.Spec.DeprecatedRolloutID = "4" - rollout.Status = rolloutv1alpha1.RolloutStatus{ - CanaryStatus: &rolloutv1alpha1.CanaryStatus{ + rollout.Status = rolloutv1beta1.RolloutStatus{ + CanaryStatus: &rolloutv1beta1.CanaryStatus{ ObservedRolloutID: "4", }, - Phase: rolloutv1alpha1.RolloutPhaseProgressing, + Phase: rolloutv1beta1.RolloutPhaseProgressing, } - return []*rolloutv1alpha1.Rollout{rollout} + return []*rolloutv1beta1.Rollout{rollout} }, - getRolloutHistory: func() []*rolloutv1alpha1.RolloutHistory { + getRolloutHistory: func() []*rolloutv1beta1.RolloutHistory { rollouthistory := rollouthistoryDemo.DeepCopy() rollouthistory.Labels = map[string]string{ rolloutIDLabel: "4", rolloutNameLabel: "rollout-demo", } - rollouthistory.Spec = rolloutv1alpha1.RolloutHistorySpec{ - Rollout: rolloutv1alpha1.RolloutInfo{ + rollouthistory.Spec = rolloutv1beta1.RolloutHistorySpec{ + Rollout: rolloutv1beta1.RolloutInfo{ RolloutID: "4", - NameAndSpecData: rolloutv1alpha1.NameAndSpecData{ + NameAndSpecData: rolloutv1beta1.NameAndSpecData{ Name: "rollout-demo", }, }, - Workload: rolloutv1alpha1.WorkloadInfo{ - NameAndSpecData: rolloutv1alpha1.NameAndSpecData{ + Workload: rolloutv1beta1.WorkloadInfo{ + NameAndSpecData: rolloutv1beta1.NameAndSpecData{ Name: "workload-demo", }, }, - Service: rolloutv1alpha1.ServiceInfo{ - NameAndSpecData: rolloutv1alpha1.NameAndSpecData{ + Service: rolloutv1beta1.ServiceInfo{ + NameAndSpecData: rolloutv1beta1.NameAndSpecData{ Name: "service-demo", }, }, - TrafficRouting: rolloutv1alpha1.TrafficRoutingInfo{ - Ingress: &rolloutv1alpha1.IngressInfo{ - NameAndSpecData: rolloutv1alpha1.NameAndSpecData{ + TrafficRouting: rolloutv1beta1.TrafficRoutingInfo{ + Ingress: &rolloutv1beta1.IngressInfo{ + NameAndSpecData: rolloutv1beta1.NameAndSpecData{ Name: "ingress-demo", }, }, - HTTPRoute: &rolloutv1alpha1.HTTPRouteInfo{ - NameAndSpecData: rolloutv1alpha1.NameAndSpecData{ + HTTPRoute: &rolloutv1beta1.HTTPRouteInfo{ + NameAndSpecData: rolloutv1beta1.NameAndSpecData{ Name: "HTTPRoute-demo", }, }, }, } - rollouthistory.Status = rolloutv1alpha1.RolloutHistoryStatus{ - Phase: rolloutv1alpha1.PhaseCompleted, - CanarySteps: []rolloutv1alpha1.CanaryStepInfo{ + rollouthistory.Status = rolloutv1beta1.RolloutHistoryStatus{ + Phase: rolloutv1beta1.PhaseCompleted, + CanarySteps: []rolloutv1beta1.CanaryStepInfo{ { CanaryStepIndex: 1, - Pods: []rolloutv1alpha1.Pod{ + Pods: []rolloutv1beta1.Pod{ { Name: "pod1", IP: "1.2.3.1", @@ -728,7 +728,7 @@ func TestReconcile(t *testing.T) { }, { CanaryStepIndex: 2, - Pods: []rolloutv1alpha1.Pod{ + Pods: []rolloutv1beta1.Pod{ { Name: "pod2", IP: "1.2.3.2", @@ -738,7 +738,7 @@ func TestReconcile(t *testing.T) { }, { CanaryStepIndex: 3, - Pods: []rolloutv1alpha1.Pod{ + Pods: []rolloutv1beta1.Pod{ { Name: "pod3", IP: "1.2.3.3", @@ -758,50 +758,50 @@ func TestReconcile(t *testing.T) { }, }, } - return []*rolloutv1alpha1.RolloutHistory{rollouthistory} + return []*rolloutv1beta1.RolloutHistory{rollouthistory} }, - expectRolloutHistory: func() []*rolloutv1alpha1.RolloutHistory { + expectRolloutHistory: func() []*rolloutv1beta1.RolloutHistory { rollouthistory := rollouthistoryDemo.DeepCopy() rollouthistory.Labels = map[string]string{ rolloutIDLabel: "4", rolloutNameLabel: "rollout-demo", } - rollouthistory.Spec = rolloutv1alpha1.RolloutHistorySpec{ - Rollout: rolloutv1alpha1.RolloutInfo{ + rollouthistory.Spec = rolloutv1beta1.RolloutHistorySpec{ + Rollout: rolloutv1beta1.RolloutInfo{ RolloutID: "4", - NameAndSpecData: rolloutv1alpha1.NameAndSpecData{ + NameAndSpecData: rolloutv1beta1.NameAndSpecData{ Name: "rollout-demo", }, }, - Workload: rolloutv1alpha1.WorkloadInfo{ - NameAndSpecData: rolloutv1alpha1.NameAndSpecData{ + Workload: rolloutv1beta1.WorkloadInfo{ + NameAndSpecData: rolloutv1beta1.NameAndSpecData{ Name: "workload-demo", }, }, - Service: rolloutv1alpha1.ServiceInfo{ - NameAndSpecData: rolloutv1alpha1.NameAndSpecData{ + Service: rolloutv1beta1.ServiceInfo{ + NameAndSpecData: rolloutv1beta1.NameAndSpecData{ Name: "service-demo", }, }, - TrafficRouting: rolloutv1alpha1.TrafficRoutingInfo{ - Ingress: &rolloutv1alpha1.IngressInfo{ - NameAndSpecData: rolloutv1alpha1.NameAndSpecData{ + TrafficRouting: rolloutv1beta1.TrafficRoutingInfo{ + Ingress: &rolloutv1beta1.IngressInfo{ + NameAndSpecData: rolloutv1beta1.NameAndSpecData{ Name: "ingress-demo", }, }, - HTTPRoute: &rolloutv1alpha1.HTTPRouteInfo{ - NameAndSpecData: rolloutv1alpha1.NameAndSpecData{ + HTTPRoute: &rolloutv1beta1.HTTPRouteInfo{ + NameAndSpecData: rolloutv1beta1.NameAndSpecData{ Name: "HTTPRoute-demo", }, }, }, } - rollouthistory.Status = rolloutv1alpha1.RolloutHistoryStatus{ - Phase: rolloutv1alpha1.PhaseCompleted, - CanarySteps: []rolloutv1alpha1.CanaryStepInfo{ + rollouthistory.Status = rolloutv1beta1.RolloutHistoryStatus{ + Phase: rolloutv1beta1.PhaseCompleted, + CanarySteps: []rolloutv1beta1.CanaryStepInfo{ { CanaryStepIndex: 1, - Pods: []rolloutv1alpha1.Pod{ + Pods: []rolloutv1beta1.Pod{ { Name: "pod1", IP: "1.2.3.1", @@ -811,7 +811,7 @@ func TestReconcile(t *testing.T) { }, { CanaryStepIndex: 2, - Pods: []rolloutv1alpha1.Pod{ + Pods: []rolloutv1beta1.Pod{ { Name: "pod2", IP: "1.2.3.2", @@ -821,7 +821,7 @@ func TestReconcile(t *testing.T) { }, { CanaryStepIndex: 3, - Pods: []rolloutv1alpha1.Pod{ + Pods: []rolloutv1beta1.Pod{ { Name: "pod3", IP: "1.2.3.3", @@ -841,7 +841,7 @@ func TestReconcile(t *testing.T) { }, }, } - return []*rolloutv1alpha1.RolloutHistory{rollouthistory} + return []*rolloutv1beta1.RolloutHistory{rollouthistory} }, }, { @@ -872,23 +872,23 @@ func TestReconcile(t *testing.T) { httpRoutes := []*v1alpha2.HTTPRoute{} return httpRoutes }, - getRollout: func() []*rolloutv1alpha1.Rollout { + getRollout: func() []*rolloutv1beta1.Rollout { rollout := rolloutDemo1.DeepCopy() rollout.Spec.DeprecatedRolloutID = "5" - rollout.Status = rolloutv1alpha1.RolloutStatus{ - CanaryStatus: &rolloutv1alpha1.CanaryStatus{ + rollout.Status = rolloutv1beta1.RolloutStatus{ + CanaryStatus: &rolloutv1beta1.CanaryStatus{ ObservedRolloutID: "5", }, - Phase: rolloutv1alpha1.RolloutPhaseHealthy, + Phase: rolloutv1beta1.RolloutPhaseHealthy, } - return []*rolloutv1alpha1.Rollout{rollout} + return []*rolloutv1beta1.Rollout{rollout} }, - getRolloutHistory: func() []*rolloutv1alpha1.RolloutHistory { - rollouthistories := []*rolloutv1alpha1.RolloutHistory{} + getRolloutHistory: func() []*rolloutv1beta1.RolloutHistory { + rollouthistories := []*rolloutv1beta1.RolloutHistory{} return rollouthistories }, - expectRolloutHistory: func() []*rolloutv1alpha1.RolloutHistory { - rollouthistories := []*rolloutv1alpha1.RolloutHistory{} + expectRolloutHistory: func() []*rolloutv1beta1.RolloutHistory { + rollouthistories := []*rolloutv1beta1.RolloutHistory{} return rollouthistories }, }, @@ -969,8 +969,8 @@ func TestReconcile(t *testing.T) { } } -func checkRolloutHistoryNum(c client.WithWatch, t *testing.T, expect []*rolloutv1alpha1.RolloutHistory) bool { - rollouthistories := &rolloutv1alpha1.RolloutHistoryList{} +func checkRolloutHistoryNum(c client.WithWatch, t *testing.T, expect []*rolloutv1beta1.RolloutHistory) bool { + rollouthistories := &rolloutv1beta1.RolloutHistoryList{} err := c.List(context.TODO(), rollouthistories, &client.ListOptions{}, client.InNamespace("default")) if err != nil { t.Fatalf("get rollouthistories failed: %s", err.Error()) @@ -981,10 +981,10 @@ func checkRolloutHistoryNum(c client.WithWatch, t *testing.T, expect []*rolloutv return true } -func checkRolloutHistoryInfoEqual(c client.WithWatch, t *testing.T, expect []*rolloutv1alpha1.RolloutHistory) bool { +func checkRolloutHistoryInfoEqual(c client.WithWatch, t *testing.T, expect []*rolloutv1beta1.RolloutHistory) bool { for i := range expect { obj := expect[i] - rollouthistories := &rolloutv1alpha1.RolloutHistoryList{} + rollouthistories := &rolloutv1beta1.RolloutHistoryList{} err := c.List(context.TODO(), rollouthistories, &client.ListOptions{}, client.InNamespace(obj.Namespace)) if err != nil { t.Fatalf("get rollouthistories failed: %s", err.Error()) @@ -1015,7 +1015,7 @@ func checkRolloutHistoryInfoEqual(c client.WithWatch, t *testing.T, expect []*ro return true } -func checkRolloutHistorySpec(spec1 *rolloutv1alpha1.RolloutHistorySpec, spec2 *rolloutv1alpha1.RolloutHistorySpec) bool { +func checkRolloutHistorySpec(spec1 *rolloutv1beta1.RolloutHistorySpec, spec2 *rolloutv1beta1.RolloutHistorySpec) bool { // spec1 and spec2 may be empty when rollouthistory is not completed if reflect.DeepEqual(spec1, spec2) { return true @@ -1033,7 +1033,7 @@ func checkRolloutHistorySpec(spec1 *rolloutv1alpha1.RolloutHistorySpec, spec2 *r return true } -func checkRolloutHistoryStatus(status1 *rolloutv1alpha1.RolloutHistoryStatus, status2 *rolloutv1alpha1.RolloutHistoryStatus) bool { +func checkRolloutHistoryStatus(status1 *rolloutv1beta1.RolloutHistoryStatus, status2 *rolloutv1beta1.RolloutHistoryStatus) bool { // in the first reconcile, there is only spec updated // status1 and status2 may be empty when rollouthistory is not completed if reflect.DeepEqual(status1, status2) { diff --git a/pkg/controller/rollouthistory/rollouthistory_event_handler.go b/pkg/controller/rollouthistory/rollouthistory_event_handler.go index b8e85496..d660532d 100644 --- a/pkg/controller/rollouthistory/rollouthistory_event_handler.go +++ b/pkg/controller/rollouthistory/rollouthistory_event_handler.go @@ -17,7 +17,7 @@ limitations under the License. package rollouthistory import ( - rolloutv1alpha1 "github.com/openkruise/rollouts/api/v1alpha1" + rolloutv1beta1 "github.com/openkruise/rollouts/api/v1beta1" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/util/workqueue" "sigs.k8s.io/controller-runtime/pkg/client" @@ -47,8 +47,8 @@ func (w *enqueueRequestForRolloutHistory) Update(evt event.UpdateEvent, q workqu func (w *enqueueRequestForRolloutHistory) handleEvent(q workqueue.RateLimitingInterface, obj client.Object) { // In fact, rolloutHistory which is created by controller must have rolloutNameLabel and rolloutIDLabe - rolloutName, ok1 := obj.(*rolloutv1alpha1.RolloutHistory).Labels[rolloutNameLabel] - _, ok2 := obj.(*rolloutv1alpha1.RolloutHistory).Labels[rolloutIDLabel] + rolloutName, ok1 := obj.(*rolloutv1beta1.RolloutHistory).Labels[rolloutNameLabel] + _, ok2 := obj.(*rolloutv1beta1.RolloutHistory).Labels[rolloutIDLabel] if !ok1 || !ok2 { return } @@ -78,7 +78,7 @@ func (w *enqueueRequestForRollout) Update(evt event.UpdateEvent, q workqueue.Rat func (w *enqueueRequestForRollout) handleEvent(q workqueue.RateLimitingInterface, obj client.Object) { // RolloutID shouldn't be empty - rollout := obj.(*rolloutv1alpha1.Rollout) + rollout := obj.(*rolloutv1beta1.Rollout) if rollout.Status.CanaryStatus == nil || rollout.Status.CanaryStatus.ObservedRolloutID == "" { return } diff --git a/pkg/controller/rollouthistory/util.go b/pkg/controller/rollouthistory/util.go index bc118495..ed71db44 100644 --- a/pkg/controller/rollouthistory/util.go +++ b/pkg/controller/rollouthistory/util.go @@ -25,7 +25,7 @@ import ( appsv1alpha1 "github.com/openkruise/kruise-api/apps/v1alpha1" appsv1beta1 "github.com/openkruise/kruise-api/apps/v1beta1" - rolloutv1alpha1 "github.com/openkruise/rollouts/api/v1alpha1" + rolloutv1beta1 "github.com/openkruise/rollouts/api/v1beta1" "github.com/openkruise/rollouts/pkg/util" apps "k8s.io/api/apps/v1" "k8s.io/apimachinery/pkg/api/errors" @@ -46,9 +46,9 @@ const ( ) // controllerFinderFunc2 is a function type that maps to a rolloutHistory's WorkloadInfo -type controllerFinderFunc2 func(namespace string, ref *rolloutv1alpha1.WorkloadRef) (*rolloutv1alpha1.WorkloadInfo, error) +type controllerFinderFunc2 func(namespace string, ref *rolloutv1beta1.WorkloadRef) (*rolloutv1beta1.WorkloadInfo, error) -type controllerFinderFunc2LabelSelector func(namespace string, ref *rolloutv1alpha1.WorkloadRef) (*v1.LabelSelector, error) +type controllerFinderFunc2LabelSelector func(namespace string, ref *rolloutv1beta1.WorkloadRef) (*v1.LabelSelector, error) type controllerFinder2 struct { client.Client } @@ -59,7 +59,7 @@ func newControllerFinder2(c client.Client) *controllerFinder2 { } } -func (r *controllerFinder2) getWorkloadInfoForRef(namespace string, ref *rolloutv1alpha1.WorkloadRef) (*rolloutv1alpha1.WorkloadInfo, error) { +func (r *controllerFinder2) getWorkloadInfoForRef(namespace string, ref *rolloutv1beta1.WorkloadRef) (*rolloutv1beta1.WorkloadInfo, error) { for _, finder := range r.finders2() { workloadInfo, err := finder(namespace, ref) if workloadInfo != nil || err != nil { @@ -69,7 +69,7 @@ func (r *controllerFinder2) getWorkloadInfoForRef(namespace string, ref *rollout return nil, nil } -func (r *controllerFinder2) getLabelSelectorForRef(namespace string, ref *rolloutv1alpha1.WorkloadRef) (*v1.LabelSelector, error) { +func (r *controllerFinder2) getLabelSelectorForRef(namespace string, ref *rolloutv1beta1.WorkloadRef) (*v1.LabelSelector, error) { for _, finder := range r.finders2LabelSelector() { labelSelector, err := finder(namespace, ref) if labelSelector != nil || err != nil { @@ -90,7 +90,7 @@ func (r *controllerFinder2) finders2() []controllerFinderFunc2 { } // getWorkloadInfoWithAdvancedStatefulSet returns WorkloadInfo with kruise statefulset referenced by the provided controllerRef -func (r *controllerFinder2) getWorkloadInfoWithAdvancedStatefulSet(namespace string, ref *rolloutv1alpha1.WorkloadRef) (*rolloutv1alpha1.WorkloadInfo, error) { +func (r *controllerFinder2) getWorkloadInfoWithAdvancedStatefulSet(namespace string, ref *rolloutv1beta1.WorkloadRef) (*rolloutv1beta1.WorkloadInfo, error) { // This error is irreversible, so there is no need to return error ok, _ := verifyGroupKind(ref, util.ControllerKruiseKindSts.Kind, []string{util.ControllerKruiseKindSts.Group}) if !ok { @@ -108,7 +108,7 @@ func (r *controllerFinder2) getWorkloadInfoWithAdvancedStatefulSet(namespace str } // assign value - workloadInfo := &rolloutv1alpha1.WorkloadInfo{} + workloadInfo := &rolloutv1beta1.WorkloadInfo{} workloadInfo.APIVersion = workload.APIVersion workloadInfo.Kind = workload.Kind workloadInfo.Name = workload.Name @@ -120,7 +120,7 @@ func (r *controllerFinder2) getWorkloadInfoWithAdvancedStatefulSet(namespace str } // getLabelSelectorWithAdvancedStatefulSet returns selector with kruise statefulset referenced by the provided controllerRef -func (r *controllerFinder2) getLabelSelectorWithAdvancedStatefulSet(namespace string, ref *rolloutv1alpha1.WorkloadRef) (*v1.LabelSelector, error) { +func (r *controllerFinder2) getLabelSelectorWithAdvancedStatefulSet(namespace string, ref *rolloutv1beta1.WorkloadRef) (*v1.LabelSelector, error) { // This error is irreversible, so there is no need to return error ok, _ := verifyGroupKind(ref, util.ControllerKruiseKindSts.Kind, []string{util.ControllerKruiseKindSts.Group}) if !ok { @@ -144,7 +144,7 @@ func (r *controllerFinder2) getLabelSelectorWithAdvancedStatefulSet(namespace st } // getWorkloadInfoWithCloneSet returns WorkloadInfo with kruise cloneset referenced by the provided controllerRef -func (r *controllerFinder2) getWorkloadInfoWithCloneSet(namespace string, ref *rolloutv1alpha1.WorkloadRef) (*rolloutv1alpha1.WorkloadInfo, error) { +func (r *controllerFinder2) getWorkloadInfoWithCloneSet(namespace string, ref *rolloutv1beta1.WorkloadRef) (*rolloutv1beta1.WorkloadInfo, error) { // This error is irreversible, so there is no need to return error ok, _ := verifyGroupKind(ref, util.ControllerKruiseKindCS.Kind, []string{util.ControllerKruiseKindCS.Group}) if !ok { @@ -162,7 +162,7 @@ func (r *controllerFinder2) getWorkloadInfoWithCloneSet(namespace string, ref *r } // assign value - workloadInfo := &rolloutv1alpha1.WorkloadInfo{} + workloadInfo := &rolloutv1beta1.WorkloadInfo{} workloadInfo.APIVersion = workload.APIVersion workloadInfo.Kind = workload.Kind workloadInfo.Name = workload.Name @@ -174,7 +174,7 @@ func (r *controllerFinder2) getWorkloadInfoWithCloneSet(namespace string, ref *r } // getLabelSelectorWithCloneSet returns selector with kruise cloneset referenced by the provided controllerRef -func (r *controllerFinder2) getLabelSelectorWithCloneSet(namespace string, ref *rolloutv1alpha1.WorkloadRef) (*v1.LabelSelector, error) { +func (r *controllerFinder2) getLabelSelectorWithCloneSet(namespace string, ref *rolloutv1beta1.WorkloadRef) (*v1.LabelSelector, error) { // This error is irreversible, so there is no need to return error ok, _ := verifyGroupKind(ref, util.ControllerKruiseKindCS.Kind, []string{util.ControllerKruiseKindCS.Group}) if !ok { @@ -198,7 +198,7 @@ func (r *controllerFinder2) getLabelSelectorWithCloneSet(namespace string, ref * } // getWorkloadInfoWithDeployment returns WorkloadInfo with k8s native deployment referenced by the provided controllerRef -func (r *controllerFinder2) getWorkloadInfoWithDeployment(namespace string, ref *rolloutv1alpha1.WorkloadRef) (*rolloutv1alpha1.WorkloadInfo, error) { +func (r *controllerFinder2) getWorkloadInfoWithDeployment(namespace string, ref *rolloutv1beta1.WorkloadRef) (*rolloutv1beta1.WorkloadInfo, error) { // This error is irreversible, so there is no need to return error ok, _ := verifyGroupKind(ref, util.ControllerKindDep.Kind, []string{util.ControllerKindDep.Group}) if !ok { @@ -216,7 +216,7 @@ func (r *controllerFinder2) getWorkloadInfoWithDeployment(namespace string, ref } // assign value - workloadInfo := &rolloutv1alpha1.WorkloadInfo{} + workloadInfo := &rolloutv1beta1.WorkloadInfo{} workloadInfo.APIVersion = workload.APIVersion workloadInfo.Kind = workload.Kind workloadInfo.Name = workload.Name @@ -228,7 +228,7 @@ func (r *controllerFinder2) getWorkloadInfoWithDeployment(namespace string, ref } // getLabelSelectorWithDeployment returns selector with deployment referenced by the provided controllerRef -func (r *controllerFinder2) getLabelSelectorWithDeployment(namespace string, ref *rolloutv1alpha1.WorkloadRef) (*v1.LabelSelector, error) { +func (r *controllerFinder2) getLabelSelectorWithDeployment(namespace string, ref *rolloutv1beta1.WorkloadRef) (*v1.LabelSelector, error) { // This error is irreversible, so there is no need to return error ok, _ := verifyGroupKind(ref, util.ControllerKindDep.Kind, []string{util.ControllerKindDep.Group}) if !ok { @@ -252,7 +252,7 @@ func (r *controllerFinder2) getLabelSelectorWithDeployment(namespace string, ref } // getWorkloadInfoWithNativeStatefulSet returns WorkloadInfo with k8s native statefulset referenced by the provided controllerRef -func (r *controllerFinder2) getWorkloadInfoWithNativeStatefulSet(namespace string, ref *rolloutv1alpha1.WorkloadRef) (*rolloutv1alpha1.WorkloadInfo, error) { +func (r *controllerFinder2) getWorkloadInfoWithNativeStatefulSet(namespace string, ref *rolloutv1beta1.WorkloadRef) (*rolloutv1beta1.WorkloadInfo, error) { // This error is irreversible, so there is no need to return error ok, _ := verifyGroupKind(ref, util.ControllerKindSts.Kind, []string{util.ControllerKindSts.Group}) if !ok { @@ -270,7 +270,7 @@ func (r *controllerFinder2) getWorkloadInfoWithNativeStatefulSet(namespace strin } // assign value - workloadInfo := &rolloutv1alpha1.WorkloadInfo{} + workloadInfo := &rolloutv1beta1.WorkloadInfo{} workloadInfo.APIVersion = workload.APIVersion workloadInfo.Kind = workload.Kind workloadInfo.Name = workload.Name @@ -282,7 +282,7 @@ func (r *controllerFinder2) getWorkloadInfoWithNativeStatefulSet(namespace strin } // getLabelSelectorWithNativeStatefulSet returns selector with deployment referenced by the provided controllerRef -func (r *controllerFinder2) getLabelSelectorWithNativeStatefulSet(namespace string, ref *rolloutv1alpha1.WorkloadRef) (*v1.LabelSelector, error) { +func (r *controllerFinder2) getLabelSelectorWithNativeStatefulSet(namespace string, ref *rolloutv1beta1.WorkloadRef) (*v1.LabelSelector, error) { // This error is irreversible, so there is no need to return error ok, _ := verifyGroupKind(ref, util.ControllerKindSts.Kind, []string{util.ControllerKindSts.Group}) if !ok { @@ -305,7 +305,7 @@ func (r *controllerFinder2) getLabelSelectorWithNativeStatefulSet(namespace stri return labelSelector, nil } -func verifyGroupKind(ref *rolloutv1alpha1.WorkloadRef, expectedKind string, expectedGroups []string) (bool, error) { +func verifyGroupKind(ref *rolloutv1beta1.WorkloadRef, expectedKind string, expectedGroups []string) (bool, error) { gv, err := schema.ParseGroupVersion(ref.APIVersion) if err != nil { return false, err diff --git a/pkg/controller/trafficrouting/trafficrouting_controller.go b/pkg/controller/trafficrouting/trafficrouting_controller.go index eb62d3c2..5cabd3e9 100644 --- a/pkg/controller/trafficrouting/trafficrouting_controller.go +++ b/pkg/controller/trafficrouting/trafficrouting_controller.go @@ -24,7 +24,7 @@ import ( "strings" "time" - "github.com/openkruise/rollouts/api/v1alpha1" + "github.com/openkruise/rollouts/api/v1beta1" "github.com/openkruise/rollouts/pkg/trafficrouting" "github.com/openkruise/rollouts/pkg/util" "k8s.io/apimachinery/pkg/api/errors" @@ -45,7 +45,7 @@ import ( var ( concurrentReconciles = 3 defaultGracePeriodSeconds int32 = 3 - trControllerKind = v1alpha1.SchemeGroupVersion.WithKind("TrafficRouting") + trControllerKind = v1beta1.SchemeGroupVersion.WithKind("TrafficRouting") ) func init() { @@ -76,7 +76,7 @@ type TrafficRoutingReconciler struct { // - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.8.3/pkg/reconcile func (r *TrafficRoutingReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { // Fetch the Rollout instance - tr := &v1alpha1.TrafficRouting{} + tr := &v1beta1.TrafficRouting{} err := r.Get(context.TODO(), req.NamespacedName, tr) if err != nil { if errors.IsNotFound(err) { @@ -96,38 +96,38 @@ func (r *TrafficRoutingReconciler) Reconcile(ctx context.Context, req ctrl.Reque } newStatus := tr.Status.DeepCopy() if newStatus.Phase == "" { - newStatus.Phase = v1alpha1.TrafficRoutingPhaseInitial + newStatus.Phase = v1beta1.TrafficRoutingPhaseInitial } if !tr.DeletionTimestamp.IsZero() { - newStatus.Phase = v1alpha1.TrafficRoutingPhaseTerminating + newStatus.Phase = v1beta1.TrafficRoutingPhaseTerminating } var done = true switch newStatus.Phase { - case v1alpha1.TrafficRoutingPhaseInitial: + case v1beta1.TrafficRoutingPhaseInitial: err = r.trafficRoutingManager.InitializeTrafficRouting(newTrafficRoutingContext(tr)) if err == nil { - newStatus.Phase = v1alpha1.TrafficRoutingPhaseHealthy + newStatus.Phase = v1beta1.TrafficRoutingPhaseHealthy newStatus.Message = "TrafficRouting is Healthy" } - case v1alpha1.TrafficRoutingPhaseHealthy: + case v1beta1.TrafficRoutingPhaseHealthy: if rolloutProgressingFinalizer(tr).Len() > 0 { - newStatus.Phase = v1alpha1.TrafficRoutingPhaseProgressing + newStatus.Phase = v1beta1.TrafficRoutingPhaseProgressing newStatus.Message = "TrafficRouting is Progressing" } - case v1alpha1.TrafficRoutingPhaseProgressing: + case v1beta1.TrafficRoutingPhaseProgressing: if rolloutProgressingFinalizer(tr).Len() == 0 { - newStatus.Phase = v1alpha1.TrafficRoutingPhaseFinalizing + newStatus.Phase = v1beta1.TrafficRoutingPhaseFinalizing newStatus.Message = "TrafficRouting is Finalizing" } else { done, err = r.trafficRoutingManager.DoTrafficRouting(newTrafficRoutingContext(tr)) } - case v1alpha1.TrafficRoutingPhaseFinalizing: + case v1beta1.TrafficRoutingPhaseFinalizing: done, err = r.trafficRoutingManager.FinalisingTrafficRouting(newTrafficRoutingContext(tr), false) if done { - newStatus.Phase = v1alpha1.TrafficRoutingPhaseHealthy + newStatus.Phase = v1beta1.TrafficRoutingPhaseHealthy newStatus.Message = "TrafficRouting is Healthy" } - case v1alpha1.TrafficRoutingPhaseTerminating: + case v1beta1.TrafficRoutingPhaseTerminating: done, err = r.trafficRoutingManager.FinalisingTrafficRouting(newTrafficRoutingContext(tr), false) if done { // remove trafficRouting finalizer @@ -144,7 +144,7 @@ func (r *TrafficRoutingReconciler) Reconcile(ctx context.Context, req ctrl.Reque return ctrl.Result{}, r.updateTrafficRoutingStatus(tr, *newStatus) } -func (r *TrafficRoutingReconciler) updateTrafficRoutingStatus(tr *v1alpha1.TrafficRouting, newStatus v1alpha1.TrafficRoutingStatus) error { +func (r *TrafficRoutingReconciler) updateTrafficRoutingStatus(tr *v1beta1.TrafficRouting, newStatus v1beta1.TrafficRoutingStatus) error { if reflect.DeepEqual(tr.Status, newStatus) { return nil } @@ -164,7 +164,7 @@ func (r *TrafficRoutingReconciler) updateTrafficRoutingStatus(tr *v1alpha1.Traff } // handle adding and handle finalizer logic, it turns if we should continue to reconcile -func (r *TrafficRoutingReconciler) handleFinalizer(tr *v1alpha1.TrafficRouting) error { +func (r *TrafficRoutingReconciler) handleFinalizer(tr *v1beta1.TrafficRouting) error { // delete trafficRouting crd, remove finalizer if !tr.DeletionTimestamp.IsZero() { err := util.UpdateFinalizer(r.Client, tr, util.RemoveFinalizerOpType, util.TrafficRoutingFinalizer) @@ -188,10 +188,10 @@ func (r *TrafficRoutingReconciler) handleFinalizer(tr *v1alpha1.TrafficRouting) return nil } -func rolloutProgressingFinalizer(tr *v1alpha1.TrafficRouting) sets.String { +func rolloutProgressingFinalizer(tr *v1beta1.TrafficRouting) sets.String { progressing := sets.String{} for _, s := range tr.GetFinalizers() { - if strings.Contains(s, v1alpha1.ProgressingRolloutFinalizerPrefix) { + if strings.Contains(s, v1beta1.ProgressingRolloutFinalizerPrefix) { progressing.Insert(s) } } @@ -206,14 +206,14 @@ func (r *TrafficRoutingReconciler) SetupWithManager(mgr ctrl.Manager) error { return err } // Watch for changes to trafficrouting - if err = c.Watch(&source.Kind{Type: &v1alpha1.TrafficRouting{}}, &handler.EnqueueRequestForObject{}); err != nil { + if err = c.Watch(&source.Kind{Type: &v1beta1.TrafficRouting{}}, &handler.EnqueueRequestForObject{}); err != nil { return err } r.trafficRoutingManager = trafficrouting.NewTrafficRoutingManager(mgr.GetClient()) return nil } -func newTrafficRoutingContext(tr *v1alpha1.TrafficRouting) *trafficrouting.TrafficRoutingContext { +func newTrafficRoutingContext(tr *v1beta1.TrafficRouting) *trafficrouting.TrafficRoutingContext { return &trafficrouting.TrafficRoutingContext{ Key: fmt.Sprintf("TrafficRouting(%s/%s)", tr.Namespace, tr.Name), Namespace: tr.Namespace, diff --git a/pkg/controller/trafficrouting/trafficrouting_controller_test.go b/pkg/controller/trafficrouting/trafficrouting_controller_test.go index 6485a3f2..ddd68a7a 100644 --- a/pkg/controller/trafficrouting/trafficrouting_controller_test.go +++ b/pkg/controller/trafficrouting/trafficrouting_controller_test.go @@ -23,7 +23,7 @@ import ( "testing" kruisev1aplphal "github.com/openkruise/kruise-api/apps/v1alpha1" - "github.com/openkruise/rollouts/api/v1alpha1" + "github.com/openkruise/rollouts/api/v1beta1" "github.com/openkruise/rollouts/pkg/trafficrouting" "github.com/openkruise/rollouts/pkg/util" "github.com/openkruise/rollouts/pkg/util/configuration" @@ -104,26 +104,26 @@ var ( }, } - demoTR = &v1alpha1.TrafficRouting{ + demoTR = &v1beta1.TrafficRouting{ TypeMeta: metav1.TypeMeta{ - APIVersion: "rollouts.kruise.io/v1alpha1", + APIVersion: "rollouts.kruise.io/v1beta1", Kind: "TrafficRouting", }, ObjectMeta: metav1.ObjectMeta{ Name: "tr-demo", Labels: map[string]string{}, }, - Spec: v1alpha1.TrafficRoutingSpec{ - ObjectRef: []v1alpha1.TrafficRoutingRef{ + Spec: v1beta1.TrafficRoutingSpec{ + ObjectRef: []v1beta1.TrafficRoutingRef{ { Service: "echoserver", - Ingress: &v1alpha1.IngressTrafficRouting{ + Ingress: &v1beta1.IngressTrafficRouting{ Name: "echoserver", }, }, }, - Strategy: v1alpha1.TrafficRoutingStrategy{ - Matches: []v1alpha1.HttpRouteMatch{ + Strategy: v1beta1.TrafficRoutingStrategy{ + Matches: []v1beta1.HttpRouteMatch{ // header { Headers: []gatewayv1alpha2.HTTPHeaderMatch{ @@ -185,15 +185,15 @@ func init() { scheme = runtime.NewScheme() _ = clientgoscheme.AddToScheme(scheme) _ = kruisev1aplphal.AddToScheme(scheme) - _ = v1alpha1.AddToScheme(scheme) + _ = v1beta1.AddToScheme(scheme) } func TestTrafficRoutingTest(t *testing.T) { cases := []struct { name string getObj func() ([]*corev1.Service, []*netv1.Ingress) - getTrafficRouting func() *v1alpha1.TrafficRouting - expectObj func() ([]*corev1.Service, []*netv1.Ingress, *v1alpha1.TrafficRouting) + getTrafficRouting func() *v1beta1.TrafficRouting + expectObj func() ([]*corev1.Service, []*netv1.Ingress, *v1beta1.TrafficRouting) expectDone bool }{ { @@ -201,14 +201,14 @@ func TestTrafficRoutingTest(t *testing.T) { getObj: func() ([]*corev1.Service, []*netv1.Ingress) { return []*corev1.Service{demoService.DeepCopy()}, []*netv1.Ingress{demoIngress.DeepCopy()} }, - getTrafficRouting: func() *v1alpha1.TrafficRouting { + getTrafficRouting: func() *v1beta1.TrafficRouting { return demoTR.DeepCopy() }, - expectObj: func() ([]*corev1.Service, []*netv1.Ingress, *v1alpha1.TrafficRouting) { + expectObj: func() ([]*corev1.Service, []*netv1.Ingress, *v1beta1.TrafficRouting) { s1 := demoService.DeepCopy() tr := demoTR.DeepCopy() - tr.Status = v1alpha1.TrafficRoutingStatus{ - Phase: v1alpha1.TrafficRoutingPhaseHealthy, + tr.Status = v1beta1.TrafficRoutingStatus{ + Phase: v1beta1.TrafficRoutingPhaseHealthy, } return []*corev1.Service{s1}, []*netv1.Ingress{demoIngress.DeepCopy()}, tr }, @@ -219,20 +219,20 @@ func TestTrafficRoutingTest(t *testing.T) { getObj: func() ([]*corev1.Service, []*netv1.Ingress) { return []*corev1.Service{demoService.DeepCopy()}, []*netv1.Ingress{demoIngress.DeepCopy()} }, - getTrafficRouting: func() *v1alpha1.TrafficRouting { + getTrafficRouting: func() *v1beta1.TrafficRouting { obj := demoTR.DeepCopy() - obj.Status = v1alpha1.TrafficRoutingStatus{ - Phase: v1alpha1.TrafficRoutingPhaseHealthy, + obj.Status = v1beta1.TrafficRoutingStatus{ + Phase: v1beta1.TrafficRoutingPhaseHealthy, } - obj.Finalizers = []string{fmt.Sprintf("%s/rollout-test", v1alpha1.ProgressingRolloutFinalizerPrefix), + obj.Finalizers = []string{fmt.Sprintf("%s/rollout-test", v1beta1.ProgressingRolloutFinalizerPrefix), util.TrafficRoutingFinalizer} return obj }, - expectObj: func() ([]*corev1.Service, []*netv1.Ingress, *v1alpha1.TrafficRouting) { + expectObj: func() ([]*corev1.Service, []*netv1.Ingress, *v1beta1.TrafficRouting) { s1 := demoService.DeepCopy() tr := demoTR.DeepCopy() - tr.Status = v1alpha1.TrafficRoutingStatus{ - Phase: v1alpha1.TrafficRoutingPhaseProgressing, + tr.Status = v1beta1.TrafficRoutingStatus{ + Phase: v1beta1.TrafficRoutingPhaseProgressing, } return []*corev1.Service{s1}, []*netv1.Ingress{demoIngress.DeepCopy()}, tr }, @@ -243,16 +243,16 @@ func TestTrafficRoutingTest(t *testing.T) { getObj: func() ([]*corev1.Service, []*netv1.Ingress) { return []*corev1.Service{demoService.DeepCopy()}, []*netv1.Ingress{demoIngress.DeepCopy()} }, - getTrafficRouting: func() *v1alpha1.TrafficRouting { + getTrafficRouting: func() *v1beta1.TrafficRouting { obj := demoTR.DeepCopy() - obj.Status = v1alpha1.TrafficRoutingStatus{ - Phase: v1alpha1.TrafficRoutingPhaseProgressing, + obj.Status = v1beta1.TrafficRoutingStatus{ + Phase: v1beta1.TrafficRoutingPhaseProgressing, } - obj.Finalizers = []string{fmt.Sprintf("%s/rollout-test", v1alpha1.ProgressingRolloutFinalizerPrefix), + obj.Finalizers = []string{fmt.Sprintf("%s/rollout-test", v1beta1.ProgressingRolloutFinalizerPrefix), util.TrafficRoutingFinalizer} return obj }, - expectObj: func() ([]*corev1.Service, []*netv1.Ingress, *v1alpha1.TrafficRouting) { + expectObj: func() ([]*corev1.Service, []*netv1.Ingress, *v1beta1.TrafficRouting) { s1 := demoService.DeepCopy() i1 := demoIngress.DeepCopy() i2 := demoIngress.DeepCopy() @@ -260,8 +260,8 @@ func TestTrafficRoutingTest(t *testing.T) { i2.Annotations[fmt.Sprintf("%s/canary", nginxIngressAnnotationDefaultPrefix)] = "true" i2.Annotations[fmt.Sprintf("%s/canary-weight", nginxIngressAnnotationDefaultPrefix)] = "0" tr := demoTR.DeepCopy() - tr.Status = v1alpha1.TrafficRoutingStatus{ - Phase: v1alpha1.TrafficRoutingPhaseProgressing, + tr.Status = v1beta1.TrafficRoutingStatus{ + Phase: v1beta1.TrafficRoutingPhaseProgressing, } return []*corev1.Service{s1}, []*netv1.Ingress{i1, i2}, tr }, @@ -278,16 +278,16 @@ func TestTrafficRoutingTest(t *testing.T) { i2.Annotations[fmt.Sprintf("%s/canary-weight", nginxIngressAnnotationDefaultPrefix)] = "0" return []*corev1.Service{s1}, []*netv1.Ingress{i1, i2} }, - getTrafficRouting: func() *v1alpha1.TrafficRouting { + getTrafficRouting: func() *v1beta1.TrafficRouting { obj := demoTR.DeepCopy() - obj.Status = v1alpha1.TrafficRoutingStatus{ - Phase: v1alpha1.TrafficRoutingPhaseProgressing, + obj.Status = v1beta1.TrafficRoutingStatus{ + Phase: v1beta1.TrafficRoutingPhaseProgressing, } - obj.Finalizers = []string{fmt.Sprintf("%s/rollout-test", v1alpha1.ProgressingRolloutFinalizerPrefix), + obj.Finalizers = []string{fmt.Sprintf("%s/rollout-test", v1beta1.ProgressingRolloutFinalizerPrefix), util.TrafficRoutingFinalizer} return obj }, - expectObj: func() ([]*corev1.Service, []*netv1.Ingress, *v1alpha1.TrafficRouting) { + expectObj: func() ([]*corev1.Service, []*netv1.Ingress, *v1beta1.TrafficRouting) { s1 := demoService.DeepCopy() i1 := demoIngress.DeepCopy() i2 := demoIngress.DeepCopy() @@ -296,8 +296,8 @@ func TestTrafficRoutingTest(t *testing.T) { i2.Annotations["nginx.ingress.kubernetes.io/canary-by-header"] = "user_id" i2.Annotations["nginx.ingress.kubernetes.io/canary-by-header-value"] = "123456" tr := demoTR.DeepCopy() - tr.Status = v1alpha1.TrafficRoutingStatus{ - Phase: v1alpha1.TrafficRoutingPhaseProgressing, + tr.Status = v1beta1.TrafficRoutingStatus{ + Phase: v1beta1.TrafficRoutingPhaseProgressing, } return []*corev1.Service{s1}, []*netv1.Ingress{i1, i2}, tr }, @@ -315,16 +315,16 @@ func TestTrafficRoutingTest(t *testing.T) { i2.Annotations["nginx.ingress.kubernetes.io/canary-by-header-value"] = "123456" return []*corev1.Service{s1}, []*netv1.Ingress{i1, i2} }, - getTrafficRouting: func() *v1alpha1.TrafficRouting { + getTrafficRouting: func() *v1beta1.TrafficRouting { obj := demoTR.DeepCopy() - obj.Status = v1alpha1.TrafficRoutingStatus{ - Phase: v1alpha1.TrafficRoutingPhaseProgressing, + obj.Status = v1beta1.TrafficRoutingStatus{ + Phase: v1beta1.TrafficRoutingPhaseProgressing, } - obj.Finalizers = []string{fmt.Sprintf("%s/rollout-test", v1alpha1.ProgressingRolloutFinalizerPrefix), + obj.Finalizers = []string{fmt.Sprintf("%s/rollout-test", v1beta1.ProgressingRolloutFinalizerPrefix), util.TrafficRoutingFinalizer} return obj }, - expectObj: func() ([]*corev1.Service, []*netv1.Ingress, *v1alpha1.TrafficRouting) { + expectObj: func() ([]*corev1.Service, []*netv1.Ingress, *v1beta1.TrafficRouting) { s1 := demoService.DeepCopy() i1 := demoIngress.DeepCopy() i2 := demoIngress.DeepCopy() @@ -333,8 +333,8 @@ func TestTrafficRoutingTest(t *testing.T) { i2.Annotations["nginx.ingress.kubernetes.io/canary-by-header"] = "user_id" i2.Annotations["nginx.ingress.kubernetes.io/canary-by-header-value"] = "123456" tr := demoTR.DeepCopy() - tr.Status = v1alpha1.TrafficRoutingStatus{ - Phase: v1alpha1.TrafficRoutingPhaseProgressing, + tr.Status = v1beta1.TrafficRoutingStatus{ + Phase: v1beta1.TrafficRoutingPhaseProgressing, } return []*corev1.Service{s1}, []*netv1.Ingress{i1, i2}, tr }, @@ -405,9 +405,9 @@ func checkObjEqual(c client.WithWatch, t *testing.T, expect client.Object) { } case "TrafficRouting": - s1 := obj.(*v1alpha1.TrafficRouting) + s1 := obj.(*v1beta1.TrafficRouting) s1.Status.Message = "" - s2 := expect.(*v1alpha1.TrafficRouting) + s2 := expect.(*v1beta1.TrafficRouting) if !reflect.DeepEqual(s1.Status, s2.Status) { t.Fatalf("expect(%s), but get object(%s)", util.DumpJSON(s2), util.DumpJSON(s1)) } @@ -421,7 +421,7 @@ func getEmptyObject(gvk schema.GroupVersionKind) client.Object { case "Ingress": return &netv1.Ingress{} case "TrafficRouting": - return &v1alpha1.TrafficRouting{} + return &v1beta1.TrafficRouting{} } return nil } diff --git a/pkg/trafficrouting/manager.go b/pkg/trafficrouting/manager.go index 1f77dd2b..92f8ff62 100644 --- a/pkg/trafficrouting/manager.go +++ b/pkg/trafficrouting/manager.go @@ -21,7 +21,7 @@ import ( "fmt" "time" - "github.com/openkruise/rollouts/api/v1alpha1" + "github.com/openkruise/rollouts/api/v1beta1" "github.com/openkruise/rollouts/pkg/trafficrouting/network" "github.com/openkruise/rollouts/pkg/trafficrouting/network/gateway" "github.com/openkruise/rollouts/pkg/trafficrouting/network/ingress" @@ -43,8 +43,8 @@ type TrafficRoutingContext struct { // only for log info Key string Namespace string - ObjectRef []v1alpha1.TrafficRoutingRef - Strategy v1alpha1.TrafficRoutingStrategy + ObjectRef []v1beta1.TrafficRoutingRef + Strategy v1beta1.TrafficRoutingStrategy // OnlyTrafficRouting OnlyTrafficRouting bool OwnerRef metav1.OwnerReference diff --git a/pkg/trafficrouting/manager_test.go b/pkg/trafficrouting/manager_test.go index 94fa9c43..0676a55e 100644 --- a/pkg/trafficrouting/manager_test.go +++ b/pkg/trafficrouting/manager_test.go @@ -24,7 +24,7 @@ import ( "time" kruisev1aplphal "github.com/openkruise/kruise-api/apps/v1alpha1" - "github.com/openkruise/rollouts/api/v1alpha1" + "github.com/openkruise/rollouts/api/v1beta1" "github.com/openkruise/rollouts/pkg/util" "github.com/openkruise/rollouts/pkg/util/configuration" apps "k8s.io/api/apps/v1" @@ -103,7 +103,7 @@ var ( }, } - demoRollout = &v1alpha1.Rollout{ + demoRollout = &v1beta1.Rollout{ ObjectMeta: metav1.ObjectMeta{ Name: "rollout-demo", Labels: map[string]string{}, @@ -111,46 +111,46 @@ var ( util.RolloutHashAnnotation: "rollout-hash-v1", }, }, - Spec: v1alpha1.RolloutSpec{ - ObjectRef: v1alpha1.ObjectRef{ - WorkloadRef: &v1alpha1.WorkloadRef{ + Spec: v1beta1.RolloutSpec{ + ObjectRef: v1beta1.ObjectRef{ + WorkloadRef: &v1beta1.WorkloadRef{ APIVersion: "apps/v1", Kind: "Deployment", Name: "echoserver", }, }, - Strategy: v1alpha1.RolloutStrategy{ - Canary: &v1alpha1.CanaryStrategy{ - Steps: []v1alpha1.CanaryStep{ + Strategy: v1beta1.RolloutStrategy{ + Canary: &v1beta1.CanaryStrategy{ + Steps: []v1beta1.CanaryStep{ { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(5), }, Replicas: &intstr.IntOrString{IntVal: 1}, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(20), }, Replicas: &intstr.IntOrString{IntVal: 2}, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(60), }, Replicas: &intstr.IntOrString{IntVal: 6}, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(100), }, Replicas: &intstr.IntOrString{IntVal: 10}, }, }, - TrafficRoutings: []v1alpha1.TrafficRoutingRef{ + TrafficRoutings: []v1beta1.TrafficRoutingRef{ { Service: "echoserver", - Ingress: &v1alpha1.IngressTrafficRouting{ + Ingress: &v1beta1.IngressTrafficRouting{ Name: "echoserver", }, }, @@ -158,23 +158,23 @@ var ( }, }, }, - Status: v1alpha1.RolloutStatus{ - Phase: v1alpha1.RolloutPhaseProgressing, - CanaryStatus: &v1alpha1.CanaryStatus{ + Status: v1beta1.RolloutStatus{ + Phase: v1beta1.RolloutPhaseProgressing, + CanaryStatus: &v1beta1.CanaryStatus{ ObservedWorkloadGeneration: 1, RolloutHash: "rollout-hash-v1", ObservedRolloutID: "rollout-id-1", StableRevision: "podtemplatehash-v1", CanaryRevision: "revision-v2", CurrentStepIndex: 1, - CurrentStepState: v1alpha1.CanaryStepStateTrafficRouting, + CurrentStepState: v1beta1.CanaryStepStateTrafficRouting, PodTemplateHash: "podtemplatehash-v2", LastUpdateTime: &metav1.Time{Time: time.Now()}, }, - Conditions: []v1alpha1.RolloutCondition{ + Conditions: []v1beta1.RolloutCondition{ { - Type: v1alpha1.RolloutConditionProgressing, - Reason: v1alpha1.ProgressingReasonInRolling, + Type: v1beta1.RolloutConditionProgressing, + Reason: v1beta1.ProgressingReasonInRolling, Status: corev1.ConditionFalse, }, }, @@ -228,14 +228,14 @@ func init() { scheme = runtime.NewScheme() _ = clientgoscheme.AddToScheme(scheme) _ = kruisev1aplphal.AddToScheme(scheme) - _ = v1alpha1.AddToScheme(scheme) + _ = v1beta1.AddToScheme(scheme) } func TestDoTrafficRouting(t *testing.T) { cases := []struct { name string getObj func() ([]*corev1.Service, []*netv1.Ingress) - getRollout func() (*v1alpha1.Rollout, *util.Workload) + getRollout func() (*v1beta1.Rollout, *util.Workload) expectObj func() ([]*corev1.Service, []*netv1.Ingress) expectDone bool }{ @@ -244,7 +244,7 @@ func TestDoTrafficRouting(t *testing.T) { getObj: func() ([]*corev1.Service, []*netv1.Ingress) { return []*corev1.Service{demoService.DeepCopy()}, []*netv1.Ingress{demoIngress.DeepCopy()} }, - getRollout: func() (*v1alpha1.Rollout, *util.Workload) { + getRollout: func() (*v1beta1.Rollout, *util.Workload) { return demoRollout.DeepCopy(), &util.Workload{RevisionLabelKey: apps.DefaultDeploymentUniqueLabelKey} }, expectObj: func() ([]*corev1.Service, []*netv1.Ingress) { @@ -267,7 +267,7 @@ func TestDoTrafficRouting(t *testing.T) { s2.Spec.Selector[apps.DefaultDeploymentUniqueLabelKey] = "podtemplatehash-v2" return []*corev1.Service{s1, s2}, []*netv1.Ingress{demoIngress.DeepCopy()} }, - getRollout: func() (*v1alpha1.Rollout, *util.Workload) { + getRollout: func() (*v1beta1.Rollout, *util.Workload) { obj := demoRollout.DeepCopy() obj.Status.CanaryStatus.LastUpdateTime = &metav1.Time{Time: time.Now()} return obj, &util.Workload{RevisionLabelKey: apps.DefaultDeploymentUniqueLabelKey} @@ -299,7 +299,7 @@ func TestDoTrafficRouting(t *testing.T) { c2.Annotations[fmt.Sprintf("%s/canary-weight", nginxIngressAnnotationDefaultPrefix)] = "0" return []*corev1.Service{s1, s2}, []*netv1.Ingress{c1, c2} }, - getRollout: func() (*v1alpha1.Rollout, *util.Workload) { + getRollout: func() (*v1beta1.Rollout, *util.Workload) { obj := demoRollout.DeepCopy() obj.Status.CanaryStatus.LastUpdateTime = &metav1.Time{Time: time.Now().Add(-10 * time.Second)} return obj, &util.Workload{RevisionLabelKey: apps.DefaultDeploymentUniqueLabelKey} @@ -336,7 +336,7 @@ func TestDoTrafficRouting(t *testing.T) { c2.Spec.Rules[0].HTTP.Paths[0].Backend.Service.Name = "echoserver-canary" return []*corev1.Service{s1, s2}, []*netv1.Ingress{c1, c2} }, - getRollout: func() (*v1alpha1.Rollout, *util.Workload) { + getRollout: func() (*v1beta1.Rollout, *util.Workload) { obj := demoRollout.DeepCopy() obj.Status.CanaryStatus.LastUpdateTime = &metav1.Time{Time: time.Now().Add(-10 * time.Second)} return obj, &util.Workload{RevisionLabelKey: apps.DefaultDeploymentUniqueLabelKey} @@ -373,7 +373,7 @@ func TestDoTrafficRouting(t *testing.T) { c2.Spec.Rules[0].HTTP.Paths[0].Backend.Service.Name = "echoserver-canary" return []*corev1.Service{s1, s2}, []*netv1.Ingress{c1, c2} }, - getRollout: func() (*v1alpha1.Rollout, *util.Workload) { + getRollout: func() (*v1beta1.Rollout, *util.Workload) { obj := demoRollout.DeepCopy() obj.Status.CanaryStatus.LastUpdateTime = &metav1.Time{Time: time.Now().Add(-10 * time.Second)} obj.Status.CanaryStatus.CurrentStepIndex = 2 @@ -419,7 +419,7 @@ func TestDoTrafficRouting(t *testing.T) { Namespace: rollout.Namespace, ObjectRef: rollout.Spec.Strategy.Canary.TrafficRoutings, Strategy: currentStep.TrafficRoutingStrategy, - OwnerRef: *metav1.NewControllerRef(rollout, v1alpha1.SchemeGroupVersion.WithKind("Rollout")), + OwnerRef: *metav1.NewControllerRef(rollout, v1beta1.SchemeGroupVersion.WithKind("Rollout")), RevisionLabelKey: workload.RevisionLabelKey, StableRevision: newStatus.CanaryStatus.StableRevision, CanaryRevision: newStatus.CanaryStatus.PodTemplateHash, @@ -452,7 +452,7 @@ func TestFinalisingTrafficRouting(t *testing.T) { cases := []struct { name string getObj func() ([]*corev1.Service, []*netv1.Ingress) - getRollout func() (*v1alpha1.Rollout, *util.Workload) + getRollout func() (*v1beta1.Rollout, *util.Workload) onlyRestoreStableService bool expectObj func() ([]*corev1.Service, []*netv1.Ingress) expectDone bool @@ -473,9 +473,9 @@ func TestFinalisingTrafficRouting(t *testing.T) { c2.Spec.Rules[0].HTTP.Paths[0].Backend.Service.Name = "echoserver-canary" return []*corev1.Service{s1, s2}, []*netv1.Ingress{c1, c2} }, - getRollout: func() (*v1alpha1.Rollout, *util.Workload) { + getRollout: func() (*v1beta1.Rollout, *util.Workload) { obj := demoRollout.DeepCopy() - obj.Status.CanaryStatus.CurrentStepState = v1alpha1.CanaryStepStateCompleted + obj.Status.CanaryStatus.CurrentStepState = v1beta1.CanaryStepStateCompleted obj.Status.CanaryStatus.CurrentStepIndex = 4 return obj, &util.Workload{RevisionLabelKey: apps.DefaultDeploymentUniqueLabelKey} }, @@ -510,9 +510,9 @@ func TestFinalisingTrafficRouting(t *testing.T) { c2.Spec.Rules[0].HTTP.Paths[0].Backend.Service.Name = "echoserver-canary" return []*corev1.Service{s1, s2}, []*netv1.Ingress{c1, c2} }, - getRollout: func() (*v1alpha1.Rollout, *util.Workload) { + getRollout: func() (*v1beta1.Rollout, *util.Workload) { obj := demoRollout.DeepCopy() - obj.Status.CanaryStatus.CurrentStepState = v1alpha1.CanaryStepStateCompleted + obj.Status.CanaryStatus.CurrentStepState = v1beta1.CanaryStepStateCompleted obj.Status.CanaryStatus.CurrentStepIndex = 4 return obj, &util.Workload{RevisionLabelKey: apps.DefaultDeploymentUniqueLabelKey} }, @@ -547,9 +547,9 @@ func TestFinalisingTrafficRouting(t *testing.T) { c2.Spec.Rules[0].HTTP.Paths[0].Backend.Service.Name = "echoserver-canary" return []*corev1.Service{s1, s2}, []*netv1.Ingress{c1, c2} }, - getRollout: func() (*v1alpha1.Rollout, *util.Workload) { + getRollout: func() (*v1beta1.Rollout, *util.Workload) { obj := demoRollout.DeepCopy() - obj.Status.CanaryStatus.CurrentStepState = v1alpha1.CanaryStepStateCompleted + obj.Status.CanaryStatus.CurrentStepState = v1beta1.CanaryStepStateCompleted obj.Status.CanaryStatus.CurrentStepIndex = 4 obj.Status.CanaryStatus.LastUpdateTime = &metav1.Time{Time: time.Now().Add(-10 * time.Second)} return obj, &util.Workload{RevisionLabelKey: apps.DefaultDeploymentUniqueLabelKey} @@ -585,9 +585,9 @@ func TestFinalisingTrafficRouting(t *testing.T) { c2.Spec.Rules[0].HTTP.Paths[0].Backend.Service.Name = "echoserver-canary" return []*corev1.Service{s1, s2}, []*netv1.Ingress{c1, c2} }, - getRollout: func() (*v1alpha1.Rollout, *util.Workload) { + getRollout: func() (*v1beta1.Rollout, *util.Workload) { obj := demoRollout.DeepCopy() - obj.Status.CanaryStatus.CurrentStepState = v1alpha1.CanaryStepStateCompleted + obj.Status.CanaryStatus.CurrentStepState = v1beta1.CanaryStepStateCompleted obj.Status.CanaryStatus.CurrentStepIndex = 4 obj.Status.CanaryStatus.LastUpdateTime = &metav1.Time{Time: time.Now().Add(-3 * time.Second)} return obj, &util.Workload{RevisionLabelKey: apps.DefaultDeploymentUniqueLabelKey} @@ -623,9 +623,9 @@ func TestFinalisingTrafficRouting(t *testing.T) { c2.Spec.Rules[0].HTTP.Paths[0].Backend.Service.Name = "echoserver-canary" return []*corev1.Service{s1, s2}, []*netv1.Ingress{c1, c2} }, - getRollout: func() (*v1alpha1.Rollout, *util.Workload) { + getRollout: func() (*v1beta1.Rollout, *util.Workload) { obj := demoRollout.DeepCopy() - obj.Status.CanaryStatus.CurrentStepState = v1alpha1.CanaryStepStateCompleted + obj.Status.CanaryStatus.CurrentStepState = v1beta1.CanaryStepStateCompleted obj.Status.CanaryStatus.CurrentStepIndex = 4 obj.Status.CanaryStatus.LastUpdateTime = &metav1.Time{Time: time.Now().Add(-3 * time.Second)} return obj, &util.Workload{RevisionLabelKey: apps.DefaultDeploymentUniqueLabelKey} @@ -658,7 +658,7 @@ func TestFinalisingTrafficRouting(t *testing.T) { Namespace: rollout.Namespace, ObjectRef: rollout.Spec.Strategy.Canary.TrafficRoutings, Strategy: currentStep.TrafficRoutingStrategy, - OwnerRef: *metav1.NewControllerRef(rollout, v1alpha1.SchemeGroupVersion.WithKind("Rollout")), + OwnerRef: *metav1.NewControllerRef(rollout, v1beta1.SchemeGroupVersion.WithKind("Rollout")), RevisionLabelKey: workload.RevisionLabelKey, StableRevision: newStatus.CanaryStatus.StableRevision, CanaryRevision: newStatus.CanaryStatus.PodTemplateHash, diff --git a/pkg/trafficrouting/network/gateway/gateway.go b/pkg/trafficrouting/network/gateway/gateway.go index 572e138a..e2c2fa16 100644 --- a/pkg/trafficrouting/network/gateway/gateway.go +++ b/pkg/trafficrouting/network/gateway/gateway.go @@ -17,7 +17,7 @@ import ( "context" "reflect" - rolloutv1alpha1 "github.com/openkruise/rollouts/api/v1alpha1" + rolloutv1beta1 "github.com/openkruise/rollouts/api/v1beta1" "github.com/openkruise/rollouts/pkg/trafficrouting/network" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/types" @@ -34,7 +34,7 @@ type Config struct { Namespace string CanaryService string StableService string - TrafficConf *rolloutv1alpha1.GatewayTrafficRouting + TrafficConf *rolloutv1beta1.GatewayTrafficRouting } type gatewayController struct { @@ -56,7 +56,7 @@ func (r *gatewayController) Initialize(ctx context.Context) error { return r.Get(ctx, types.NamespacedName{Namespace: r.conf.Namespace, Name: *r.conf.TrafficConf.HTTPRouteName}, route) } -func (r *gatewayController) EnsureRoutes(ctx context.Context, strategy *rolloutv1alpha1.TrafficRoutingStrategy) (bool, error) { +func (r *gatewayController) EnsureRoutes(ctx context.Context, strategy *rolloutv1beta1.TrafficRoutingStrategy) (bool, error) { weight := strategy.Weight matches := strategy.Matches // headerModifier := strategy.RequestHeaderModifier @@ -118,7 +118,7 @@ func (r *gatewayController) Finalise(ctx context.Context) error { return nil } -func (r *gatewayController) buildDesiredHTTPRoute(rules []gatewayv1alpha2.HTTPRouteRule, weight *int32, matches []rolloutv1alpha1.HttpRouteMatch, +func (r *gatewayController) buildDesiredHTTPRoute(rules []gatewayv1alpha2.HTTPRouteRule, weight *int32, matches []rolloutv1beta1.HttpRouteMatch, rh *gatewayv1alpha2.HTTPRequestHeaderFilter) []gatewayv1alpha2.HTTPRouteRule { var desired []gatewayv1alpha2.HTTPRouteRule // Only when finalize method parameter weight=-1, @@ -146,7 +146,7 @@ func (r *gatewayController) buildDesiredHTTPRoute(rules []gatewayv1alpha2.HTTPRo return r.buildCanaryWeightHttpRoutes(rules, weight) } -func (r *gatewayController) buildCanaryHeaderHttpRoutes(rules []gatewayv1alpha2.HTTPRouteRule, matchs []rolloutv1alpha1.HttpRouteMatch) []gatewayv1alpha2.HTTPRouteRule { +func (r *gatewayController) buildCanaryHeaderHttpRoutes(rules []gatewayv1alpha2.HTTPRouteRule, matchs []rolloutv1beta1.HttpRouteMatch) []gatewayv1alpha2.HTTPRouteRule { var desired []gatewayv1alpha2.HTTPRouteRule var canarys []gatewayv1alpha2.HTTPRouteRule for i := range rules { diff --git a/pkg/trafficrouting/network/gateway/gateway_test.go b/pkg/trafficrouting/network/gateway/gateway_test.go index 8edfbed6..d8764a55 100644 --- a/pkg/trafficrouting/network/gateway/gateway_test.go +++ b/pkg/trafficrouting/network/gateway/gateway_test.go @@ -17,7 +17,7 @@ import ( "reflect" "testing" - rolloutsv1alpha1 "github.com/openkruise/rollouts/api/v1alpha1" + rolloutsv1beta1 "github.com/openkruise/rollouts/api/v1beta1" "github.com/openkruise/rollouts/pkg/util" utilpointer "k8s.io/utils/pointer" gatewayv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" @@ -130,7 +130,7 @@ func TestBuildDesiredHTTPRoute(t *testing.T) { cases := []struct { name string getRouteRules func() []gatewayv1alpha2.HTTPRouteRule - getRoutes func() (*int32, []rolloutsv1alpha1.HttpRouteMatch) + getRoutes func() (*int32, []rolloutsv1beta1.HttpRouteMatch) desiredRules func() []gatewayv1alpha2.HTTPRouteRule }{ { @@ -139,9 +139,9 @@ func TestBuildDesiredHTTPRoute(t *testing.T) { rules := routeDemo.DeepCopy().Spec.Rules return rules }, - getRoutes: func() (*int32, []rolloutsv1alpha1.HttpRouteMatch) { + getRoutes: func() (*int32, []rolloutsv1beta1.HttpRouteMatch) { iType := gatewayv1alpha2.HeaderMatchRegularExpression - return nil, []rolloutsv1alpha1.HttpRouteMatch{ + return nil, []rolloutsv1beta1.HttpRouteMatch{ // header { Headers: []gatewayv1alpha2.HTTPHeaderMatch{ @@ -360,7 +360,7 @@ func TestBuildDesiredHTTPRoute(t *testing.T) { } return rules }, - getRoutes: func() (*int32, []rolloutsv1alpha1.HttpRouteMatch) { + getRoutes: func() (*int32, []rolloutsv1beta1.HttpRouteMatch) { return utilpointer.Int32(20), nil }, desiredRules: func() []gatewayv1alpha2.HTTPRouteRule { @@ -494,7 +494,7 @@ func TestBuildDesiredHTTPRoute(t *testing.T) { }) return rules }, - getRoutes: func() (*int32, []rolloutsv1alpha1.HttpRouteMatch) { + getRoutes: func() (*int32, []rolloutsv1beta1.HttpRouteMatch) { return utilpointer.Int32(-1), nil }, desiredRules: func() []gatewayv1alpha2.HTTPRouteRule { diff --git a/pkg/trafficrouting/network/ingress/ingress.go b/pkg/trafficrouting/network/ingress/ingress.go index 9531a765..bec969bb 100644 --- a/pkg/trafficrouting/network/ingress/ingress.go +++ b/pkg/trafficrouting/network/ingress/ingress.go @@ -23,7 +23,7 @@ import ( "reflect" jsonpatch "github.com/evanphx/json-patch" - rolloutv1alpha1 "github.com/openkruise/rollouts/api/v1alpha1" + rolloutv1beta1 "github.com/openkruise/rollouts/api/v1beta1" "github.com/openkruise/rollouts/pkg/trafficrouting/network" "github.com/openkruise/rollouts/pkg/util" "github.com/openkruise/rollouts/pkg/util/configuration" @@ -56,7 +56,7 @@ type Config struct { Namespace string CanaryService string StableService string - TrafficConf *rolloutv1alpha1.IngressTrafficRouting + TrafficConf *rolloutv1beta1.IngressTrafficRouting OwnerRef metav1.OwnerReference } @@ -82,7 +82,7 @@ func (r *ingressController) Initialize(ctx context.Context) error { return r.Get(ctx, types.NamespacedName{Namespace: r.conf.Namespace, Name: r.conf.TrafficConf.Name}, ingress) } -func (r *ingressController) EnsureRoutes(ctx context.Context, strategy *rolloutv1alpha1.TrafficRoutingStrategy) (bool, error) { +func (r *ingressController) EnsureRoutes(ctx context.Context, strategy *rolloutv1beta1.TrafficRoutingStrategy) (bool, error) { weight := strategy.Weight matches := strategy.Matches headerModifier := strategy.RequestHeaderModifier @@ -217,7 +217,7 @@ func defaultCanaryIngressName(name string) string { return fmt.Sprintf("%s-canary", name) } -func (r *ingressController) executeLuaForCanary(annotations map[string]string, weight *int32, matches []rolloutv1alpha1.HttpRouteMatch, +func (r *ingressController) executeLuaForCanary(annotations map[string]string, weight *int32, matches []rolloutv1beta1.HttpRouteMatch, headerModifier *gatewayv1alpha2.HTTPRequestHeaderFilter) (map[string]string, error) { if weight == nil { @@ -228,7 +228,7 @@ func (r *ingressController) executeLuaForCanary(annotations map[string]string, w type LuaData struct { Annotations map[string]string Weight string - Matches []rolloutv1alpha1.HttpRouteMatch + Matches []rolloutv1beta1.HttpRouteMatch CanaryService string RequestHeaderModifier *gatewayv1alpha2.HTTPRequestHeaderFilter } diff --git a/pkg/trafficrouting/network/ingress/ingress_test.go b/pkg/trafficrouting/network/ingress/ingress_test.go index 95e1ec99..3d886fe8 100644 --- a/pkg/trafficrouting/network/ingress/ingress_test.go +++ b/pkg/trafficrouting/network/ingress/ingress_test.go @@ -19,7 +19,7 @@ import ( "reflect" "testing" - rolloutsv1alpha1 "github.com/openkruise/rollouts/api/v1alpha1" + rolloutsv1beta1 "github.com/openkruise/rollouts/api/v1beta1" "github.com/openkruise/rollouts/pkg/util" "github.com/openkruise/rollouts/pkg/util/configuration" corev1 "k8s.io/api/core/v1" @@ -253,7 +253,7 @@ var ( func init() { scheme = runtime.NewScheme() _ = clientgoscheme.AddToScheme(scheme) - _ = rolloutsv1alpha1.AddToScheme(scheme) + _ = rolloutsv1beta1.AddToScheme(scheme) } func TestInitialize(t *testing.T) { @@ -277,7 +277,7 @@ func TestInitialize(t *testing.T) { Key: "rollout-demo", StableService: "echoserver", CanaryService: "echoserver-canary", - TrafficConf: &rolloutsv1alpha1.IngressTrafficRouting{ + TrafficConf: &rolloutsv1beta1.IngressTrafficRouting{ Name: "echoserver", }, } @@ -307,7 +307,7 @@ func TestEnsureRoutes(t *testing.T) { name string getConfigmap func() *corev1.ConfigMap getIngress func() []*netv1.Ingress - getRoutes func() *rolloutsv1alpha1.CanaryStep + getRoutes func() *rolloutsv1beta1.CanaryStep expectIngress func() *netv1.Ingress ingressType string }{ @@ -327,11 +327,11 @@ func TestEnsureRoutes(t *testing.T) { canary.Spec.Rules[1].HTTP.Paths[0].Backend.Service.Name = "echoserver-canary" return []*netv1.Ingress{demoIngress.DeepCopy(), canary} }, - getRoutes: func() *rolloutsv1alpha1.CanaryStep { - return &rolloutsv1alpha1.CanaryStep{ - TrafficRoutingStrategy: rolloutsv1alpha1.TrafficRoutingStrategy{ + getRoutes: func() *rolloutsv1beta1.CanaryStep { + return &rolloutsv1beta1.CanaryStep{ + TrafficRoutingStrategy: rolloutsv1beta1.TrafficRoutingStrategy{ Weight: nil, - Matches: []rolloutsv1alpha1.HttpRouteMatch{ + Matches: []rolloutsv1beta1.HttpRouteMatch{ // header { Headers: []gatewayv1alpha2.HTTPHeaderMatch{ @@ -398,9 +398,9 @@ func TestEnsureRoutes(t *testing.T) { canary.Spec.Rules[1].HTTP.Paths[0].Backend.Service.Name = "echoserver-canary" return []*netv1.Ingress{demoIngress.DeepCopy(), canary} }, - getRoutes: func() *rolloutsv1alpha1.CanaryStep { - return &rolloutsv1alpha1.CanaryStep{ - TrafficRoutingStrategy: rolloutsv1alpha1.TrafficRoutingStrategy{ + getRoutes: func() *rolloutsv1beta1.CanaryStep { + return &rolloutsv1beta1.CanaryStep{ + TrafficRoutingStrategy: rolloutsv1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(40), }, } @@ -433,11 +433,11 @@ func TestEnsureRoutes(t *testing.T) { canary.Spec.Rules[1].HTTP.Paths[0].Backend.Service.Name = "echoserver-canary" return []*netv1.Ingress{demoIngress.DeepCopy(), canary} }, - getRoutes: func() *rolloutsv1alpha1.CanaryStep { + getRoutes: func() *rolloutsv1beta1.CanaryStep { iType := gatewayv1alpha2.HeaderMatchRegularExpression - return &rolloutsv1alpha1.CanaryStep{ - TrafficRoutingStrategy: rolloutsv1alpha1.TrafficRoutingStrategy{ - Matches: []rolloutsv1alpha1.HttpRouteMatch{ + return &rolloutsv1beta1.CanaryStep{ + TrafficRoutingStrategy: rolloutsv1beta1.TrafficRoutingStrategy{ + Matches: []rolloutsv1beta1.HttpRouteMatch{ // header { Headers: []gatewayv1alpha2.HTTPHeaderMatch{ @@ -481,10 +481,10 @@ func TestEnsureRoutes(t *testing.T) { canary.Spec.Rules[1].HTTP.Paths[0].Backend.Service.Name = "echoserver-canary" return []*netv1.Ingress{demoIngress.DeepCopy(), canary} }, - getRoutes: func() *rolloutsv1alpha1.CanaryStep { - return &rolloutsv1alpha1.CanaryStep{ - TrafficRoutingStrategy: rolloutsv1alpha1.TrafficRoutingStrategy{ - Matches: []rolloutsv1alpha1.HttpRouteMatch{ + getRoutes: func() *rolloutsv1beta1.CanaryStep { + return &rolloutsv1beta1.CanaryStep{ + TrafficRoutingStrategy: rolloutsv1beta1.TrafficRoutingStrategy{ + Matches: []rolloutsv1beta1.HttpRouteMatch{ // header { Headers: []gatewayv1alpha2.HTTPHeaderMatch{ @@ -524,7 +524,7 @@ func TestEnsureRoutes(t *testing.T) { Key: "rollout-demo", StableService: "echoserver", CanaryService: "echoserver-canary", - TrafficConf: &rolloutsv1alpha1.IngressTrafficRouting{ + TrafficConf: &rolloutsv1beta1.IngressTrafficRouting{ Name: "echoserver", }, } @@ -594,7 +594,7 @@ func TestFinalise(t *testing.T) { Key: "rollout-demo", StableService: "echoserver", CanaryService: "echoserver-canary", - TrafficConf: &rolloutsv1alpha1.IngressTrafficRouting{ + TrafficConf: &rolloutsv1beta1.IngressTrafficRouting{ Name: "echoserver", }, } diff --git a/pkg/trafficrouting/network/interface.go b/pkg/trafficrouting/network/interface.go index 8cf0faf5..7fd8828e 100644 --- a/pkg/trafficrouting/network/interface.go +++ b/pkg/trafficrouting/network/interface.go @@ -19,7 +19,7 @@ package network import ( "context" - rolloutv1alpha1 "github.com/openkruise/rollouts/api/v1alpha1" + rolloutv1beta1 "github.com/openkruise/rollouts/api/v1beta1" ) // NetworkProvider common function across all TrafficRouting implementation @@ -33,7 +33,7 @@ type NetworkProvider interface { // 1. check if canary has been set desired weight. // 2. If not, set canary desired weight // When the first set weight is returned false, mainly to give the provider some time to process, only when again ensure, will return true - EnsureRoutes(ctx context.Context, strategy *rolloutv1alpha1.TrafficRoutingStrategy) (bool, error) + EnsureRoutes(ctx context.Context, strategy *rolloutv1beta1.TrafficRoutingStrategy) (bool, error) // Finalise will do some cleanup work after the canary rollout complete, such as delete canary ingress. // Finalise is called with a 3-second delay after completing the canary. Finalise(ctx context.Context) error diff --git a/pkg/util/condition.go b/pkg/util/condition.go index 85fd755c..b1ed7075 100644 --- a/pkg/util/condition.go +++ b/pkg/util/condition.go @@ -17,14 +17,14 @@ limitations under the License. package util import ( - "github.com/openkruise/rollouts/api/v1alpha1" + "github.com/openkruise/rollouts/api/v1beta1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) // NewRolloutCondition creates a new rollout condition. -func NewRolloutCondition(condType v1alpha1.RolloutConditionType, status corev1.ConditionStatus, reason, message string) *v1alpha1.RolloutCondition { - return &v1alpha1.RolloutCondition{ +func NewRolloutCondition(condType v1beta1.RolloutConditionType, status corev1.ConditionStatus, reason, message string) *v1beta1.RolloutCondition { + return &v1beta1.RolloutCondition{ Type: condType, Status: status, LastUpdateTime: metav1.Now(), @@ -35,7 +35,7 @@ func NewRolloutCondition(condType v1alpha1.RolloutConditionType, status corev1.C } // GetRolloutCondition returns the condition with the provided type. -func GetRolloutCondition(status v1alpha1.RolloutStatus, condType v1alpha1.RolloutConditionType) *v1alpha1.RolloutCondition { +func GetRolloutCondition(status v1beta1.RolloutStatus, condType v1beta1.RolloutConditionType) *v1beta1.RolloutCondition { for i := range status.Conditions { c := status.Conditions[i] if c.Type == condType { @@ -48,7 +48,7 @@ func GetRolloutCondition(status v1alpha1.RolloutStatus, condType v1alpha1.Rollou // SetRolloutCondition updates the rollout to include the provided condition. If the condition that // we are about to add already exists and has the same status and reason, then we are not going to update // by returning false. Returns true if the condition was updated -func SetRolloutCondition(status *v1alpha1.RolloutStatus, condition v1alpha1.RolloutCondition) bool { +func SetRolloutCondition(status *v1beta1.RolloutStatus, condition v1beta1.RolloutCondition) bool { currentCond := GetRolloutCondition(*status, condition.Type) if currentCond != nil && currentCond.Status == condition.Status && currentCond.Reason == condition.Reason && currentCond.Message == condition.Message { @@ -64,8 +64,8 @@ func SetRolloutCondition(status *v1alpha1.RolloutStatus, condition v1alpha1.Roll } // filterOutCondition returns a new slice of rollout conditions without conditions with the provided type. -func filterOutCondition(conditions []v1alpha1.RolloutCondition, condType v1alpha1.RolloutConditionType) []v1alpha1.RolloutCondition { - var newConditions []v1alpha1.RolloutCondition +func filterOutCondition(conditions []v1beta1.RolloutCondition, condType v1beta1.RolloutConditionType) []v1beta1.RolloutCondition { + var newConditions []v1beta1.RolloutCondition for _, c := range conditions { if c.Type == condType { continue @@ -75,6 +75,6 @@ func filterOutCondition(conditions []v1alpha1.RolloutCondition, condType v1alpha return newConditions } -func RemoveRolloutCondition(status *v1alpha1.RolloutStatus, condType v1alpha1.RolloutConditionType) { +func RemoveRolloutCondition(status *v1beta1.RolloutStatus, condType v1beta1.RolloutConditionType) { status.Conditions = filterOutCondition(status.Conditions, condType) } diff --git a/pkg/util/constant.go b/pkg/util/constant.go index 02ff7226..c3be2d0f 100644 --- a/pkg/util/constant.go +++ b/pkg/util/constant.go @@ -19,7 +19,7 @@ package util import ( "fmt" - "github.com/openkruise/rollouts/api/v1alpha1" + "github.com/openkruise/rollouts/api/v1beta1" ) // For Rollout and BatchRelease @@ -78,5 +78,5 @@ type WorkloadType string type FinalizerOpType string func ProgressingRolloutFinalizer(name string) string { - return fmt.Sprintf("%s/%s", v1alpha1.ProgressingRolloutFinalizerPrefix, name) + return fmt.Sprintf("%s/%s", v1beta1.ProgressingRolloutFinalizerPrefix, name) } diff --git a/pkg/util/controller_finder.go b/pkg/util/controller_finder.go index cc16baf8..938b1f92 100644 --- a/pkg/util/controller_finder.go +++ b/pkg/util/controller_finder.go @@ -23,7 +23,7 @@ import ( appsv1alpha1 "github.com/openkruise/kruise-api/apps/v1alpha1" appsv1beta1 "github.com/openkruise/kruise-api/apps/v1beta1" - rolloutv1alpha1 "github.com/openkruise/rollouts/api/v1alpha1" + rolloutv1beta1 "github.com/openkruise/rollouts/api/v1beta1" utilclient "github.com/openkruise/rollouts/pkg/util/client" apps "k8s.io/api/apps/v1" "k8s.io/apimachinery/pkg/api/errors" @@ -65,7 +65,7 @@ type Workload struct { // ControllerFinderFunc is a function type that maps a pod to a list of // controllers and their scale. -type ControllerFinderFunc func(namespace string, ref *rolloutv1alpha1.WorkloadRef) (*Workload, error) +type ControllerFinderFunc func(namespace string, ref *rolloutv1beta1.WorkloadRef) (*Workload, error) type ControllerFinder struct { client.Client @@ -84,21 +84,21 @@ func NewControllerFinder(c client.Client) *ControllerFinder { // +kubebuilder:rbac:groups=apps,resources=replicasets,verbs=get;list;watch;create;update;patch;delete // +kubebuilder:rbac:groups=apps,resources=replicasets/status,verbs=get;update;patch -func (r *ControllerFinder) GetWorkloadForRef(rollout *rolloutv1alpha1.Rollout) (*Workload, error) { +func (r *ControllerFinder) GetWorkloadForRef(rollout *rolloutv1beta1.Rollout) (*Workload, error) { workloadRef := rollout.Spec.ObjectRef.WorkloadRef if workloadRef == nil { return nil, nil } - switch strings.ToLower(rollout.Annotations[rolloutv1alpha1.RolloutStyleAnnotation]) { - case strings.ToLower(string(rolloutv1alpha1.PartitionRollingStyle)): + switch strings.ToLower(rollout.Annotations[rolloutv1beta1.RolloutStyleAnnotation]) { + case strings.ToLower(string(rolloutv1beta1.PartitionRollingStyle)): for _, finder := range r.partitionStyleFinders() { workload, err := finder(rollout.Namespace, workloadRef) if workload != nil || err != nil { return workload, err } } - case strings.ToLower(string(rolloutv1alpha1.CanaryRollingStyle)): + case strings.ToLower(string(rolloutv1beta1.CanaryRollingStyle)): for _, finder := range r.canaryStyleFinders() { workload, err := finder(rollout.Namespace, workloadRef) if workload != nil || err != nil { @@ -137,7 +137,7 @@ var ( ) // getKruiseCloneSet returns the kruise cloneSet referenced by the provided controllerRef. -func (r *ControllerFinder) getKruiseCloneSet(namespace string, ref *rolloutv1alpha1.WorkloadRef) (*Workload, error) { +func (r *ControllerFinder) getKruiseCloneSet(namespace string, ref *rolloutv1beta1.WorkloadRef) (*Workload, error) { // This error is irreversible, so there is no need to return error ok, _ := verifyGroupKind(ref, ControllerKruiseKindCS.Kind, []string{ControllerKruiseKindCS.Group}) if !ok { @@ -179,7 +179,7 @@ func (r *ControllerFinder) getKruiseCloneSet(namespace string, ref *rolloutv1alp return workload, nil } -func (r *ControllerFinder) getKruiseDaemonSet(namespace string, ref *rolloutv1alpha1.WorkloadRef) (*Workload, error) { +func (r *ControllerFinder) getKruiseDaemonSet(namespace string, ref *rolloutv1beta1.WorkloadRef) (*Workload, error) { // This error is irreversible, so there is no need to return error ok, _ := verifyGroupKind(ref, ControllerKruiseKindDS.Kind, []string{ControllerKruiseKindDS.Group}) if !ok { @@ -223,7 +223,7 @@ func (r *ControllerFinder) getKruiseDaemonSet(namespace string, ref *rolloutv1al } // getPartitionStyleDeployment returns the Advanced Deployment referenced by the provided controllerRef. -func (r *ControllerFinder) getAdvancedDeployment(namespace string, ref *rolloutv1alpha1.WorkloadRef) (*Workload, error) { +func (r *ControllerFinder) getAdvancedDeployment(namespace string, ref *rolloutv1beta1.WorkloadRef) (*Workload, error) { // This error is irreversible, so there is no need to return error ok, _ := verifyGroupKind(ref, ControllerKindDep.Kind, []string{ControllerKindDep.Group}) if !ok { @@ -242,7 +242,7 @@ func (r *ControllerFinder) getAdvancedDeployment(namespace string, ref *rolloutv return &Workload{IsStatusConsistent: false}, nil } - stableRevision := deployment.Labels[rolloutv1alpha1.DeploymentStableRevisionLabel] + stableRevision := deployment.Labels[rolloutv1beta1.DeploymentStableRevisionLabel] workload := &Workload{ RevisionLabelKey: apps.DefaultDeploymentUniqueLabelKey, @@ -277,7 +277,7 @@ func (r *ControllerFinder) getAdvancedDeployment(namespace string, ref *rolloutv } // getDeployment returns the k8s native deployment referenced by the provided controllerRef. -func (r *ControllerFinder) getDeployment(namespace string, ref *rolloutv1alpha1.WorkloadRef) (*Workload, error) { +func (r *ControllerFinder) getDeployment(namespace string, ref *rolloutv1beta1.WorkloadRef) (*Workload, error) { // This error is irreversible, so there is no need to return error ok, _ := verifyGroupKind(ref, ControllerKindDep.Kind, []string{ControllerKindDep.Group}) if !ok { @@ -334,7 +334,7 @@ func (r *ControllerFinder) getDeployment(namespace string, ref *rolloutv1alpha1. return workload, err } -func (r *ControllerFinder) getStatefulSetLikeWorkload(namespace string, ref *rolloutv1alpha1.WorkloadRef) (*Workload, error) { +func (r *ControllerFinder) getStatefulSetLikeWorkload(namespace string, ref *rolloutv1beta1.WorkloadRef) (*Workload, error) { if ref == nil { return nil, nil } @@ -445,7 +445,7 @@ func (r *ControllerFinder) getDeploymentStableRs(obj *apps.Deployment) (*apps.Re return rss[0], nil } -func verifyGroupKind(ref *rolloutv1alpha1.WorkloadRef, expectedKind string, expectedGroups []string) (bool, error) { +func verifyGroupKind(ref *rolloutv1beta1.WorkloadRef, expectedKind string, expectedGroups []string) (bool, error) { gv, err := schema.ParseGroupVersion(ref.APIVersion) if err != nil { return false, err diff --git a/pkg/util/luamanager/lua_test.go b/pkg/util/luamanager/lua_test.go index 3926ae8b..86d97430 100644 --- a/pkg/util/luamanager/lua_test.go +++ b/pkg/util/luamanager/lua_test.go @@ -21,7 +21,7 @@ import ( "fmt" "testing" - rolloutv1alpha1 "github.com/openkruise/rollouts/api/v1alpha1" + rolloutv1beta1 "github.com/openkruise/rollouts/api/v1beta1" "github.com/openkruise/rollouts/pkg/util" lua "github.com/yuin/gopher-lua" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" @@ -43,14 +43,14 @@ func TestRunLuaScript(t *testing.T) { type LuaData struct { Annotations map[string]string Weight string - Matches []rolloutv1alpha1.HttpRouteMatch + Matches []rolloutv1beta1.HttpRouteMatch } data := &LuaData{ Annotations: map[string]string{ "kubernetes.io/ingress.class": "nginx", }, Weight: "0", - Matches: []rolloutv1alpha1.HttpRouteMatch{ + Matches: []rolloutv1beta1.HttpRouteMatch{ { Headers: []gatewayv1alpha2.HTTPHeaderMatch{ { diff --git a/pkg/util/rollout_utils.go b/pkg/util/rollout_utils.go index 090c6783..58b0c9a1 100644 --- a/pkg/util/rollout_utils.go +++ b/pkg/util/rollout_utils.go @@ -26,7 +26,7 @@ import ( kruiseappsv1alpha1 "github.com/openkruise/kruise-api/apps/v1alpha1" kruiseappsv1beta1 "github.com/openkruise/kruise-api/apps/v1beta1" - rolloutv1alpha1 "github.com/openkruise/rollouts/api/v1alpha1" + rolloutv1beta1 "github.com/openkruise/rollouts/api/v1beta1" "github.com/openkruise/rollouts/pkg/util/client" apps "k8s.io/api/apps/v1" "k8s.io/apimachinery/pkg/api/errors" @@ -44,7 +44,7 @@ type RolloutState struct { RolloutName string `json:"rolloutName"` } -func IsRollbackInBatchPolicy(rollout *rolloutv1alpha1.Rollout, labels map[string]string) bool { +func IsRollbackInBatchPolicy(rollout *rolloutv1beta1.Rollout, labels map[string]string) bool { // currently, only support the case of no traffic routing if len(rollout.Spec.Strategy.Canary.TrafficRoutings) > 0 { return false @@ -54,7 +54,7 @@ func IsRollbackInBatchPolicy(rollout *rolloutv1alpha1.Rollout, labels map[string if workloadRef.Kind == ControllerKindSts.Kind || workloadRef.Kind == ControllerKruiseKindCS.Kind || strings.EqualFold(labels[WorkloadTypeLabel], ControllerKindSts.Kind) { - if rollout.Annotations[rolloutv1alpha1.RollbackInBatchAnnotation] == "true" { + if rollout.Annotations[rolloutv1beta1.RollbackInBatchAnnotation] == "true" { return true } } @@ -130,7 +130,7 @@ func DiscoverGVK(gvk schema.GroupVersionKind) bool { return true } -func GetGVKFrom(workloadRef *rolloutv1alpha1.WorkloadRef) schema.GroupVersionKind { +func GetGVKFrom(workloadRef *rolloutv1beta1.WorkloadRef) schema.GroupVersionKind { if workloadRef == nil { return schema.GroupVersionKind{} } @@ -148,7 +148,7 @@ func AddWatcherDynamically(c controller.Controller, h handler.EventHandler, gvk return true, c.Watch(&source.Kind{Type: object}, h) } -func HashReleasePlanBatches(releasePlan *rolloutv1alpha1.ReleasePlan) string { +func HashReleasePlanBatches(releasePlan *rolloutv1beta1.ReleasePlan) string { by, _ := json.Marshal(releasePlan) md5Hash := sha256.Sum256(by) return hex.EncodeToString(md5Hash[:]) diff --git a/pkg/util/workloads_utils.go b/pkg/util/workloads_utils.go index 86bc8659..b81ec55f 100644 --- a/pkg/util/workloads_utils.go +++ b/pkg/util/workloads_utils.go @@ -30,7 +30,7 @@ import ( "github.com/davecgh/go-spew/spew" appsv1alpha1 "github.com/openkruise/kruise-api/apps/v1alpha1" appsv1beta1 "github.com/openkruise/kruise-api/apps/v1beta1" - "github.com/openkruise/rollouts/api/v1alpha1" + "github.com/openkruise/rollouts/api/v1beta1" "github.com/openkruise/rollouts/pkg/feature" apps "k8s.io/api/apps/v1" v1 "k8s.io/api/core/v1" @@ -404,12 +404,12 @@ func GetEmptyObjectWithKey(object client.Object) client.Object { // GetDeploymentStrategy decode the strategy object for advanced deployment // from the annotation rollouts.kruise.io/deployment-strategy -func GetDeploymentStrategy(deployment *apps.Deployment) v1alpha1.DeploymentStrategy { - strategy := v1alpha1.DeploymentStrategy{} +func GetDeploymentStrategy(deployment *apps.Deployment) v1beta1.DeploymentStrategy { + strategy := v1beta1.DeploymentStrategy{} if deployment == nil { return strategy } - strategyStr := deployment.Annotations[v1alpha1.DeploymentStrategyAnnotation] + strategyStr := deployment.Annotations[v1beta1.DeploymentStrategyAnnotation] if strategyStr == "" { return strategy } @@ -419,12 +419,12 @@ func GetDeploymentStrategy(deployment *apps.Deployment) v1alpha1.DeploymentStrat // GetDeploymentExtraStatus decode the extra-status object for advanced deployment // from the annotation rollouts.kruise.io/deployment-extra-status -func GetDeploymentExtraStatus(deployment *apps.Deployment) v1alpha1.DeploymentExtraStatus { - extraStatus := v1alpha1.DeploymentExtraStatus{} +func GetDeploymentExtraStatus(deployment *apps.Deployment) v1beta1.DeploymentExtraStatus { + extraStatus := v1beta1.DeploymentExtraStatus{} if deployment == nil { return extraStatus } - extraStatusStr := deployment.Annotations[v1alpha1.DeploymentExtraStatusAnnotation] + extraStatusStr := deployment.Annotations[v1beta1.DeploymentExtraStatusAnnotation] if extraStatusStr == "" { return extraStatus } diff --git a/pkg/util/workloads_utils_test.go b/pkg/util/workloads_utils_test.go index a9aca549..8acf0eba 100644 --- a/pkg/util/workloads_utils_test.go +++ b/pkg/util/workloads_utils_test.go @@ -25,7 +25,7 @@ import ( . "github.com/onsi/gomega" kruiseappsv1alpha1 "github.com/openkruise/kruise-api/apps/v1alpha1" appsv1beta1 "github.com/openkruise/kruise-api/apps/v1beta1" - appsv1alpha1 "github.com/openkruise/rollouts/api/v1alpha1" + rolloutsv1beta1 "github.com/openkruise/rollouts/api/v1beta1" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -41,7 +41,7 @@ func init() { scheme = runtime.NewScheme() _ = appsv1.AddToScheme(scheme) _ = appsv1beta1.AddToScheme(scheme) - _ = appsv1alpha1.AddToScheme(scheme) + _ = rolloutsv1beta1.AddToScheme(scheme) _ = kruiseappsv1alpha1.AddToScheme(scheme) } diff --git a/pkg/webhook/rollout/validating/rollout_create_update_handler.go b/pkg/webhook/rollout/validating/rollout_create_update_handler.go index b9f90b54..ef12f571 100644 --- a/pkg/webhook/rollout/validating/rollout_create_update_handler.go +++ b/pkg/webhook/rollout/validating/rollout_create_update_handler.go @@ -24,6 +24,7 @@ import ( "strings" appsv1alpha1 "github.com/openkruise/rollouts/api/v1alpha1" + appsv1beta1 "github.com/openkruise/rollouts/api/v1beta1" "github.com/openkruise/rollouts/pkg/util" utilclient "github.com/openkruise/rollouts/pkg/util/client" addmissionv1 "k8s.io/api/admission/v1" @@ -53,8 +54,8 @@ var _ admission.Handler = &RolloutCreateUpdateHandler{} func (h *RolloutCreateUpdateHandler) Handle(ctx context.Context, req admission.Request) admission.Response { switch req.Operation { case addmissionv1.Create: - obj := &appsv1alpha1.Rollout{} - if err := h.Decoder.Decode(req, obj); err != nil { + obj := &appsv1beta1.Rollout{} + if err := h.decodeObject(req, obj); err != nil { return admission.Errored(http.StatusBadRequest, err) } errList := h.validateRollout(obj) @@ -63,16 +64,16 @@ func (h *RolloutCreateUpdateHandler) Handle(ctx context.Context, req admission.R } case addmissionv1.Update: - obj := &appsv1alpha1.Rollout{} - if err := h.Decoder.Decode(req, obj); err != nil { + obj := &appsv1beta1.Rollout{} + if err := h.decodeObject(req, obj); err != nil { return admission.Errored(http.StatusBadRequest, err) } errList := h.validateRollout(obj) if len(errList) != 0 { return admission.Errored(http.StatusUnprocessableEntity, errList.ToAggregate()) } - oldObj := &appsv1alpha1.Rollout{} - if err := h.Decoder.DecodeRaw(req.AdmissionRequest.OldObject, oldObj); err != nil { + oldObj := &appsv1beta1.Rollout{} + if err := h.decodeOldObject(req, oldObj); err != nil { return admission.Errored(http.StatusBadRequest, err) } errList = h.validateRolloutUpdate(oldObj, obj) @@ -84,8 +85,44 @@ func (h *RolloutCreateUpdateHandler) Handle(ctx context.Context, req admission.R return admission.ValidationResponse(true, "") } -func (h *RolloutCreateUpdateHandler) validateRolloutUpdate(oldObj, newObj *appsv1alpha1.Rollout) field.ErrorList { - latestObject := &appsv1alpha1.Rollout{} +func (h *RolloutCreateUpdateHandler) decodeObject(req admission.Request, obj *appsv1beta1.Rollout) error { + switch req.AdmissionRequest.Resource.Version { + case appsv1beta1.GroupVersion.Version: + if err := h.Decoder.Decode(req, obj); err != nil { + return err + } + case appsv1alpha1.GroupVersion.Version: + objv1alpha1 := &appsv1alpha1.Rollout{} + if err := h.Decoder.Decode(req, objv1alpha1); err != nil { + return err + } + if err := objv1alpha1.ConvertTo(obj); err != nil { + return fmt.Errorf("failed to convert v1alpha1->v1beta1: %v", err) + } + } + return nil +} + +func (h *RolloutCreateUpdateHandler) decodeOldObject(req admission.Request, oldObj *appsv1beta1.Rollout) error { + switch req.AdmissionRequest.Resource.Version { + case appsv1beta1.GroupVersion.Version: + if err := h.Decoder.DecodeRaw(req.AdmissionRequest.OldObject, oldObj); err != nil { + return err + } + case appsv1alpha1.GroupVersion.Version: + objv1alpha1 := &appsv1alpha1.Rollout{} + if err := h.Decoder.DecodeRaw(req.AdmissionRequest.OldObject, objv1alpha1); err != nil { + return err + } + if err := objv1alpha1.ConvertTo(oldObj); err != nil { + return fmt.Errorf("failed to convert v1alpha1->v1beta1: %v", err) + } + } + return nil +} + +func (h *RolloutCreateUpdateHandler) validateRolloutUpdate(oldObj, newObj *appsv1beta1.Rollout) field.ErrorList { + latestObject := &appsv1beta1.Rollout{} err := h.Client.Get(context.TODO(), client.ObjectKeyFromObject(newObj), latestObject) if err != nil { return field.ErrorList{field.InternalError(field.NewPath("Rollout"), err)} @@ -96,7 +133,7 @@ func (h *RolloutCreateUpdateHandler) validateRolloutUpdate(oldObj, newObj *appsv switch latestObject.Status.Phase { // The workloadRef and TrafficRouting are not allowed to be modified in the Progressing, Terminating state - case appsv1alpha1.RolloutPhaseProgressing, appsv1alpha1.RolloutPhaseTerminating: + case appsv1beta1.RolloutPhaseProgressing, appsv1beta1.RolloutPhaseTerminating: if !reflect.DeepEqual(oldObj.Spec.ObjectRef, newObj.Spec.ObjectRef) { return field.ErrorList{field.Forbidden(field.NewPath("Spec.ObjectRef"), "Rollout 'ObjectRef' field is immutable")} } @@ -104,15 +141,15 @@ func (h *RolloutCreateUpdateHandler) validateRolloutUpdate(oldObj, newObj *appsv if !reflect.DeepEqual(oldObj.Spec.Strategy.Canary.TrafficRoutings, newObj.Spec.Strategy.Canary.TrafficRoutings) { return field.ErrorList{field.Forbidden(field.NewPath("Spec.Strategy.Canary.TrafficRoutings"), "Rollout 'Strategy.Canary.TrafficRoutings' field is immutable")} } - if !strings.EqualFold(oldObj.Annotations[appsv1alpha1.RolloutStyleAnnotation], newObj.Annotations[appsv1alpha1.RolloutStyleAnnotation]) { + if !strings.EqualFold(oldObj.Annotations[appsv1beta1.RolloutStyleAnnotation], newObj.Annotations[appsv1beta1.RolloutStyleAnnotation]) { return field.ErrorList{field.Forbidden(field.NewPath("Metadata.Annotation"), "Rollout 'Rolling-Style' annotation is immutable")} } } - /*if newObj.Status.CanaryStatus != nil && newObj.Status.CanaryStatus.CurrentStepState == appsv1alpha1.CanaryStepStateReady { + /*if newObj.Status.CanaryStatus != nil && newObj.Status.CanaryStatus.CurrentStepState == appsv1beta1.CanaryStepStateReady { if oldObj.Status.CanaryStatus != nil { switch oldObj.Status.CanaryStatus.CurrentStepState { - case appsv1alpha1.CanaryStepStateCompleted, appsv1alpha1.CanaryStepStatePaused: + case appsv1beta1.CanaryStepStateCompleted, appsv1beta1.CanaryStepStatePaused: default: return field.ErrorList{field.Forbidden(field.NewPath("Status"), "CanaryStatus.CurrentStepState only allow to translate to 'StepInCompleted' from 'StepInPaused'")} } @@ -122,15 +159,15 @@ func (h *RolloutCreateUpdateHandler) validateRolloutUpdate(oldObj, newObj *appsv return nil } -func (h *RolloutCreateUpdateHandler) validateRollout(rollout *appsv1alpha1.Rollout) field.ErrorList { +func (h *RolloutCreateUpdateHandler) validateRollout(rollout *appsv1beta1.Rollout) field.ErrorList { errList := validateRolloutSpec(rollout, field.NewPath("Spec")) errList = append(errList, h.validateRolloutConflict(rollout, field.NewPath("Conflict Checker"))...) return errList } -func (h *RolloutCreateUpdateHandler) validateRolloutConflict(rollout *appsv1alpha1.Rollout, path *field.Path) field.ErrorList { +func (h *RolloutCreateUpdateHandler) validateRolloutConflict(rollout *appsv1beta1.Rollout, path *field.Path) field.ErrorList { errList := field.ErrorList{} - rolloutList := &appsv1alpha1.RolloutList{} + rolloutList := &appsv1beta1.RolloutList{} err := h.Client.List(context.TODO(), rolloutList, client.InNamespace(rollout.Namespace), utilclient.DisableDeepCopy) if err != nil { return append(errList, field.InternalError(path, err)) @@ -146,18 +183,18 @@ func (h *RolloutCreateUpdateHandler) validateRolloutConflict(rollout *appsv1alph return nil } -func validateRolloutSpec(rollout *appsv1alpha1.Rollout, fldPath *field.Path) field.ErrorList { +func validateRolloutSpec(rollout *appsv1beta1.Rollout, fldPath *field.Path) field.ErrorList { errList := validateRolloutSpecObjectRef(&rollout.Spec.ObjectRef, fldPath.Child("ObjectRef")) errList = append(errList, validateRolloutRollingStyle(rollout, field.NewPath("RollingStyle"))...) errList = append(errList, validateRolloutSpecStrategy(&rollout.Spec.Strategy, fldPath.Child("Strategy"))...) return errList } -func validateRolloutRollingStyle(rollout *appsv1alpha1.Rollout, fldPath *field.Path) field.ErrorList { - switch strings.ToLower(rollout.Annotations[appsv1alpha1.RolloutStyleAnnotation]) { - case "", strings.ToLower(string(appsv1alpha1.CanaryRollingStyle)), strings.ToLower(string(appsv1alpha1.PartitionRollingStyle)): +func validateRolloutRollingStyle(rollout *appsv1beta1.Rollout, fldPath *field.Path) field.ErrorList { + switch strings.ToLower(rollout.Annotations[appsv1beta1.RolloutStyleAnnotation]) { + case "", strings.ToLower(string(appsv1beta1.CanaryRollingStyle)), strings.ToLower(string(appsv1beta1.PartitionRollingStyle)): default: - return field.ErrorList{field.Invalid(fldPath, rollout.Annotations[appsv1alpha1.RolloutStyleAnnotation], + return field.ErrorList{field.Invalid(fldPath, rollout.Annotations[appsv1beta1.RolloutStyleAnnotation], "Rolling style must be 'Canary', 'Partition' or empty")} } @@ -165,14 +202,14 @@ func validateRolloutRollingStyle(rollout *appsv1alpha1.Rollout, fldPath *field.P if workloadRef == nil || workloadRef.Kind == util.ControllerKindDep.Kind { return nil // Deployment support all rolling styles, no need to validate. } - if strings.EqualFold(rollout.Annotations[appsv1alpha1.RolloutStyleAnnotation], string(appsv1alpha1.CanaryRollingStyle)) { - return field.ErrorList{field.Invalid(fldPath, rollout.Annotations[appsv1alpha1.RolloutStyleAnnotation], + if strings.EqualFold(rollout.Annotations[appsv1beta1.RolloutStyleAnnotation], string(appsv1beta1.CanaryRollingStyle)) { + return field.ErrorList{field.Invalid(fldPath, rollout.Annotations[appsv1beta1.RolloutStyleAnnotation], "Only Deployment support canary rolling style")} } return nil } -func validateRolloutSpecObjectRef(objectRef *appsv1alpha1.ObjectRef, fldPath *field.Path) field.ErrorList { +func validateRolloutSpecObjectRef(objectRef *appsv1beta1.ObjectRef, fldPath *field.Path) field.ErrorList { if objectRef.WorkloadRef == nil { return field.ErrorList{field.Invalid(fldPath.Child("WorkloadRef"), objectRef.WorkloadRef, "WorkloadRef is required")} } @@ -184,11 +221,11 @@ func validateRolloutSpecObjectRef(objectRef *appsv1alpha1.ObjectRef, fldPath *fi return nil } -func validateRolloutSpecStrategy(strategy *appsv1alpha1.RolloutStrategy, fldPath *field.Path) field.ErrorList { +func validateRolloutSpecStrategy(strategy *appsv1beta1.RolloutStrategy, fldPath *field.Path) field.ErrorList { return validateRolloutSpecCanaryStrategy(strategy.Canary, fldPath.Child("Canary")) } -func validateRolloutSpecCanaryStrategy(canary *appsv1alpha1.CanaryStrategy, fldPath *field.Path) field.ErrorList { +func validateRolloutSpecCanaryStrategy(canary *appsv1beta1.CanaryStrategy, fldPath *field.Path) field.ErrorList { if canary == nil { return field.ErrorList{field.Invalid(fldPath, nil, "Canary cannot be empty")} } @@ -203,7 +240,7 @@ func validateRolloutSpecCanaryStrategy(canary *appsv1alpha1.CanaryStrategy, fldP return errList } -func validateRolloutSpecCanaryTraffic(traffic appsv1alpha1.TrafficRoutingRef, fldPath *field.Path) field.ErrorList { +func validateRolloutSpecCanaryTraffic(traffic appsv1beta1.TrafficRoutingRef, fldPath *field.Path) field.ErrorList { errList := field.ErrorList{} if len(traffic.Service) == 0 { errList = append(errList, field.Invalid(fldPath.Child("Service"), traffic.Service, "TrafficRouting.Service cannot be empty")) @@ -227,7 +264,7 @@ func validateRolloutSpecCanaryTraffic(traffic appsv1alpha1.TrafficRoutingRef, fl return errList } -func validateRolloutSpecCanarySteps(steps []appsv1alpha1.CanaryStep, fldPath *field.Path, isTraffic bool) field.ErrorList { +func validateRolloutSpecCanarySteps(steps []appsv1beta1.CanaryStep, fldPath *field.Path, isTraffic bool) field.ErrorList { stepCount := len(steps) if stepCount == 0 { return field.ErrorList{field.Invalid(fldPath, steps, "The number of Canary.Steps cannot be empty")} @@ -281,7 +318,7 @@ func IsPercentageCanaryReplicasType(replicas *intstr.IntOrString) bool { return replicas == nil || replicas.Type == intstr.String } -func IsSameWorkloadRefGVKName(a, b *appsv1alpha1.WorkloadRef) bool { +func IsSameWorkloadRefGVKName(a, b *appsv1beta1.WorkloadRef) bool { if a == nil || b == nil { return false } diff --git a/pkg/webhook/rollout/validating/rollout_create_update_handler_test.go b/pkg/webhook/rollout/validating/rollout_create_update_handler_test.go index ce181dab..2c2d1163 100644 --- a/pkg/webhook/rollout/validating/rollout_create_update_handler_test.go +++ b/pkg/webhook/rollout/validating/rollout_create_update_handler_test.go @@ -21,7 +21,7 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - appsv1alpha1 "github.com/openkruise/rollouts/api/v1alpha1" + appsv1beta1 "github.com/openkruise/rollouts/api/v1beta1" apps "k8s.io/api/apps/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" @@ -34,9 +34,9 @@ import ( var ( scheme = runtime.NewScheme() - rollout = appsv1alpha1.Rollout{ + rollout = appsv1beta1.Rollout{ TypeMeta: metav1.TypeMeta{ - APIVersion: appsv1alpha1.SchemeGroupVersion.String(), + APIVersion: appsv1beta1.SchemeGroupVersion.String(), Kind: "Rollout", }, ObjectMeta: metav1.ObjectMeta{ @@ -44,57 +44,57 @@ var ( Namespace: "namespace-unit-test", Annotations: map[string]string{}, }, - Spec: appsv1alpha1.RolloutSpec{ - ObjectRef: appsv1alpha1.ObjectRef{ - WorkloadRef: &appsv1alpha1.WorkloadRef{ + Spec: appsv1beta1.RolloutSpec{ + ObjectRef: appsv1beta1.ObjectRef{ + WorkloadRef: &appsv1beta1.WorkloadRef{ APIVersion: apps.SchemeGroupVersion.String(), Kind: "Deployment", Name: "deployment-demo", }, }, - Strategy: appsv1alpha1.RolloutStrategy{ - Canary: &appsv1alpha1.CanaryStrategy{ - Steps: []appsv1alpha1.CanaryStep{ + Strategy: appsv1beta1.RolloutStrategy{ + Canary: &appsv1beta1.CanaryStrategy{ + Steps: []appsv1beta1.CanaryStep{ { - TrafficRoutingStrategy: appsv1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: appsv1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(10), }, Replicas: &intstr.IntOrString{Type: intstr.Int, IntVal: int32(1)}, - Pause: appsv1alpha1.RolloutPause{}, + Pause: appsv1beta1.RolloutPause{}, }, { - TrafficRoutingStrategy: appsv1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: appsv1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(10), }, Replicas: &intstr.IntOrString{Type: intstr.Int, IntVal: int32(3)}, - Pause: appsv1alpha1.RolloutPause{Duration: utilpointer.Int32(1 * 24 * 60 * 60)}, + Pause: appsv1beta1.RolloutPause{Duration: utilpointer.Int32(1 * 24 * 60 * 60)}, }, { - TrafficRoutingStrategy: appsv1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: appsv1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(30), }, - Pause: appsv1alpha1.RolloutPause{Duration: utilpointer.Int32(7 * 24 * 60 * 60)}, + Pause: appsv1beta1.RolloutPause{Duration: utilpointer.Int32(7 * 24 * 60 * 60)}, }, { - TrafficRoutingStrategy: appsv1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: appsv1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(100), }, }, { - TrafficRoutingStrategy: appsv1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: appsv1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(101), }, }, { - TrafficRoutingStrategy: appsv1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: appsv1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(200), }, }, }, - TrafficRoutings: []appsv1alpha1.TrafficRoutingRef{ + TrafficRoutings: []appsv1beta1.TrafficRoutingRef{ { Service: "service-demo", - Ingress: &appsv1alpha1.IngressTrafficRouting{ + Ingress: &appsv1beta1.IngressTrafficRouting{ ClassType: "nginx", Name: "ingress-nginx-demo", }, @@ -103,16 +103,16 @@ var ( }, }, }, - Status: appsv1alpha1.RolloutStatus{ - CanaryStatus: &appsv1alpha1.CanaryStatus{ - CurrentStepState: appsv1alpha1.CanaryStepStateCompleted, + Status: appsv1beta1.RolloutStatus{ + CanaryStatus: &appsv1beta1.CanaryStatus{ + CurrentStepState: appsv1beta1.CanaryStepStateCompleted, }, }, } ) func init() { - _ = appsv1alpha1.AddToScheme(scheme) + _ = appsv1beta1.AddToScheme(scheme) } func TestRolloutValidateCreate(t *testing.T) { @@ -177,7 +177,7 @@ func TestRolloutValidateCreate(t *testing.T) { Succeed: false, GetObject: func() []client.Object { object := rollout.DeepCopy() - object.Spec.Strategy.Canary.Steps = []appsv1alpha1.CanaryStep{} + object.Spec.Strategy.Canary.Steps = []appsv1beta1.CanaryStep{} return []client.Object{object} }, }, @@ -186,7 +186,7 @@ func TestRolloutValidateCreate(t *testing.T) { Succeed: true, GetObject: func() []client.Object { object := rollout.DeepCopy() - object.Spec.ObjectRef.WorkloadRef = &appsv1alpha1.WorkloadRef{ + object.Spec.ObjectRef.WorkloadRef = &appsv1beta1.WorkloadRef{ APIVersion: "apps/v1", Kind: "StatefulSet", Name: "whatever", @@ -263,7 +263,7 @@ func TestRolloutValidateCreate(t *testing.T) { GetObject: func() []client.Object { object := rollout.DeepCopy() object.Annotations = map[string]string{ - appsv1alpha1.RolloutStyleAnnotation: "Canary", + appsv1beta1.RolloutStyleAnnotation: "Canary", } return []client.Object{object} }, @@ -274,7 +274,7 @@ func TestRolloutValidateCreate(t *testing.T) { GetObject: func() []client.Object { object := rollout.DeepCopy() object.Annotations = map[string]string{ - appsv1alpha1.RolloutStyleAnnotation: "Partition", + appsv1beta1.RolloutStyleAnnotation: "Partition", } return []client.Object{object} }, @@ -285,7 +285,7 @@ func TestRolloutValidateCreate(t *testing.T) { GetObject: func() []client.Object { object := rollout.DeepCopy() object.Annotations = map[string]string{ - appsv1alpha1.RolloutStyleAnnotation: "Other", + appsv1beta1.RolloutStyleAnnotation: "Other", } return []client.Object{object} }, @@ -296,7 +296,7 @@ func TestRolloutValidateCreate(t *testing.T) { GetObject: func() []client.Object { object := rollout.DeepCopy() object.Annotations = map[string]string{ - appsv1alpha1.RolloutStyleAnnotation: "Canary", + appsv1beta1.RolloutStyleAnnotation: "Canary", } object.Spec.ObjectRef.WorkloadRef.APIVersion = "apps.kruise.io/v1alpha1" object.Spec.ObjectRef.WorkloadRef.Kind = "CloneSet" @@ -373,7 +373,7 @@ func TestRolloutValidateCreate(t *testing.T) { handler := RolloutCreateUpdateHandler{ Client: cli, } - errList := handler.validateRollout(objects[0].(*appsv1alpha1.Rollout)) + errList := handler.validateRollout(objects[0].(*appsv1beta1.Rollout)) t.Log(errList) Expect(len(errList) == 0).Should(Equal(cs.Succeed)) }) @@ -407,12 +407,12 @@ func TestRolloutValidateUpdate(t *testing.T) { Succeed: true, GetOldObject: func() client.Object { object := rollout.DeepCopy() - object.Status.Phase = appsv1alpha1.RolloutPhaseProgressing + object.Status.Phase = appsv1beta1.RolloutPhaseProgressing return object }, GetNewObject: func() client.Object { object := rollout.DeepCopy() - object.Status.Phase = appsv1alpha1.RolloutPhaseProgressing + object.Status.Phase = appsv1beta1.RolloutPhaseProgressing object.Status.CanaryStatus.CurrentStepIndex = 1 return object }, @@ -422,12 +422,12 @@ func TestRolloutValidateUpdate(t *testing.T) { Succeed: true, GetOldObject: func() client.Object { object := rollout.DeepCopy() - object.Status.Phase = appsv1alpha1.RolloutPhaseProgressing + object.Status.Phase = appsv1beta1.RolloutPhaseProgressing return object }, GetNewObject: func() client.Object { object := rollout.DeepCopy() - object.Status.Phase = appsv1alpha1.RolloutPhaseProgressing + object.Status.Phase = appsv1beta1.RolloutPhaseProgressing object.Spec.Strategy.Canary.Steps[0].Weight = utilpointer.Int32Ptr(5) return object }, @@ -437,14 +437,14 @@ func TestRolloutValidateUpdate(t *testing.T) { Succeed: false, GetOldObject: func() client.Object { object := rollout.DeepCopy() - object.Annotations[appsv1alpha1.RolloutStyleAnnotation] = "Partition" - object.Status.Phase = appsv1alpha1.RolloutPhaseProgressing + object.Annotations[appsv1beta1.RolloutStyleAnnotation] = "Partition" + object.Status.Phase = appsv1beta1.RolloutPhaseProgressing return object }, GetNewObject: func() client.Object { object := rollout.DeepCopy() - object.Status.Phase = appsv1alpha1.RolloutPhaseProgressing - object.Annotations[appsv1alpha1.RolloutStyleAnnotation] = "Canary" + object.Status.Phase = appsv1beta1.RolloutPhaseProgressing + object.Annotations[appsv1beta1.RolloutStyleAnnotation] = "Canary" return object }, }, @@ -453,12 +453,12 @@ func TestRolloutValidateUpdate(t *testing.T) { Succeed: false, GetOldObject: func() client.Object { object := rollout.DeepCopy() - object.Status.Phase = appsv1alpha1.RolloutPhaseTerminating + object.Status.Phase = appsv1beta1.RolloutPhaseTerminating return object }, GetNewObject: func() client.Object { object := rollout.DeepCopy() - object.Status.Phase = appsv1alpha1.RolloutPhaseTerminating + object.Status.Phase = appsv1beta1.RolloutPhaseTerminating object.Spec.Strategy.Canary.TrafficRoutings[0].Ingress.ClassType = "alb" return object }, @@ -468,12 +468,12 @@ func TestRolloutValidateUpdate(t *testing.T) { Succeed: true, GetOldObject: func() client.Object { object := rollout.DeepCopy() - object.Status.Phase = appsv1alpha1.RolloutPhaseInitial + object.Status.Phase = appsv1beta1.RolloutPhaseInitial return object }, GetNewObject: func() client.Object { object := rollout.DeepCopy() - object.Status.Phase = appsv1alpha1.RolloutPhaseInitial + object.Status.Phase = appsv1beta1.RolloutPhaseInitial object.Spec.Strategy.Canary.Steps[0].Weight = utilpointer.Int32Ptr(5) return object }, @@ -483,12 +483,12 @@ func TestRolloutValidateUpdate(t *testing.T) { Succeed: true, GetOldObject: func() client.Object { object := rollout.DeepCopy() - object.Status.Phase = appsv1alpha1.RolloutPhaseHealthy + object.Status.Phase = appsv1beta1.RolloutPhaseHealthy return object }, GetNewObject: func() client.Object { object := rollout.DeepCopy() - object.Status.Phase = appsv1alpha1.RolloutPhaseHealthy + object.Status.Phase = appsv1beta1.RolloutPhaseHealthy object.Spec.Strategy.Canary.Steps[0].Weight = utilpointer.Int32Ptr(5) return object }, @@ -498,12 +498,12 @@ func TestRolloutValidateUpdate(t *testing.T) { Succeed: true, GetOldObject: func() client.Object { object := rollout.DeepCopy() - object.Status.CanaryStatus.CurrentStepState = appsv1alpha1.CanaryStepStatePaused + object.Status.CanaryStatus.CurrentStepState = appsv1beta1.CanaryStepStatePaused return object }, GetNewObject: func() client.Object { object := rollout.DeepCopy() - object.Status.CanaryStatus.CurrentStepState = appsv1alpha1.CanaryStepStateCompleted + object.Status.CanaryStatus.CurrentStepState = appsv1beta1.CanaryStepStateCompleted return object }, }, @@ -512,12 +512,12 @@ func TestRolloutValidateUpdate(t *testing.T) { Succeed: true, GetOldObject: func() client.Object { object := rollout.DeepCopy() - object.Status.CanaryStatus.CurrentStepState = appsv1alpha1.CanaryStepStateCompleted + object.Status.CanaryStatus.CurrentStepState = appsv1beta1.CanaryStepStateCompleted return object }, GetNewObject: func() client.Object { object := rollout.DeepCopy() - object.Status.CanaryStatus.CurrentStepState = appsv1alpha1.CanaryStepStateCompleted + object.Status.CanaryStatus.CurrentStepState = appsv1beta1.CanaryStepStateCompleted return object }, }, @@ -526,12 +526,12 @@ func TestRolloutValidateUpdate(t *testing.T) { Succeed: false, GetOldObject: func() client.Object { object := rollout.DeepCopy() - object.Status.CanaryStatus.CurrentStepState = appsv1alpha1.CanaryStepStateUpgrade + object.Status.CanaryStatus.CurrentStepState = appsv1beta1.CanaryStepStateUpgrade return object }, GetNewObject: func() client.Object { object := rollout.DeepCopy() - object.Status.CanaryStatus.CurrentStepState = appsv1alpha1.CanaryStepStateCompleted + object.Status.CanaryStatus.CurrentStepState = appsv1beta1.CanaryStepStateCompleted return object }, }, @@ -540,12 +540,12 @@ func TestRolloutValidateUpdate(t *testing.T) { Succeed: false, GetOldObject: func() client.Object { object := rollout.DeepCopy() - object.Status.CanaryStatus.CurrentStepState = appsv1alpha1.CanaryStepStateTrafficRouting + object.Status.CanaryStatus.CurrentStepState = appsv1beta1.CanaryStepStateTrafficRouting return object }, GetNewObject: func() client.Object { object := rollout.DeepCopy() - object.Status.CanaryStatus.CurrentStepState = appsv1alpha1.CanaryStepStateCompleted + object.Status.CanaryStatus.CurrentStepState = appsv1beta1.CanaryStepStateCompleted return object }, }, @@ -554,12 +554,12 @@ func TestRolloutValidateUpdate(t *testing.T) { Succeed: false, GetOldObject: func() client.Object { object := rollout.DeepCopy() - object.Status.CanaryStatus.CurrentStepState = appsv1alpha1.CanaryStepStateMetricsAnalysis + object.Status.CanaryStatus.CurrentStepState = appsv1beta1.CanaryStepStateMetricsAnalysis return object }, GetNewObject: func() client.Object { object := rollout.DeepCopy() - object.Status.CanaryStatus.CurrentStepState = appsv1alpha1.CanaryStepStateCompleted + object.Status.CanaryStatus.CurrentStepState = appsv1beta1.CanaryStepStateCompleted return object }, }, @@ -573,7 +573,7 @@ func TestRolloutValidateUpdate(t *testing.T) { }, GetNewObject: func() client.Object { object := rollout.DeepCopy() - object.Status.CanaryStatus.CurrentStepState = appsv1alpha1.CanaryStepStateCompleted + object.Status.CanaryStatus.CurrentStepState = appsv1beta1.CanaryStepStateCompleted return object }, },*/ @@ -587,7 +587,7 @@ func TestRolloutValidateUpdate(t *testing.T) { handler := RolloutCreateUpdateHandler{ Client: cli, } - errList := handler.validateRolloutUpdate(oldObject.(*appsv1alpha1.Rollout), newObject.(*appsv1alpha1.Rollout)) + errList := handler.validateRolloutUpdate(oldObject.(*appsv1beta1.Rollout), newObject.(*appsv1beta1.Rollout)) t.Log(errList) Expect(len(errList) == 0).Should(Equal(cs.Succeed)) }) diff --git a/pkg/webhook/rollout/validating/webhooks.go b/pkg/webhook/rollout/validating/webhooks.go index d105deb5..c9a6a827 100644 --- a/pkg/webhook/rollout/validating/webhooks.go +++ b/pkg/webhook/rollout/validating/webhooks.go @@ -20,7 +20,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/webhook/admission" ) -// +kubebuilder:webhook:path=/validate-rollouts-kruise-io-rollout,mutating=false,failurePolicy=fail,sideEffects=None,admissionReviewVersions=v1;v1beta1,groups=rollouts.kruise.io,resources=rollouts,verbs=create;update,versions=v1alpha1,name=vrollout.kb.io +// +kubebuilder:webhook:path=/validate-rollouts-kruise-io-rollout,mutating=false,failurePolicy=fail,sideEffects=None,admissionReviewVersions=v1;v1beta1,groups=rollouts.kruise.io,resources=rollouts,verbs=create;update,versions=v1beta1;v1alpha1,name=vrollout.kb.io var ( // HandlerMap contains admission webhook handlers diff --git a/pkg/webhook/workload/mutating/workload_update_handler.go b/pkg/webhook/workload/mutating/workload_update_handler.go index 2968e643..e311c614 100644 --- a/pkg/webhook/workload/mutating/workload_update_handler.go +++ b/pkg/webhook/workload/mutating/workload_update_handler.go @@ -24,7 +24,7 @@ import ( "strings" kruiseappsv1alpha1 "github.com/openkruise/kruise-api/apps/v1alpha1" - appsv1alpha1 "github.com/openkruise/rollouts/api/v1alpha1" + appsv1beta1 "github.com/openkruise/rollouts/api/v1beta1" "github.com/openkruise/rollouts/pkg/util" utilclient "github.com/openkruise/rollouts/pkg/util/client" util2 "github.com/openkruise/rollouts/pkg/webhook/util" @@ -231,10 +231,10 @@ func (h *WorkloadHandler) handleStatefulSetLikeWorkload(newObj, oldObj *unstruct return false, nil } oldMetadata, newMetadata := util.GetMetadata(oldObj), util.GetMetadata(newObj) - if newMetadata.Annotations[appsv1alpha1.RolloutIDLabel] != "" && - oldMetadata.Annotations[appsv1alpha1.RolloutIDLabel] == newMetadata.Annotations[appsv1alpha1.RolloutIDLabel] { + if newMetadata.Annotations[appsv1beta1.RolloutIDLabel] != "" && + oldMetadata.Annotations[appsv1beta1.RolloutIDLabel] == newMetadata.Annotations[appsv1beta1.RolloutIDLabel] { return false, nil - } else if newMetadata.Annotations[appsv1alpha1.RolloutIDLabel] == "" && util.EqualIgnoreHash(oldTemplate, newTemplate) { + } else if newMetadata.Annotations[appsv1beta1.RolloutIDLabel] == "" && util.EqualIgnoreHash(oldTemplate, newTemplate) { return false, nil } @@ -268,7 +268,7 @@ func (h *WorkloadHandler) handleDeployment(newObj, oldObj *apps.Deployment) (boo } strategy := util.GetDeploymentStrategy(newObj) switch strings.ToLower(string(strategy.RollingStyle)) { - case strings.ToLower(string(appsv1alpha1.PartitionRollingStyle)): + case strings.ToLower(string(appsv1beta1.PartitionRollingStyle)): // Make sure it is always Recreate to disable native controller if newObj.Spec.Strategy.Type == apps.RollingUpdateDeploymentStrategyType { modified = true @@ -332,7 +332,7 @@ func (h *WorkloadHandler) handleDeployment(newObj, oldObj *apps.Deployment) (boo if newObj.Labels == nil { newObj.Labels = map[string]string{} } - newObj.Labels[appsv1alpha1.DeploymentStableRevisionLabel] = stableRS.Labels[apps.DefaultDeploymentUniqueLabelKey] + newObj.Labels[appsv1beta1.DeploymentStableRevisionLabel] = stableRS.Labels[apps.DefaultDeploymentUniqueLabelKey] } // need set workload paused = true @@ -353,10 +353,10 @@ func (h *WorkloadHandler) handleCloneSet(newObj, oldObj *kruiseappsv1alpha1.Clon if newObj.Spec.Replicas != nil && *newObj.Spec.Replicas == 0 { return false, nil } - if newObj.Annotations[appsv1alpha1.RolloutIDLabel] != "" && - oldObj.Annotations[appsv1alpha1.RolloutIDLabel] == newObj.Annotations[appsv1alpha1.RolloutIDLabel] { + if newObj.Annotations[appsv1beta1.RolloutIDLabel] != "" && + oldObj.Annotations[appsv1beta1.RolloutIDLabel] == newObj.Annotations[appsv1beta1.RolloutIDLabel] { return false, nil - } else if newObj.Annotations[appsv1alpha1.RolloutIDLabel] == "" && util.EqualIgnoreHash(&oldObj.Spec.Template, &newObj.Spec.Template) { + } else if newObj.Annotations[appsv1beta1.RolloutIDLabel] == "" && util.EqualIgnoreHash(&oldObj.Spec.Template, &newObj.Spec.Template) { return false, nil } @@ -386,10 +386,10 @@ func (h *WorkloadHandler) handleCloneSet(newObj, oldObj *kruiseappsv1alpha1.Clon func (h *WorkloadHandler) handleDaemonSet(newObj, oldObj *kruiseappsv1alpha1.DaemonSet) (bool, error) { // indicate whether the workload can enter the rollout process - if newObj.Annotations[appsv1alpha1.RolloutIDLabel] != "" && - oldObj.Annotations[appsv1alpha1.RolloutIDLabel] == newObj.Annotations[appsv1alpha1.RolloutIDLabel] { + if newObj.Annotations[appsv1beta1.RolloutIDLabel] != "" && + oldObj.Annotations[appsv1beta1.RolloutIDLabel] == newObj.Annotations[appsv1beta1.RolloutIDLabel] { return false, nil - } else if newObj.Annotations[appsv1alpha1.RolloutIDLabel] == "" && util.EqualIgnoreHash(&oldObj.Spec.Template, &newObj.Spec.Template) { + } else if newObj.Annotations[appsv1beta1.RolloutIDLabel] == "" && util.EqualIgnoreHash(&oldObj.Spec.Template, &newObj.Spec.Template) { return false, nil } @@ -411,9 +411,9 @@ func (h *WorkloadHandler) handleDaemonSet(newObj, oldObj *kruiseappsv1alpha1.Dae return true, nil } -func (h *WorkloadHandler) fetchMatchedRollout(obj client.Object) (*appsv1alpha1.Rollout, error) { +func (h *WorkloadHandler) fetchMatchedRollout(obj client.Object) (*appsv1beta1.Rollout, error) { oGv := obj.GetObjectKind().GroupVersionKind() - rolloutList := &appsv1alpha1.RolloutList{} + rolloutList := &appsv1beta1.RolloutList{} if err := h.Client.List(context.TODO(), rolloutList, utilclient.DisableDeepCopy, &client.ListOptions{Namespace: obj.GetNamespace()}); err != nil { klog.Errorf("WorkloadHandler List rollout failed: %s", err.Error()) @@ -424,7 +424,7 @@ func (h *WorkloadHandler) fetchMatchedRollout(obj client.Object) (*appsv1alpha1. if !rollout.DeletionTimestamp.IsZero() || rollout.Spec.ObjectRef.WorkloadRef == nil { continue } - if rollout.Status.Phase == appsv1alpha1.RolloutPhaseDisabled { + if rollout.Status.Phase == appsv1beta1.RolloutPhaseDisabled { klog.Infof("Disabled rollout(%s/%s) fetched when fetching matched rollout", rollout.Namespace, rollout.Name) continue } @@ -459,19 +459,19 @@ func (h *WorkloadHandler) InjectDecoder(d *admission.Decoder) error { } func isEffectiveDeploymentRevisionChange(oldObj, newObj *apps.Deployment) bool { - if newObj.Annotations[appsv1alpha1.RolloutIDLabel] != "" && - oldObj.Annotations[appsv1alpha1.RolloutIDLabel] == newObj.Annotations[appsv1alpha1.RolloutIDLabel] { + if newObj.Annotations[appsv1beta1.RolloutIDLabel] != "" && + oldObj.Annotations[appsv1beta1.RolloutIDLabel] == newObj.Annotations[appsv1beta1.RolloutIDLabel] { return false - } else if newObj.Annotations[appsv1alpha1.RolloutIDLabel] == "" && + } else if newObj.Annotations[appsv1beta1.RolloutIDLabel] == "" && util.EqualIgnoreHash(&oldObj.Spec.Template, &newObj.Spec.Template) { return false } return true } -func setDeploymentStrategyAnnotation(strategy appsv1alpha1.DeploymentStrategy, d *apps.Deployment) { +func setDeploymentStrategyAnnotation(strategy appsv1beta1.DeploymentStrategy, d *apps.Deployment) { strategyAnno, _ := json.Marshal(&strategy) - d.Annotations[appsv1alpha1.DeploymentStrategyAnnotation] = string(strategyAnno) + d.Annotations[appsv1beta1.DeploymentStrategyAnnotation] = string(strategyAnno) } func (h *WorkloadHandler) checkWorkloadRules(ctx context.Context, req admission.Request) (bool, error) { diff --git a/pkg/webhook/workload/mutating/workload_update_handler_test.go b/pkg/webhook/workload/mutating/workload_update_handler_test.go index 53930b3d..b1d76417 100644 --- a/pkg/webhook/workload/mutating/workload_update_handler_test.go +++ b/pkg/webhook/workload/mutating/workload_update_handler_test.go @@ -25,7 +25,7 @@ import ( kruisev1aplphal "github.com/openkruise/kruise-api/apps/v1alpha1" kruiseappsv1beta1 "github.com/openkruise/kruise-api/apps/v1beta1" - appsv1alpha1 "github.com/openkruise/rollouts/api/v1alpha1" + appsv1beta1 "github.com/openkruise/rollouts/api/v1beta1" "github.com/openkruise/rollouts/pkg/util" "github.com/openkruise/rollouts/pkg/webhook/util/configuration" "github.com/stretchr/testify/assert" @@ -266,21 +266,21 @@ var ( }, } - rolloutDemo = &appsv1alpha1.Rollout{ + rolloutDemo = &appsv1beta1.Rollout{ ObjectMeta: metav1.ObjectMeta{ Name: "rollout-demo", Labels: map[string]string{}, }, - Spec: appsv1alpha1.RolloutSpec{ - ObjectRef: appsv1alpha1.ObjectRef{ - WorkloadRef: &appsv1alpha1.WorkloadRef{ + Spec: appsv1beta1.RolloutSpec{ + ObjectRef: appsv1beta1.ObjectRef{ + WorkloadRef: &appsv1beta1.WorkloadRef{ APIVersion: "apps/v1", Kind: "Deployment", Name: "echoserver", }, }, - Strategy: appsv1alpha1.RolloutStrategy{ - Canary: &appsv1alpha1.CanaryStrategy{}, + Strategy: appsv1beta1.RolloutStrategy{ + Canary: &appsv1beta1.CanaryStrategy{}, }, }, } @@ -290,7 +290,7 @@ func init() { scheme = runtime.NewScheme() _ = clientgoscheme.AddToScheme(scheme) _ = kruisev1aplphal.AddToScheme(scheme) - _ = appsv1alpha1.AddToScheme(scheme) + _ = appsv1beta1.AddToScheme(scheme) } func TestHandlerDeployment(t *testing.T) { @@ -298,7 +298,7 @@ func TestHandlerDeployment(t *testing.T) { name string getObjs func() (*apps.Deployment, *apps.Deployment) expectObj func() *apps.Deployment - getRollout func() *appsv1alpha1.Rollout + getRollout func() *appsv1beta1.Rollout getRs func() []*apps.ReplicaSet isError bool }{ @@ -321,7 +321,7 @@ func TestHandlerDeployment(t *testing.T) { rs := rsDemo.DeepCopy() return []*apps.ReplicaSet{rs} }, - getRollout: func() *appsv1alpha1.Rollout { + getRollout: func() *appsv1beta1.Rollout { return rolloutDemo.DeepCopy() }, }, @@ -342,9 +342,9 @@ func TestHandlerDeployment(t *testing.T) { rs := rsDemo.DeepCopy() return []*apps.ReplicaSet{rs} }, - getRollout: func() *appsv1alpha1.Rollout { + getRollout: func() *appsv1beta1.Rollout { obj := rolloutDemo.DeepCopy() - obj.Spec.ObjectRef.WorkloadRef = &appsv1alpha1.WorkloadRef{ + obj.Spec.ObjectRef.WorkloadRef = &appsv1beta1.WorkloadRef{ APIVersion: "apps/v1", Kind: "Deployment", Name: "other", @@ -373,13 +373,13 @@ func TestHandlerDeployment(t *testing.T) { rs2.Spec.Template.Spec.Containers[0].Image = "echoserver:v2" return []*apps.ReplicaSet{rs1, rs2} }, - getRollout: func() *appsv1alpha1.Rollout { + getRollout: func() *appsv1beta1.Rollout { demo := rolloutDemo.DeepCopy() - demo.Spec.Strategy.Canary = &appsv1alpha1.CanaryStrategy{ - TrafficRoutings: []appsv1alpha1.TrafficRoutingRef{ + demo.Spec.Strategy.Canary = &appsv1beta1.CanaryStrategy{ + TrafficRoutings: []appsv1beta1.TrafficRoutingRef{ { Service: "echoserver", - Ingress: &appsv1alpha1.IngressTrafficRouting{ + Ingress: &appsv1beta1.IngressTrafficRouting{ Name: "echoserver", }, }, @@ -412,7 +412,7 @@ func TestHandlerDeployment(t *testing.T) { rs := rsDemo.DeepCopy() return []*apps.ReplicaSet{rs} }, - getRollout: func() *appsv1alpha1.Rollout { + getRollout: func() *appsv1beta1.Rollout { return rolloutDemo.DeepCopy() }, }, @@ -440,7 +440,7 @@ func TestHandlerDeployment(t *testing.T) { rs := rsDemo.DeepCopy() return []*apps.ReplicaSet{rs} }, - getRollout: func() *appsv1alpha1.Rollout { + getRollout: func() *appsv1beta1.Rollout { obj := rolloutDemo.DeepCopy() return obj }, @@ -450,7 +450,7 @@ func TestHandlerDeployment(t *testing.T) { getObjs: func() (*apps.Deployment, *apps.Deployment) { oldObj := deploymentDemo.DeepCopy() newObj := deploymentDemo.DeepCopy() - newObj.Annotations[appsv1alpha1.RolloutIDLabel] = "v2" + newObj.Annotations[appsv1beta1.RolloutIDLabel] = "v2" newObj.Spec.Template.Spec.Containers[0].Image = "echoserver:v2" return oldObj, newObj }, @@ -459,14 +459,14 @@ func TestHandlerDeployment(t *testing.T) { obj.Spec.Template.Spec.Containers[0].Image = "echoserver:v2" obj.Annotations[util.InRolloutProgressingAnnotation] = `{"rolloutName":"rollout-demo"}` obj.Spec.Paused = true - obj.Annotations[appsv1alpha1.RolloutIDLabel] = "v2" + obj.Annotations[appsv1beta1.RolloutIDLabel] = "v2" return obj }, getRs: func() []*apps.ReplicaSet { rs := rsDemo.DeepCopy() return []*apps.ReplicaSet{rs} }, - getRollout: func() *appsv1alpha1.Rollout { + getRollout: func() *appsv1beta1.Rollout { obj := rolloutDemo.DeepCopy() return obj }, @@ -476,21 +476,21 @@ func TestHandlerDeployment(t *testing.T) { getObjs: func() (*apps.Deployment, *apps.Deployment) { oldObj := deploymentDemo.DeepCopy() newObj := deploymentDemo.DeepCopy() - newObj.Annotations[appsv1alpha1.RolloutIDLabel] = "v1-alpha1" + newObj.Annotations[appsv1beta1.RolloutIDLabel] = "v1-alpha1" return oldObj, newObj }, expectObj: func() *apps.Deployment { obj := deploymentDemo.DeepCopy() obj.Annotations[util.InRolloutProgressingAnnotation] = `{"rolloutName":"rollout-demo"}` obj.Spec.Paused = true - obj.Annotations[appsv1alpha1.RolloutIDLabel] = "v1-alpha1" + obj.Annotations[appsv1beta1.RolloutIDLabel] = "v1-alpha1" return obj }, getRs: func() []*apps.ReplicaSet { rs := rsDemo.DeepCopy() return []*apps.ReplicaSet{rs} }, - getRollout: func() *appsv1alpha1.Rollout { + getRollout: func() *appsv1beta1.Rollout { obj := rolloutDemo.DeepCopy() return obj }, @@ -499,23 +499,23 @@ func TestHandlerDeployment(t *testing.T) { name: "rolloutId no change, and podTemplateSpec change", getObjs: func() (*apps.Deployment, *apps.Deployment) { oldObj := deploymentDemo.DeepCopy() - oldObj.Annotations[appsv1alpha1.RolloutIDLabel] = "v1" + oldObj.Annotations[appsv1beta1.RolloutIDLabel] = "v1" newObj := deploymentDemo.DeepCopy() newObj.Spec.Template.Spec.Containers[0].Image = "echoserver:v2" - newObj.Annotations[appsv1alpha1.RolloutIDLabel] = "v1" + newObj.Annotations[appsv1beta1.RolloutIDLabel] = "v1" return oldObj, newObj }, expectObj: func() *apps.Deployment { obj := deploymentDemo.DeepCopy() obj.Spec.Template.Spec.Containers[0].Image = "echoserver:v2" - obj.Annotations[appsv1alpha1.RolloutIDLabel] = "v1" + obj.Annotations[appsv1beta1.RolloutIDLabel] = "v1" return obj }, getRs: func() []*apps.ReplicaSet { rs := rsDemo.DeepCopy() return []*apps.ReplicaSet{rs} }, - getRollout: func() *appsv1alpha1.Rollout { + getRollout: func() *appsv1beta1.Rollout { obj := rolloutDemo.DeepCopy() return obj }, @@ -548,7 +548,7 @@ func TestHandlerDeployment(t *testing.T) { } else if !cs.isError && err != nil { t.Fatalf(err.Error()) } - delete(newObj.Labels, appsv1alpha1.DeploymentStableRevisionLabel) + delete(newObj.Labels, appsv1beta1.DeploymentStableRevisionLabel) if !reflect.DeepEqual(newObj, cs.expectObj()) { t.Fatalf("handlerDeployment failed, and expect(%s) new(%s)", util.DumpJSON(cs.expectObj()), util.DumpJSON(newObj)) } @@ -561,7 +561,7 @@ func TestHandlerCloneSet(t *testing.T) { name string getObjs func() (*kruisev1aplphal.CloneSet, *kruisev1aplphal.CloneSet) expectObj func() *kruisev1aplphal.CloneSet - getRollout func() *appsv1alpha1.Rollout + getRollout func() *appsv1beta1.Rollout isError bool }{ { @@ -579,9 +579,9 @@ func TestHandlerCloneSet(t *testing.T) { obj.Spec.UpdateStrategy.Partition = &intstr.IntOrString{Type: intstr.String, StrVal: "100%"} return obj }, - getRollout: func() *appsv1alpha1.Rollout { + getRollout: func() *appsv1beta1.Rollout { obj := rolloutDemo.DeepCopy() - obj.Spec.ObjectRef.WorkloadRef = &appsv1alpha1.WorkloadRef{ + obj.Spec.ObjectRef.WorkloadRef = &appsv1beta1.WorkloadRef{ APIVersion: "apps.kruise.io/v1alpha1", Kind: "CloneSet", Name: "echoserver", @@ -625,7 +625,7 @@ func TestHandlerDaemonSet(t *testing.T) { name string getObjs func() (*kruisev1aplphal.DaemonSet, *kruisev1aplphal.DaemonSet) expectObj func() *kruisev1aplphal.DaemonSet - getRollout func() *appsv1alpha1.Rollout + getRollout func() *appsv1beta1.Rollout isError bool }{ { @@ -643,9 +643,9 @@ func TestHandlerDaemonSet(t *testing.T) { obj.Spec.UpdateStrategy.RollingUpdate.Partition = pointer.Int32(math.MaxInt16) return obj }, - getRollout: func() *appsv1alpha1.Rollout { + getRollout: func() *appsv1beta1.Rollout { obj := rolloutDemo.DeepCopy() - obj.Spec.ObjectRef.WorkloadRef = &appsv1alpha1.WorkloadRef{ + obj.Spec.ObjectRef.WorkloadRef = &appsv1beta1.WorkloadRef{ APIVersion: "apps.kruise.io/v1alpha1", Kind: "DaemonSet", Name: "echoserver", @@ -689,7 +689,7 @@ func TestHandleStatefulSet(t *testing.T) { name string getObjs func() (*kruiseappsv1beta1.StatefulSet, *kruiseappsv1beta1.StatefulSet) expectObj func() *kruiseappsv1beta1.StatefulSet - getRollout func() *appsv1alpha1.Rollout + getRollout func() *appsv1beta1.Rollout isError bool }{ { @@ -707,9 +707,9 @@ func TestHandleStatefulSet(t *testing.T) { obj.Spec.UpdateStrategy.RollingUpdate.Partition = pointer.Int32(math.MaxInt16) return obj }, - getRollout: func() *appsv1alpha1.Rollout { + getRollout: func() *appsv1beta1.Rollout { obj := rolloutDemo.DeepCopy() - obj.Spec.ObjectRef.WorkloadRef = &appsv1alpha1.WorkloadRef{ + obj.Spec.ObjectRef.WorkloadRef = &appsv1beta1.WorkloadRef{ APIVersion: "apps.kruise.io/v1beta1", Kind: "StatefulSet", Name: "echoserver", diff --git a/test/e2e/batchrelease_test.go b/test/e2e/batchrelease_test.go index 1830f4df..607d37ae 100644 --- a/test/e2e/batchrelease_test.go +++ b/test/e2e/batchrelease_test.go @@ -25,7 +25,7 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" kruiseappsv1alpha1 "github.com/openkruise/kruise-api/apps/v1alpha1" - rolloutsv1alpha1 "github.com/openkruise/rollouts/api/v1alpha1" + rolloutsv1beta1 "github.com/openkruise/rollouts/api/v1beta1" workloads "github.com/openkruise/rollouts/pkg/util" "github.com/openkruise/rollouts/test/images" apps "k8s.io/api/apps/v1" @@ -44,10 +44,10 @@ var _ = SIGDescribe("BatchRelease", func() { var namespace string DumpAllResources := func() { - rollout := &rolloutsv1alpha1.RolloutList{} + rollout := &rolloutsv1beta1.RolloutList{} k8sClient.List(context.TODO(), rollout, client.InNamespace(namespace)) fmt.Println(workloads.DumpJSON(rollout)) - batch := &rolloutsv1alpha1.BatchReleaseList{} + batch := &rolloutsv1beta1.BatchReleaseList{} k8sClient.List(context.TODO(), batch, client.InNamespace(namespace)) fmt.Println(workloads.DumpJSON(batch)) deploy := &apps.DeploymentList{} @@ -72,10 +72,10 @@ var _ = SIGDescribe("BatchRelease", func() { Expect(k8sClient.Delete(context.TODO(), object)).NotTo(HaveOccurred()) } - UpdateRelease := func(object *rolloutsv1alpha1.BatchRelease) *rolloutsv1alpha1.BatchRelease { - var release *rolloutsv1alpha1.BatchRelease + UpdateRelease := func(object *rolloutsv1beta1.BatchRelease) *rolloutsv1beta1.BatchRelease { + var release *rolloutsv1beta1.BatchRelease Expect(retry.RetryOnConflict(retry.DefaultRetry, func() error { - release = &rolloutsv1alpha1.BatchRelease{} + release = &rolloutsv1beta1.BatchRelease{} err := GetObject(object.Namespace, object.Name, release) if err != nil { return err @@ -140,7 +140,7 @@ var _ = SIGDescribe("BatchRelease", func() { return clone } - GetCanaryDeployment := func(release *rolloutsv1alpha1.BatchRelease) *apps.Deployment { + GetCanaryDeployment := func(release *rolloutsv1beta1.BatchRelease) *apps.Deployment { var dList *apps.DeploymentList dList = &apps.DeploymentList{} Expect(k8sClient.List(context.TODO(), dList, client.InNamespace(release.Namespace))).NotTo(HaveOccurred()) @@ -176,10 +176,10 @@ var _ = SIGDescribe("BatchRelease", func() { }, 20*time.Minute, time.Second).Should(BeTrue()) } - WaitBatchReleaseProgressing := func(object *rolloutsv1alpha1.BatchRelease) { + WaitBatchReleaseProgressing := func(object *rolloutsv1beta1.BatchRelease) { startTime := time.Now() - Eventually(func() rolloutsv1alpha1.RolloutPhase { - release := &rolloutsv1alpha1.BatchRelease{} + Eventually(func() rolloutsv1beta1.RolloutPhase { + release := &rolloutsv1beta1.BatchRelease{} Expect(GetObject(object.Namespace, object.Name, release)).NotTo(HaveOccurred()) if startTime.Add(time.Minute * 5).Before(time.Now()) { DumpAllResources() @@ -187,7 +187,7 @@ var _ = SIGDescribe("BatchRelease", func() { } fmt.Println(release.Status.Phase) return release.Status.Phase - }, 10*time.Minute, time.Second).Should(Equal(rolloutsv1alpha1.RolloutPhaseProgressing)) + }, 10*time.Minute, time.Second).Should(Equal(rolloutsv1beta1.RolloutPhaseProgressing)) } BeforeEach(func() { @@ -206,14 +206,14 @@ var _ = SIGDescribe("BatchRelease", func() { if workloads.DiscoverGVK(workloads.ControllerKruiseKindCS) { k8sClient.DeleteAllOf(context.TODO(), &kruiseappsv1alpha1.CloneSet{}, client.InNamespace(namespace)) } - k8sClient.DeleteAllOf(context.TODO(), &rolloutsv1alpha1.BatchRelease{}, client.InNamespace(namespace)) + k8sClient.DeleteAllOf(context.TODO(), &rolloutsv1beta1.BatchRelease{}, client.InNamespace(namespace)) Expect(k8sClient.Delete(context.TODO(), &v1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: namespace}}, client.PropagationPolicy(metav1.DeletePropagationForeground))).Should(Succeed()) }) KruiseDescribe("CloneSet BatchRelease Checker", func() { It("V1->V2: Percentage, 100%, Succeeded", func() { By("Creating BatchRelease...") - release := &rolloutsv1alpha1.BatchRelease{} + release := &rolloutsv1beta1.BatchRelease{} Expect(ReadYamlToObject("./test_data/batchrelease/cloneset_percentage_100.yaml", release)).ToNot(HaveOccurred()) CreateObject(release) @@ -249,16 +249,16 @@ var _ = SIGDescribe("BatchRelease", func() { } By("Checking BatchRelease status...") - Eventually(func() rolloutsv1alpha1.RolloutPhase { - clone := &rolloutsv1alpha1.BatchRelease{} + Eventually(func() rolloutsv1beta1.RolloutPhase { + clone := &rolloutsv1beta1.BatchRelease{} Expect(GetObject(release.Namespace, release.Name, clone)).NotTo(HaveOccurred()) return clone.Status.Phase - }, 15*time.Minute, 5*time.Second).Should(Equal(rolloutsv1alpha1.RolloutPhaseCompleted)) + }, 15*time.Minute, 5*time.Second).Should(Equal(rolloutsv1beta1.RolloutPhaseCompleted)) }) It("V1->V2: Percentage, 50%, Succeeded", func() { By("Creating BatchRelease...") - release := &rolloutsv1alpha1.BatchRelease{} + release := &rolloutsv1beta1.BatchRelease{} Expect(ReadYamlToObject("./test_data/batchrelease/cloneset_percentage_50.yaml", release)).ToNot(HaveOccurred()) CreateObject(release) @@ -294,11 +294,11 @@ var _ = SIGDescribe("BatchRelease", func() { } By("Checking BatchRelease status...") - Eventually(func() rolloutsv1alpha1.RolloutPhase { - clone := &rolloutsv1alpha1.BatchRelease{} + Eventually(func() rolloutsv1beta1.RolloutPhase { + clone := &rolloutsv1beta1.BatchRelease{} Expect(GetObject(release.Namespace, release.Name, clone)).NotTo(HaveOccurred()) return clone.Status.Phase - }, 15*time.Minute, 5*time.Second).Should(Equal(rolloutsv1alpha1.RolloutPhaseCompleted)) + }, 15*time.Minute, 5*time.Second).Should(Equal(rolloutsv1beta1.RolloutPhaseCompleted)) By("Checking all pod were updated when release completed...") expectedReplicas, _ := intstr.GetScaledValueFromIntOrPercent( @@ -313,7 +313,7 @@ var _ = SIGDescribe("BatchRelease", func() { It("V1->V2(UnCompleted)->V3: Percentage, 100%, Succeeded", func() { By("Creating BatchRelease....") By("Creating BatchRelease...") - release := &rolloutsv1alpha1.BatchRelease{} + release := &rolloutsv1beta1.BatchRelease{} Expect(ReadYamlToObject("./test_data/batchrelease/cloneset_percentage_100.yaml", release)).ToNot(HaveOccurred()) CreateObject(release) @@ -352,9 +352,9 @@ var _ = SIGDescribe("BatchRelease", func() { } By("V1->V2: Checking BatchRelease status...") - clone := &rolloutsv1alpha1.BatchRelease{} + clone := &rolloutsv1beta1.BatchRelease{} Expect(GetObject(release.Namespace, release.Name, clone)).NotTo(HaveOccurred()) - Expect(clone.Status.Phase).ShouldNot(Equal(rolloutsv1alpha1.RolloutPhaseCompleted)) + Expect(clone.Status.Phase).ShouldNot(Equal(rolloutsv1beta1.RolloutPhaseCompleted)) /************************************************************************************* V1->V2 Succeeded, Start to release V2->V3 @@ -371,16 +371,16 @@ var _ = SIGDescribe("BatchRelease", func() { Expect(canaryRevisionV3).ShouldNot(Equal(canaryRevisionV2)) By("V2->V3: Checking BatchRelease status...") - Eventually(func() rolloutsv1alpha1.RolloutPhase { - clone := &rolloutsv1alpha1.BatchRelease{} + Eventually(func() rolloutsv1beta1.RolloutPhase { + clone := &rolloutsv1beta1.BatchRelease{} Expect(GetObject(release.Namespace, release.Name, clone)).NotTo(HaveOccurred()) return clone.Status.Phase - }, 15*time.Minute, 5*time.Second).Should(Equal(rolloutsv1alpha1.RolloutPhaseCompleted)) + }, 15*time.Minute, 5*time.Second).Should(Equal(rolloutsv1beta1.RolloutPhaseCompleted)) }) It("V1->V2: ScalingUp, Percentage, 100%, Succeeded", func() { By("Creating BatchRelease...") - release := &rolloutsv1alpha1.BatchRelease{} + release := &rolloutsv1beta1.BatchRelease{} Expect(ReadYamlToObject("./test_data/batchrelease/cloneset_percentage_100.yaml", release)).ToNot(HaveOccurred()) CreateObject(release) @@ -425,11 +425,11 @@ var _ = SIGDescribe("BatchRelease", func() { } By("Checking BatchRelease status...") - Eventually(func() rolloutsv1alpha1.RolloutPhase { - clone := &rolloutsv1alpha1.BatchRelease{} + Eventually(func() rolloutsv1beta1.RolloutPhase { + clone := &rolloutsv1beta1.BatchRelease{} Expect(GetObject(release.Namespace, release.Name, clone)).NotTo(HaveOccurred()) return clone.Status.Phase - }, 15*time.Minute, 5*time.Second).Should(Equal(rolloutsv1alpha1.RolloutPhaseCompleted)) + }, 15*time.Minute, 5*time.Second).Should(Equal(rolloutsv1beta1.RolloutPhaseCompleted)) By("Checking all pod were updated when release completed...") Eventually(func() bool { @@ -441,7 +441,7 @@ var _ = SIGDescribe("BatchRelease", func() { It("V1->V2: ScalingDown, Percentage, 100%, Succeeded", func() { By("Creating BatchRelease...") - release := &rolloutsv1alpha1.BatchRelease{} + release := &rolloutsv1beta1.BatchRelease{} Expect(ReadYamlToObject("./test_data/batchrelease/cloneset_percentage_100.yaml", release)).ToNot(HaveOccurred()) CreateObject(release) @@ -486,11 +486,11 @@ var _ = SIGDescribe("BatchRelease", func() { } By("Checking BatchRelease status...") - Eventually(func() rolloutsv1alpha1.RolloutPhase { - clone := &rolloutsv1alpha1.BatchRelease{} + Eventually(func() rolloutsv1beta1.RolloutPhase { + clone := &rolloutsv1beta1.BatchRelease{} Expect(GetObject(release.Namespace, release.Name, clone)).NotTo(HaveOccurred()) return clone.Status.Phase - }, 15*time.Minute, 5*time.Second).Should(Equal(rolloutsv1alpha1.RolloutPhaseCompleted)) + }, 15*time.Minute, 5*time.Second).Should(Equal(rolloutsv1beta1.RolloutPhaseCompleted)) By("Checking all pod were updated when release completed...") Eventually(func() bool { @@ -502,7 +502,7 @@ var _ = SIGDescribe("BatchRelease", func() { It("V1->V2: ScalingUp, Number, 100%, Succeeded", func() { By("Creating BatchRelease...") - release := &rolloutsv1alpha1.BatchRelease{} + release := &rolloutsv1beta1.BatchRelease{} Expect(ReadYamlToObject("./test_data/batchrelease/cloneset_number_100.yaml", release)).ToNot(HaveOccurred()) CreateObject(release) @@ -547,11 +547,11 @@ var _ = SIGDescribe("BatchRelease", func() { } By("Checking BatchRelease status...") - Eventually(func() rolloutsv1alpha1.RolloutPhase { - clone := &rolloutsv1alpha1.BatchRelease{} + Eventually(func() rolloutsv1beta1.RolloutPhase { + clone := &rolloutsv1beta1.BatchRelease{} Expect(GetObject(release.Namespace, release.Name, clone)).NotTo(HaveOccurred()) return clone.Status.Phase - }, 15*time.Minute, 5*time.Second).Should(Equal(rolloutsv1alpha1.RolloutPhaseCompleted)) + }, 15*time.Minute, 5*time.Second).Should(Equal(rolloutsv1beta1.RolloutPhaseCompleted)) By("Checking all pod were updated when release completed...") Eventually(func() bool { @@ -563,7 +563,7 @@ var _ = SIGDescribe("BatchRelease", func() { It("V1->V2: ScalingDown, Number, 100%, Succeeded", func() { By("Creating BatchRelease...") - release := &rolloutsv1alpha1.BatchRelease{} + release := &rolloutsv1beta1.BatchRelease{} Expect(ReadYamlToObject("./test_data/batchrelease/cloneset_number_100.yaml", release)).ToNot(HaveOccurred()) CreateObject(release) @@ -609,11 +609,11 @@ var _ = SIGDescribe("BatchRelease", func() { } By("Checking BatchRelease status...") - Eventually(func() rolloutsv1alpha1.RolloutPhase { - clone := &rolloutsv1alpha1.BatchRelease{} + Eventually(func() rolloutsv1beta1.RolloutPhase { + clone := &rolloutsv1beta1.BatchRelease{} Expect(GetObject(release.Namespace, release.Name, clone)).NotTo(HaveOccurred()) return clone.Status.Phase - }, 15*time.Minute, 5*time.Second).Should(Equal(rolloutsv1alpha1.RolloutPhaseCompleted)) + }, 15*time.Minute, 5*time.Second).Should(Equal(rolloutsv1beta1.RolloutPhaseCompleted)) By("Checking all pod were updated when release completed...") Eventually(func() bool { @@ -628,7 +628,7 @@ var _ = SIGDescribe("BatchRelease", func() { It("V1->V2: Percentage, 100%, Succeeded", func() { By("Creating BatchRelease...") - release := &rolloutsv1alpha1.BatchRelease{} + release := &rolloutsv1beta1.BatchRelease{} Expect(ReadYamlToObject("./test_data/batchrelease/deployment_percentage_100.yaml", release)).ToNot(HaveOccurred()) CreateObject(release) @@ -639,7 +639,7 @@ var _ = SIGDescribe("BatchRelease", func() { CreateObject(deployment) WaitDeploymentAllPodsReady(deployment) Expect(GetObject(release.Namespace, release.Name, release)) - Expect(release.Status.Phase).Should(Equal(rolloutsv1alpha1.RolloutPhaseHealthy)) + Expect(release.Status.Phase).Should(Equal(rolloutsv1beta1.RolloutPhaseHealthy)) // record stable revision --> v1 stableRevision := workloads.ComputeHash(&deployment.Spec.Template, deployment.Status.CollisionCount) @@ -667,16 +667,16 @@ var _ = SIGDescribe("BatchRelease", func() { } By("Checking BatchRelease status...") - Eventually(func() rolloutsv1alpha1.RolloutPhase { - clone := &rolloutsv1alpha1.BatchRelease{} + Eventually(func() rolloutsv1beta1.RolloutPhase { + clone := &rolloutsv1beta1.BatchRelease{} Expect(GetObject(release.Namespace, release.Name, clone)).NotTo(HaveOccurred()) return clone.Status.Phase - }, 15*time.Minute, 5*time.Second).Should(Equal(rolloutsv1alpha1.RolloutPhaseCompleted)) + }, 15*time.Minute, 5*time.Second).Should(Equal(rolloutsv1beta1.RolloutPhaseCompleted)) }) It("V1->V2: Percentage, 50%, Succeeded", func() { By("Creating BatchRelease...") - release := &rolloutsv1alpha1.BatchRelease{} + release := &rolloutsv1beta1.BatchRelease{} Expect(ReadYamlToObject("./test_data/batchrelease/deployment_percentage_50.yaml", release)).ToNot(HaveOccurred()) CreateObject(release) @@ -687,7 +687,7 @@ var _ = SIGDescribe("BatchRelease", func() { CreateObject(deployment) WaitDeploymentAllPodsReady(deployment) Expect(GetObject(release.Namespace, release.Name, release)) - Expect(release.Status.Phase).Should(Equal(rolloutsv1alpha1.RolloutPhaseHealthy)) + Expect(release.Status.Phase).Should(Equal(rolloutsv1beta1.RolloutPhaseHealthy)) // record stable revision --> v1 stableRevision := workloads.ComputeHash(&deployment.Spec.Template, deployment.Status.CollisionCount) @@ -715,11 +715,11 @@ var _ = SIGDescribe("BatchRelease", func() { } By("Checking BatchRelease status...") - Eventually(func() rolloutsv1alpha1.RolloutPhase { - clone := &rolloutsv1alpha1.BatchRelease{} + Eventually(func() rolloutsv1beta1.RolloutPhase { + clone := &rolloutsv1beta1.BatchRelease{} Expect(GetObject(release.Namespace, release.Name, clone)).NotTo(HaveOccurred()) return clone.Status.Phase - }, 5*time.Minute, time.Second).Should(Equal(rolloutsv1alpha1.RolloutPhaseCompleted)) + }, 5*time.Minute, time.Second).Should(Equal(rolloutsv1beta1.RolloutPhaseCompleted)) By("Checking expected pods were updated when release completed...") expectedReplicas, _ := intstr.GetScaledValueFromIntOrPercent( @@ -734,7 +734,7 @@ var _ = SIGDescribe("BatchRelease", func() { It("V1->V2(UnCompleted)->V3: Percentage, 100%, Succeeded", func() { By("Creating BatchRelease....") By("Creating BatchRelease...") - release := &rolloutsv1alpha1.BatchRelease{} + release := &rolloutsv1beta1.BatchRelease{} Expect(ReadYamlToObject("./test_data/batchrelease/deployment_percentage_100.yaml", release)).ToNot(HaveOccurred()) CreateObject(release) @@ -746,7 +746,7 @@ var _ = SIGDescribe("BatchRelease", func() { CreateObject(deployment) WaitDeploymentAllPodsReady(deployment) Expect(GetObject(release.Namespace, release.Name, release)) - Expect(release.Status.Phase).Should(Equal(rolloutsv1alpha1.RolloutPhaseHealthy)) + Expect(release.Status.Phase).Should(Equal(rolloutsv1beta1.RolloutPhaseHealthy)) stableRevisionV1 := workloads.ComputeHash(&deployment.Spec.Template, deployment.Status.CollisionCount) /************************************************************************************* @@ -776,9 +776,9 @@ var _ = SIGDescribe("BatchRelease", func() { } By("V1->V2: Checking BatchRelease status...") - clone := &rolloutsv1alpha1.BatchRelease{} + clone := &rolloutsv1beta1.BatchRelease{} Expect(GetObject(release.Namespace, release.Name, clone)).NotTo(HaveOccurred()) - Expect(clone.Status.Phase).ShouldNot(Equal(rolloutsv1alpha1.RolloutPhaseCompleted)) + Expect(clone.Status.Phase).ShouldNot(Equal(rolloutsv1beta1.RolloutPhaseCompleted)) /************************************************************************************* V1->V2 Not Completed, Start to release V1,V2->V3 @@ -795,16 +795,16 @@ var _ = SIGDescribe("BatchRelease", func() { Expect(canaryRevisionV3).ShouldNot(Equal(canaryRevisionV2)) By("V2->V3: Checking BatchRelease status...") - Eventually(func() rolloutsv1alpha1.RolloutPhase { - clone := &rolloutsv1alpha1.BatchRelease{} + Eventually(func() rolloutsv1beta1.RolloutPhase { + clone := &rolloutsv1beta1.BatchRelease{} Expect(GetObject(release.Namespace, release.Name, clone)).NotTo(HaveOccurred()) return clone.Status.Phase - }, 15*time.Minute, 5*time.Second).Should(Equal(rolloutsv1alpha1.RolloutPhaseCompleted)) + }, 15*time.Minute, 5*time.Second).Should(Equal(rolloutsv1beta1.RolloutPhaseCompleted)) }) It("V1->V2: ScalingUp, Percentage, 100%, Succeeded", func() { By("Creating BatchRelease...") - release := &rolloutsv1alpha1.BatchRelease{} + release := &rolloutsv1beta1.BatchRelease{} Expect(ReadYamlToObject("./test_data/batchrelease/deployment_percentage_100.yaml", release)).ToNot(HaveOccurred()) CreateObject(release) @@ -815,7 +815,7 @@ var _ = SIGDescribe("BatchRelease", func() { CreateObject(deployment) WaitDeploymentAllPodsReady(deployment) Expect(GetObject(release.Namespace, release.Name, release)) - Expect(release.Status.Phase).Should(Equal(rolloutsv1alpha1.RolloutPhaseHealthy)) + Expect(release.Status.Phase).Should(Equal(rolloutsv1beta1.RolloutPhaseHealthy)) // record stable revision --> v1 stableRevision := workloads.ComputeHash(&deployment.Spec.Template, deployment.Status.CollisionCount) @@ -853,11 +853,11 @@ var _ = SIGDescribe("BatchRelease", func() { } By("Checking BatchRelease status...") - Eventually(func() rolloutsv1alpha1.RolloutPhase { - clone := &rolloutsv1alpha1.BatchRelease{} + Eventually(func() rolloutsv1beta1.RolloutPhase { + clone := &rolloutsv1beta1.BatchRelease{} Expect(GetObject(release.Namespace, release.Name, clone)).NotTo(HaveOccurred()) return clone.Status.Phase - }, 15*time.Minute, 5*time.Second).Should(Equal(rolloutsv1alpha1.RolloutPhaseCompleted)) + }, 15*time.Minute, 5*time.Second).Should(Equal(rolloutsv1beta1.RolloutPhaseCompleted)) By("Checking all pod were updated when release completed...") fetchedDeployment := &apps.Deployment{} @@ -874,7 +874,7 @@ var _ = SIGDescribe("BatchRelease", func() { It("V1->V2: ScalingDown, Percentage, 100%, Succeeded", func() { By("Creating BatchRelease...") - release := &rolloutsv1alpha1.BatchRelease{} + release := &rolloutsv1beta1.BatchRelease{} Expect(ReadYamlToObject("./test_data/batchrelease/deployment_percentage_100.yaml", release)).ToNot(HaveOccurred()) CreateObject(release) @@ -885,7 +885,7 @@ var _ = SIGDescribe("BatchRelease", func() { CreateObject(deployment) WaitDeploymentAllPodsReady(deployment) Expect(GetObject(release.Namespace, release.Name, release)) - Expect(release.Status.Phase).Should(Equal(rolloutsv1alpha1.RolloutPhaseHealthy)) + Expect(release.Status.Phase).Should(Equal(rolloutsv1beta1.RolloutPhaseHealthy)) // record stable revision --> v1 stableRevision := workloads.ComputeHash(&deployment.Spec.Template, deployment.Status.CollisionCount) @@ -923,11 +923,11 @@ var _ = SIGDescribe("BatchRelease", func() { } By("Checking BatchRelease status...") - Eventually(func() rolloutsv1alpha1.RolloutPhase { - clone := &rolloutsv1alpha1.BatchRelease{} + Eventually(func() rolloutsv1beta1.RolloutPhase { + clone := &rolloutsv1beta1.BatchRelease{} Expect(GetObject(release.Namespace, release.Name, clone)).NotTo(HaveOccurred()) return clone.Status.Phase - }, 15*time.Minute, 5*time.Second).Should(Equal(rolloutsv1alpha1.RolloutPhaseCompleted)) + }, 15*time.Minute, 5*time.Second).Should(Equal(rolloutsv1beta1.RolloutPhaseCompleted)) By("Checking all pod were updated when release completed...") fetchedDeployment := &apps.Deployment{} @@ -944,7 +944,7 @@ var _ = SIGDescribe("BatchRelease", func() { It("V1->V2: ScalingUp, Number, 100%, Succeeded", func() { By("Creating BatchRelease...") - release := &rolloutsv1alpha1.BatchRelease{} + release := &rolloutsv1beta1.BatchRelease{} Expect(ReadYamlToObject("./test_data/batchrelease/deployment_number_100.yaml", release)).ToNot(HaveOccurred()) CreateObject(release) @@ -955,7 +955,7 @@ var _ = SIGDescribe("BatchRelease", func() { CreateObject(deployment) WaitDeploymentAllPodsReady(deployment) Expect(GetObject(release.Namespace, release.Name, release)) - Expect(release.Status.Phase).Should(Equal(rolloutsv1alpha1.RolloutPhaseHealthy)) + Expect(release.Status.Phase).Should(Equal(rolloutsv1beta1.RolloutPhaseHealthy)) // record stable revision --> v1 stableRevision := workloads.ComputeHash(&deployment.Spec.Template, deployment.Status.CollisionCount) @@ -992,11 +992,11 @@ var _ = SIGDescribe("BatchRelease", func() { } By("Checking BatchRelease status...") - Eventually(func() rolloutsv1alpha1.RolloutPhase { - clone := &rolloutsv1alpha1.BatchRelease{} + Eventually(func() rolloutsv1beta1.RolloutPhase { + clone := &rolloutsv1beta1.BatchRelease{} Expect(GetObject(release.Namespace, release.Name, clone)).NotTo(HaveOccurred()) return clone.Status.Phase - }, 15*time.Minute, 5*time.Second).Should(Equal(rolloutsv1alpha1.RolloutPhaseCompleted)) + }, 15*time.Minute, 5*time.Second).Should(Equal(rolloutsv1beta1.RolloutPhaseCompleted)) By("Checking all pod were updated when release completed...") fetchedDeployment := &apps.Deployment{} @@ -1013,7 +1013,7 @@ var _ = SIGDescribe("BatchRelease", func() { It("V1->V2: ScalingDown, Number, 100%, Succeeded", func() { By("Creating BatchRelease...") - release := &rolloutsv1alpha1.BatchRelease{} + release := &rolloutsv1beta1.BatchRelease{} Expect(ReadYamlToObject("./test_data/batchrelease/deployment_number_100.yaml", release)).ToNot(HaveOccurred()) CreateObject(release) @@ -1024,7 +1024,7 @@ var _ = SIGDescribe("BatchRelease", func() { CreateObject(deployment) WaitDeploymentAllPodsReady(deployment) Expect(GetObject(release.Namespace, release.Name, release)) - Expect(release.Status.Phase).Should(Equal(rolloutsv1alpha1.RolloutPhaseHealthy)) + Expect(release.Status.Phase).Should(Equal(rolloutsv1beta1.RolloutPhaseHealthy)) // record stable revision --> v1 stableRevision := workloads.ComputeHash(&deployment.Spec.Template, deployment.Status.CollisionCount) @@ -1062,11 +1062,11 @@ var _ = SIGDescribe("BatchRelease", func() { } By("Checking BatchRelease status...") - Eventually(func() rolloutsv1alpha1.RolloutPhase { - clone := &rolloutsv1alpha1.BatchRelease{} + Eventually(func() rolloutsv1beta1.RolloutPhase { + clone := &rolloutsv1beta1.BatchRelease{} Expect(GetObject(release.Namespace, release.Name, clone)).NotTo(HaveOccurred()) return clone.Status.Phase - }, 15*time.Minute, 5*time.Second).Should(Equal(rolloutsv1alpha1.RolloutPhaseCompleted)) + }, 15*time.Minute, 5*time.Second).Should(Equal(rolloutsv1beta1.RolloutPhaseCompleted)) By("Checking all pod were updated when release completed...") fetchedDeployment := &apps.Deployment{} @@ -1083,7 +1083,7 @@ var _ = SIGDescribe("BatchRelease", func() { It("Rollback V1->V2->V1: Percentage, 100%, Succeeded", func() { By("Creating BatchRelease...") - release := &rolloutsv1alpha1.BatchRelease{} + release := &rolloutsv1beta1.BatchRelease{} Expect(ReadYamlToObject("./test_data/batchrelease/deployment_percentage_100.yaml", release)).ToNot(HaveOccurred()) CreateObject(release) @@ -1095,7 +1095,7 @@ var _ = SIGDescribe("BatchRelease", func() { CreateObject(deployment) WaitDeploymentAllPodsReady(deployment) Expect(GetObject(release.Namespace, release.Name, release)) - Expect(release.Status.Phase).Should(Equal(rolloutsv1alpha1.RolloutPhaseHealthy)) + Expect(release.Status.Phase).Should(Equal(rolloutsv1beta1.RolloutPhaseHealthy)) // record stable revision --> v1 stableRevisionV1 := workloads.ComputeHash(&deployment.Spec.Template, deployment.Status.CollisionCount) @@ -1113,7 +1113,7 @@ var _ = SIGDescribe("BatchRelease", func() { By("Waiting a minute and checking failed revision...") time.Sleep(time.Minute) for i := 0; i < 30; i++ { - fetchedRelease := &rolloutsv1alpha1.BatchRelease{} + fetchedRelease := &rolloutsv1beta1.BatchRelease{} Expect(GetObject(release.Namespace, release.Name, fetchedRelease)).NotTo(HaveOccurred()) Expect(fetchedRelease.Status.CanaryStatus.UpdatedReplicas).Should(Equal(int32(1))) Expect(fetchedRelease.Status.CanaryStatus.UpdatedReadyReplicas).Should(Equal(int32(0))) @@ -1130,16 +1130,16 @@ var _ = SIGDescribe("BatchRelease", func() { Expect(canaryRevisionV3).Should(Equal(stableRevisionV1)) By("Checking BatchRelease completed status phase...") - Eventually(func() rolloutsv1alpha1.RolloutPhase { - clone := &rolloutsv1alpha1.BatchRelease{} + Eventually(func() rolloutsv1beta1.RolloutPhase { + clone := &rolloutsv1beta1.BatchRelease{} Expect(GetObject(release.Namespace, release.Name, clone)).NotTo(HaveOccurred()) return clone.Status.Phase - }, 15*time.Minute, 5*time.Second).Should(Equal(rolloutsv1alpha1.RolloutPhaseCompleted)) + }, 15*time.Minute, 5*time.Second).Should(Equal(rolloutsv1beta1.RolloutPhaseCompleted)) }) It("Rollback V1->V2: Delete BatchRelease, Percentage, 100%, Succeeded", func() { By("Creating BatchRelease...") - release := &rolloutsv1alpha1.BatchRelease{} + release := &rolloutsv1beta1.BatchRelease{} Expect(ReadYamlToObject("./test_data/batchrelease/deployment_percentage_100.yaml", release)).ToNot(HaveOccurred()) CreateObject(release) @@ -1152,7 +1152,7 @@ var _ = SIGDescribe("BatchRelease", func() { CreateObject(deployment) WaitDeploymentAllPodsReady(deployment) Expect(GetObject(release.Namespace, release.Name, release)) - Expect(release.Status.Phase).Should(Equal(rolloutsv1alpha1.RolloutPhaseHealthy)) + Expect(release.Status.Phase).Should(Equal(rolloutsv1beta1.RolloutPhaseHealthy)) // record stable revision --> v1 stableRevisionV1 := workloads.ComputeHash(&deployment.Spec.Template, deployment.Status.CollisionCount) @@ -1169,7 +1169,7 @@ var _ = SIGDescribe("BatchRelease", func() { By("Waiting a minute and checking failed revision...") time.Sleep(time.Minute) for i := 0; i < 30; i++ { - fetchedRelease := &rolloutsv1alpha1.BatchRelease{} + fetchedRelease := &rolloutsv1beta1.BatchRelease{} Expect(GetObject(release.Namespace, release.Name, fetchedRelease)).NotTo(HaveOccurred()) Expect(fetchedRelease.Status.CanaryStatus.CurrentBatch).Should(Equal(int32(0))) time.Sleep(time.Second) @@ -1185,7 +1185,7 @@ var _ = SIGDescribe("BatchRelease", func() { By("Deleting BatchReleasing...") DeleteObject(release) Eventually(func() bool { - objectCopy := &rolloutsv1alpha1.BatchRelease{} + objectCopy := &rolloutsv1beta1.BatchRelease{} err := GetObject(release.Namespace, release.Name, objectCopy) return errors.IsNotFound(err) }, time.Minute, time.Second).Should(BeTrue()) @@ -1198,7 +1198,7 @@ var _ = SIGDescribe("BatchRelease", func() { It("Plan changed during rollout", func() { By("Creating BatchRelease...") - release := &rolloutsv1alpha1.BatchRelease{} + release := &rolloutsv1beta1.BatchRelease{} Expect(ReadYamlToObject("./test_data/batchrelease/deployment_percentage_100.yaml", release)).ToNot(HaveOccurred()) CreateObject(release) @@ -1214,7 +1214,7 @@ var _ = SIGDescribe("BatchRelease", func() { CreateObject(deployment) WaitDeploymentAllPodsReady(deployment) Expect(GetObject(release.Namespace, release.Name, release)) - Expect(release.Status.Phase).Should(Equal(rolloutsv1alpha1.RolloutPhaseHealthy)) + Expect(release.Status.Phase).Should(Equal(rolloutsv1beta1.RolloutPhaseHealthy)) // record stable revision --> v1 stableRevision := workloads.ComputeHash(&deployment.Spec.Template, deployment.Status.CollisionCount) @@ -1228,16 +1228,16 @@ var _ = SIGDescribe("BatchRelease", func() { Expect(canaryRevision).ShouldNot(Equal(stableRevision)) WaitBatchReleaseProgressing(release) - var fetchedRelease *rolloutsv1alpha1.BatchRelease + var fetchedRelease *rolloutsv1beta1.BatchRelease Eventually(func() bool { - fetchedRelease = &rolloutsv1alpha1.BatchRelease{} + fetchedRelease = &rolloutsv1beta1.BatchRelease{} Expect(GetObject(release.Namespace, release.Name, fetchedRelease)).NotTo(HaveOccurred()) return fetchedRelease.Status.CanaryStatus.CurrentBatch == 1 && - fetchedRelease.Status.CanaryStatus.CurrentBatchState == rolloutsv1alpha1.ReadyBatchState + fetchedRelease.Status.CanaryStatus.CurrentBatchState == rolloutsv1beta1.ReadyBatchState }, time.Minute, 5*time.Second).Should(BeTrue()) // now canary: 4 - fetchedRelease.Spec.ReleasePlan.Batches = []rolloutsv1alpha1.ReleaseBatch{ + fetchedRelease.Spec.ReleasePlan.Batches = []rolloutsv1beta1.ReleaseBatch{ { CanaryReplicas: intstr.FromInt(4), }, @@ -1250,11 +1250,11 @@ var _ = SIGDescribe("BatchRelease", func() { UpdateRelease(fetchedRelease) By("Checking BatchRelease status...") - Eventually(func() rolloutsv1alpha1.RolloutPhase { - clone := &rolloutsv1alpha1.BatchRelease{} + Eventually(func() rolloutsv1beta1.RolloutPhase { + clone := &rolloutsv1beta1.BatchRelease{} Expect(GetObject(release.Namespace, release.Name, clone)).NotTo(HaveOccurred()) return clone.Status.Phase - }, 15*time.Minute, 5*time.Second).Should(Equal(rolloutsv1alpha1.RolloutPhaseCompleted)) + }, 15*time.Minute, 5*time.Second).Should(Equal(rolloutsv1beta1.RolloutPhaseCompleted)) By("Checking all pod were updated when release completed...") Expect(GetObject(deployment.Namespace, deployment.Name, deployment)).NotTo(HaveOccurred()) diff --git a/test/e2e/deployment_test.go b/test/e2e/deployment_test.go index b857f929..8797ae17 100644 --- a/test/e2e/deployment_test.go +++ b/test/e2e/deployment_test.go @@ -20,7 +20,7 @@ import ( "k8s.io/utils/pointer" "sigs.k8s.io/controller-runtime/pkg/client" - rolloutsv1alpha1 "github.com/openkruise/rollouts/api/v1alpha1" + rolloutsv1beta1 "github.com/openkruise/rollouts/api/v1beta1" "github.com/openkruise/rollouts/pkg/util" ) @@ -59,9 +59,9 @@ var _ = SIGDescribe("Advanced Deployment", func() { clone.Spec.Template.Spec.Containers[0].Image = images[0] } clone.Spec.Template.Spec.Containers[0].Env[0].Value = version - strategy := unmarshal(clone.Annotations[rolloutsv1alpha1.DeploymentStrategyAnnotation]) + strategy := unmarshal(clone.Annotations[rolloutsv1beta1.DeploymentStrategyAnnotation]) strategy.Paused = true - clone.Annotations[rolloutsv1alpha1.DeploymentStrategyAnnotation] = marshal(strategy) + clone.Annotations[rolloutsv1beta1.DeploymentStrategyAnnotation] = marshal(strategy) return k8sClient.Update(context.TODO(), clone) })).NotTo(HaveOccurred()) @@ -84,13 +84,13 @@ var _ = SIGDescribe("Advanced Deployment", func() { if err != nil { return err } - strategy := unmarshal(clone.Annotations[rolloutsv1alpha1.DeploymentStrategyAnnotation]) + strategy := unmarshal(clone.Annotations[rolloutsv1beta1.DeploymentStrategyAnnotation]) if reflect.DeepEqual(desired, strategy.Partition) { return nil } strategy.Paused = false strategy.Partition = desired - clone.Annotations[rolloutsv1alpha1.DeploymentStrategyAnnotation] = marshal(strategy) + clone.Annotations[rolloutsv1beta1.DeploymentStrategyAnnotation] = marshal(strategy) return k8sClient.Update(context.TODO(), clone) })).NotTo(HaveOccurred()) return clone @@ -189,7 +189,7 @@ var _ = SIGDescribe("Advanced Deployment", func() { UpdatePartitionWithCheck := func(deployment *apps.Deployment, desired intstr.IntOrString) { By(fmt.Sprintf("update deployment %v to desired: %v, strategy: %v, and check", - client.ObjectKeyFromObject(deployment), deployment.Annotations[rolloutsv1alpha1.DeploymentStrategyAnnotation], desired)) + client.ObjectKeyFromObject(deployment), deployment.Annotations[rolloutsv1beta1.DeploymentStrategyAnnotation], desired)) clone := UpdatePartitionWithoutCheck(deployment, desired) count := 5 for count > 0 { @@ -268,7 +268,7 @@ var _ = SIGDescribe("Advanced Deployment", func() { deployment := &apps.Deployment{} deployment.Namespace = namespace Expect(ReadYamlToObject("./test_data/deployment/deployment.yaml", deployment)).ToNot(HaveOccurred()) - deployment.Annotations[rolloutsv1alpha1.DeploymentStrategyAnnotation] = + deployment.Annotations[rolloutsv1beta1.DeploymentStrategyAnnotation] = `{"rollingStyle":"Partition","rollingUpdate":{"maxUnavailable":0,"maxSurge":1}}` CreateObject(deployment) CheckReplicas(deployment, 5, 5, 5) @@ -283,7 +283,7 @@ var _ = SIGDescribe("Advanced Deployment", func() { deployment := &apps.Deployment{} deployment.Namespace = namespace Expect(ReadYamlToObject("./test_data/deployment/deployment.yaml", deployment)).ToNot(HaveOccurred()) - deployment.Annotations[rolloutsv1alpha1.DeploymentStrategyAnnotation] = + deployment.Annotations[rolloutsv1beta1.DeploymentStrategyAnnotation] = `{"rollingStyle":"Partition","rollingUpdate":{"maxUnavailable":1,"maxSurge":0}}` deployment.Spec.MinReadySeconds = 10 CreateObject(deployment) @@ -344,13 +344,13 @@ var _ = SIGDescribe("Advanced Deployment", func() { }) }) -func unmarshal(strategyAnno string) *rolloutsv1alpha1.DeploymentStrategy { - strategy := &rolloutsv1alpha1.DeploymentStrategy{} +func unmarshal(strategyAnno string) *rolloutsv1beta1.DeploymentStrategy { + strategy := &rolloutsv1beta1.DeploymentStrategy{} _ = json.Unmarshal([]byte(strategyAnno), strategy) return strategy } -func marshal(strategy *rolloutsv1alpha1.DeploymentStrategy) string { +func marshal(strategy *rolloutsv1beta1.DeploymentStrategy) string { strategyAnno, _ := json.Marshal(strategy) return string(strategyAnno) } diff --git a/test/e2e/rollout_test.go b/test/e2e/rollout_test.go index 69d90967..374a79d1 100644 --- a/test/e2e/rollout_test.go +++ b/test/e2e/rollout_test.go @@ -27,7 +27,7 @@ import ( . "github.com/onsi/gomega" appsv1alpha1 "github.com/openkruise/kruise-api/apps/v1alpha1" appsv1beta1 "github.com/openkruise/kruise-api/apps/v1beta1" - "github.com/openkruise/rollouts/api/v1alpha1" + "github.com/openkruise/rollouts/api/v1beta1" "github.com/openkruise/rollouts/pkg/util" apps "k8s.io/api/apps/v1" v1 "k8s.io/api/core/v1" @@ -51,10 +51,10 @@ var _ = SIGDescribe("Rollout", func() { var namespace string DumpAllResources := func() { - rollout := &v1alpha1.RolloutList{} + rollout := &v1beta1.RolloutList{} k8sClient.List(context.TODO(), rollout, client.InNamespace(namespace)) fmt.Println(util.DumpJSON(rollout)) - batch := &v1alpha1.BatchReleaseList{} + batch := &v1beta1.BatchReleaseList{} k8sClient.List(context.TODO(), batch, client.InNamespace(namespace)) fmt.Println(util.DumpJSON(batch)) deploy := &apps.DeploymentList{} @@ -176,10 +176,10 @@ var _ = SIGDescribe("Rollout", func() { return clone } - UpdateRollout := func(object *v1alpha1.Rollout) *v1alpha1.Rollout { - var clone *v1alpha1.Rollout + UpdateRollout := func(object *v1beta1.Rollout) *v1beta1.Rollout { + var clone *v1beta1.Rollout Expect(retry.RetryOnConflict(retry.DefaultRetry, func() error { - clone = &v1alpha1.Rollout{} + clone = &v1beta1.Rollout{} err := GetObject(object.Name, clone) if err != nil { return err @@ -193,14 +193,14 @@ var _ = SIGDescribe("Rollout", func() { ResumeRolloutCanary := func(name string) { Eventually(func() bool { - clone := &v1alpha1.Rollout{} + clone := &v1beta1.Rollout{} Expect(GetObject(name, clone)).NotTo(HaveOccurred()) - if clone.Status.CanaryStatus.CurrentStepState != v1alpha1.CanaryStepStatePaused { + if clone.Status.CanaryStatus.CurrentStepState != v1beta1.CanaryStepStatePaused { fmt.Println("resume rollout success, and CurrentStepState", util.DumpJSON(clone.Status)) return true } - body := fmt.Sprintf(`{"status":{"canaryStatus":{"currentStepState":"%s"}}}`, v1alpha1.CanaryStepStateReady) + body := fmt.Sprintf(`{"status":{"canaryStatus":{"currentStepState":"%s"}}}`, v1beta1.CanaryStepStateReady) Expect(k8sClient.Status().Patch(context.TODO(), clone, client.RawPatch(types.MergePatchType, []byte(body)))).NotTo(HaveOccurred()) return false }, 10*time.Second, time.Second).Should(BeTrue()) @@ -268,19 +268,19 @@ var _ = SIGDescribe("Rollout", func() { DumpAllResources() Expect(true).Should(BeFalse()) } - clone := &v1alpha1.Rollout{} + clone := &v1beta1.Rollout{} Expect(GetObject(name, clone)).NotTo(HaveOccurred()) if clone.Status.CanaryStatus == nil { return false } klog.Infof("current step:%v target step:%v current step state %v", clone.Status.CanaryStatus.CurrentStepIndex, stepIndex, clone.Status.CanaryStatus.CurrentStepState) - return clone.Status.CanaryStatus.CurrentStepIndex == stepIndex && clone.Status.CanaryStatus.CurrentStepState == v1alpha1.CanaryStepStatePaused + return clone.Status.CanaryStatus.CurrentStepIndex == stepIndex && clone.Status.CanaryStatus.CurrentStepState == v1beta1.CanaryStepStatePaused }, 20*time.Minute, time.Second).Should(BeTrue()) } - WaitRolloutStatusPhase := func(name string, phase v1alpha1.RolloutPhase) { + WaitRolloutStatusPhase := func(name string, phase v1beta1.RolloutPhase) { Eventually(func() bool { - clone := &v1alpha1.Rollout{} + clone := &v1beta1.Rollout{} Expect(GetObject(name, clone)).NotTo(HaveOccurred()) return clone.Status.Phase == phase }, 20*time.Minute, time.Second).Should(BeTrue()) @@ -288,7 +288,7 @@ var _ = SIGDescribe("Rollout", func() { WaitRolloutWorkloadGeneration := func(name string, generation int64) { Eventually(func() bool { - clone := &v1alpha1.Rollout{} + clone := &v1beta1.Rollout{} Expect(GetObject(name, clone)).NotTo(HaveOccurred()) return clone.Status.CanaryStatus.ObservedWorkloadGeneration == generation }, time.Minute, time.Second).Should(BeTrue()) @@ -296,7 +296,7 @@ var _ = SIGDescribe("Rollout", func() { WaitRolloutNotFound := func(name string) { Eventually(func() bool { - clone := &v1alpha1.Rollout{} + clone := &v1beta1.Rollout{} err := GetObject(name, clone) if err == nil { return false @@ -347,8 +347,8 @@ var _ = SIGDescribe("Rollout", func() { count := 0 for _, pod := range pods { - if pod.Labels[v1alpha1.RolloutIDLabel] == rolloutID && - pod.Labels[v1alpha1.RolloutBatchIDLabel] == batchID { + if pod.Labels[v1beta1.RolloutIDLabel] == rolloutID && + pod.Labels[v1beta1.RolloutBatchIDLabel] == batchID { count++ } } @@ -403,8 +403,8 @@ var _ = SIGDescribe("Rollout", func() { By("[TEST] Clean up resources after an integration test") k8sClient.DeleteAllOf(context.TODO(), &apps.Deployment{}, client.InNamespace(namespace)) k8sClient.DeleteAllOf(context.TODO(), &appsv1alpha1.CloneSet{}, client.InNamespace(namespace)) - k8sClient.DeleteAllOf(context.TODO(), &v1alpha1.BatchRelease{}, client.InNamespace(namespace)) - k8sClient.DeleteAllOf(context.TODO(), &v1alpha1.Rollout{}, client.InNamespace(namespace)) + k8sClient.DeleteAllOf(context.TODO(), &v1beta1.BatchRelease{}, client.InNamespace(namespace)) + k8sClient.DeleteAllOf(context.TODO(), &v1beta1.Rollout{}, client.InNamespace(namespace)) k8sClient.DeleteAllOf(context.TODO(), &v1.Service{}, client.InNamespace(namespace)) k8sClient.DeleteAllOf(context.TODO(), &netv1.Ingress{}, client.InNamespace(namespace)) Expect(k8sClient.Delete(context.TODO(), &v1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: namespace}}, client.PropagationPolicy(metav1.DeletePropagationForeground))).Should(Succeed()) @@ -414,36 +414,36 @@ var _ = SIGDescribe("Rollout", func() { KruiseDescribe("Deployment canary rollout with Ingress", func() { It("Deployment V1->V2: Percentage 20%,40%,60%,80%,90%, and replicas=3", func() { By("Creating Rollout...") - rollout := &v1alpha1.Rollout{} + rollout := &v1beta1.Rollout{} Expect(ReadYamlToObject("./test_data/rollout/rollout_canary_base.yaml", rollout)).ToNot(HaveOccurred()) - rollout.Spec.Strategy.Canary.Steps = []v1alpha1.CanaryStep{ + rollout.Spec.Strategy.Canary.Steps = []v1beta1.CanaryStep{ { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(20), }, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(40), }, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(60), }, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(80), }, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(90), }, }, } - rollout.Spec.Strategy.Canary.PatchPodTemplateMetadata = &v1alpha1.PatchPodTemplateMetadata{ + rollout.Spec.Strategy.Canary.PatchPodTemplateMetadata = &v1beta1.PatchPodTemplateMetadata{ Labels: map[string]string{"pod": "canary"}, Annotations: map[string]string{"pod": "canary"}, } @@ -471,7 +471,7 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseHealthy)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseHealthy)) By("check rollout status & paused success") // v1 -> v2, start rollout action @@ -544,7 +544,7 @@ var _ = SIGDescribe("Rollout", func() { // resume rollout ResumeRolloutCanary(rollout.Name) - WaitRolloutStatusPhase(rollout.Name, v1alpha1.RolloutPhaseHealthy) + WaitRolloutStatusPhase(rollout.Name, v1beta1.RolloutPhaseHealthy) By("rollout completed, and check") // check service & ingress & deployment // ingress @@ -569,10 +569,10 @@ var _ = SIGDescribe("Rollout", func() { } // check progressing succeed Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - cond := util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionProgressing) - Expect(cond.Reason).Should(Equal(v1alpha1.ProgressingReasonCompleted)) + cond := util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionProgressing) + Expect(cond.Reason).Should(Equal(v1beta1.ProgressingReasonCompleted)) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionFalse))) - cond = util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionSucceeded) + cond = util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionSucceeded) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionTrue))) Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) WaitRolloutWorkloadGeneration(rollout.Name, workload.Generation) @@ -581,22 +581,22 @@ var _ = SIGDescribe("Rollout", func() { It("V1->V2: Percentage 20%,60% Succeeded", func() { finder := util.NewControllerFinder(k8sClient) By("Creating Rollout...") - rollout := &v1alpha1.Rollout{} + rollout := &v1beta1.Rollout{} Expect(ReadYamlToObject("./test_data/rollout/rollout_canary_base.yaml", rollout)).ToNot(HaveOccurred()) replicas := intstr.FromInt(2) - rollout.Spec.Strategy.Canary.Steps = []v1alpha1.CanaryStep{ + rollout.Spec.Strategy.Canary.Steps = []v1beta1.CanaryStep{ { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(20), }, Replicas: &replicas, - Pause: v1alpha1.RolloutPause{}, + Pause: v1beta1.RolloutPause{}, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(60), }, - Pause: v1alpha1.RolloutPause{}, + Pause: v1beta1.RolloutPause{}, }, } CreateObject(rollout) @@ -623,7 +623,7 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseHealthy)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseHealthy)) Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(stableRevision)) By("check rollout status & paused success") @@ -676,7 +676,7 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseProgressing)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseProgressing)) Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(stableRevision)) Expect(rollout.Status.CanaryStatus.CurrentStepIndex).Should(BeNumerically("==", 1)) Expect(rollout.Status.CanaryStatus.CanaryReplicas).Should(BeNumerically("==", 2)) @@ -707,7 +707,7 @@ var _ = SIGDescribe("Rollout", func() { // resume rollout ResumeRolloutCanary(rollout.Name) - WaitRolloutStatusPhase(rollout.Name, v1alpha1.RolloutPhaseHealthy) + WaitRolloutStatusPhase(rollout.Name, v1beta1.RolloutPhaseHealthy) By("rollout completed, and check") // check service & ingress & deployment // ingress @@ -737,10 +737,10 @@ var _ = SIGDescribe("Rollout", func() { // check progressing succeed Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - cond := util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionProgressing) - Expect(cond.Reason).Should(Equal(v1alpha1.ProgressingReasonCompleted)) + cond := util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionProgressing) + Expect(cond.Reason).Should(Equal(v1beta1.ProgressingReasonCompleted)) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionFalse))) - cond = util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionSucceeded) + cond = util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionSucceeded) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionTrue))) Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) //Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(canaryRevision)) @@ -760,7 +760,7 @@ var _ = SIGDescribe("Rollout", func() { It("V1->V2: Percentage 20%, and rollback-v1", func() { finder := util.NewControllerFinder(k8sClient) By("Creating Rollout...") - rollout := &v1alpha1.Rollout{} + rollout := &v1beta1.Rollout{} Expect(ReadYamlToObject("./test_data/rollout/rollout_canary_base.yaml", rollout)).ToNot(HaveOccurred()) CreateObject(rollout) @@ -792,7 +792,7 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseHealthy)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseHealthy)) Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(stableRevision)) By("check rollout status & paused success") @@ -819,7 +819,7 @@ var _ = SIGDescribe("Rollout", func() { UpdateDeployment(workload) By("Rollback deployment env NODE_NAME from(version2) -> to(version1)") - WaitRolloutStatusPhase(rollout.Name, v1alpha1.RolloutPhaseHealthy) + WaitRolloutStatusPhase(rollout.Name, v1beta1.RolloutPhaseHealthy) klog.Infof("rollout(%s) completed, and check", namespace) time.Sleep(time.Second * 10) @@ -855,10 +855,10 @@ var _ = SIGDescribe("Rollout", func() { // check progressing canceled Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - cond := util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionProgressing) - Expect(cond.Reason).Should(Equal(v1alpha1.ProgressingReasonCompleted)) + cond := util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionProgressing) + Expect(cond.Reason).Should(Equal(v1beta1.ProgressingReasonCompleted)) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionFalse))) - cond = util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionSucceeded) + cond = util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionSucceeded) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionFalse))) Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(stableRevision)) WaitRolloutWorkloadGeneration(rollout.Name, workload.Generation) @@ -867,7 +867,7 @@ var _ = SIGDescribe("Rollout", func() { It("V1->V2: Percentage 20%,40% and continuous release v3", func() { finder := util.NewControllerFinder(k8sClient) By("Creating Rollout...") - rollout := &v1alpha1.Rollout{} + rollout := &v1beta1.Rollout{} Expect(ReadYamlToObject("./test_data/rollout/rollout_canary_base.yaml", rollout)).ToNot(HaveOccurred()) CreateObject(rollout) @@ -893,7 +893,7 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseHealthy)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseHealthy)) Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(stableRevision)) By("check rollout status & paused success") @@ -923,7 +923,7 @@ var _ = SIGDescribe("Rollout", func() { canaryRevisionV1 := crss[0].Labels[apps.DefaultDeploymentUniqueLabelKey] // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseProgressing)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseProgressing)) Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(stableRevision)) Expect(rollout.Status.CanaryStatus.PodTemplateHash).Should(Equal(canaryRevisionV1)) Expect(rollout.Status.CanaryStatus.CurrentStepIndex).Should(BeNumerically("==", 1)) @@ -950,7 +950,7 @@ var _ = SIGDescribe("Rollout", func() { canaryRevisionV2 := crss[0].Labels[apps.DefaultDeploymentUniqueLabelKey] // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseProgressing)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseProgressing)) Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(stableRevision)) Expect(rollout.Status.CanaryStatus.PodTemplateHash).Should(Equal(canaryRevisionV2)) Expect(rollout.Status.CanaryStatus.CanaryReplicas).Should(BeNumerically("==", 1)) @@ -983,7 +983,7 @@ var _ = SIGDescribe("Rollout", func() { // resume rollout canary ResumeRolloutCanary(rollout.Name) By("check rollout canary status success, resume rollout, and wait rollout canary complete") - WaitRolloutStatusPhase(rollout.Name, v1alpha1.RolloutPhaseHealthy) + WaitRolloutStatusPhase(rollout.Name, v1beta1.RolloutPhaseHealthy) klog.Infof("rollout(%s) completed, and check", namespace) // check service & ingress & deployment @@ -1009,10 +1009,10 @@ var _ = SIGDescribe("Rollout", func() { } // check progressing succeed Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - cond := util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionProgressing) - Expect(cond.Reason).Should(Equal(v1alpha1.ProgressingReasonCompleted)) + cond := util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionProgressing) + Expect(cond.Reason).Should(Equal(v1beta1.ProgressingReasonCompleted)) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionFalse))) - cond = util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionSucceeded) + cond = util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionSucceeded) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionTrue))) Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) WaitRolloutWorkloadGeneration(rollout.Name, workload.Generation) @@ -1021,36 +1021,36 @@ var _ = SIGDescribe("Rollout", func() { It("V1->V2: Percentage 20%,40% and scale up replicas from(5) -> to(10)", func() { finder := util.NewControllerFinder(k8sClient) By("Creating Rollout...") - rollout := &v1alpha1.Rollout{} + rollout := &v1beta1.Rollout{} Expect(ReadYamlToObject("./test_data/rollout/rollout_canary_base.yaml", rollout)).ToNot(HaveOccurred()) - rollout.Spec.Strategy.Canary.Steps = []v1alpha1.CanaryStep{ + rollout.Spec.Strategy.Canary.Steps = []v1beta1.CanaryStep{ { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(20), }, - Pause: v1alpha1.RolloutPause{ + Pause: v1beta1.RolloutPause{ Duration: utilpointer.Int32(10), }, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(40), }, - Pause: v1alpha1.RolloutPause{}, + Pause: v1beta1.RolloutPause{}, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(60), }, - Pause: v1alpha1.RolloutPause{ + Pause: v1beta1.RolloutPause{ Duration: utilpointer.Int32(10), }, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(100), }, - Pause: v1alpha1.RolloutPause{ + Pause: v1beta1.RolloutPause{ Duration: utilpointer.Int32(0), }, }, @@ -1073,7 +1073,7 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseHealthy)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseHealthy)) By("check rollout status & paused success") // v1 -> v2, start rollout action @@ -1099,7 +1099,7 @@ var _ = SIGDescribe("Rollout", func() { canaryRevision := crss[0].Labels[apps.DefaultDeploymentUniqueLabelKey] // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseProgressing)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseProgressing)) Expect(rollout.Status.CanaryStatus.CurrentStepIndex).Should(BeNumerically("==", 2)) Expect(rollout.Status.CanaryStatus.PodTemplateHash).Should(Equal(canaryRevision)) @@ -1113,17 +1113,17 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseProgressing)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseProgressing)) Expect(rollout.Status.CanaryStatus.CurrentStepIndex).Should(BeNumerically("==", 2)) Expect(rollout.Status.CanaryStatus.CanaryReplicas).Should(BeNumerically("==", 4)) Expect(rollout.Status.CanaryStatus.CanaryReadyReplicas).Should(BeNumerically("==", 4)) - Expect(rollout.Status.CanaryStatus.CurrentStepState).Should(Equal(v1alpha1.CanaryStepStatePaused)) + Expect(rollout.Status.CanaryStatus.CurrentStepState).Should(Equal(v1beta1.CanaryStepStatePaused)) Expect(rollout.Status.CanaryStatus.PodTemplateHash).Should(Equal(canaryRevision)) // resume rollout canary ResumeRolloutCanary(rollout.Name) By("check rollout canary status success, resume rollout, and wait rollout canary complete") - WaitRolloutStatusPhase(rollout.Name, v1alpha1.RolloutPhaseHealthy) + WaitRolloutStatusPhase(rollout.Name, v1beta1.RolloutPhaseHealthy) klog.Infof("rollout(%s) completed, and check", namespace) // check service & ingress & deployment @@ -1149,10 +1149,10 @@ var _ = SIGDescribe("Rollout", func() { } // check progressing succeed Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - cond := util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionProgressing) - Expect(cond.Reason).Should(Equal(v1alpha1.ProgressingReasonCompleted)) + cond := util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionProgressing) + Expect(cond.Reason).Should(Equal(v1beta1.ProgressingReasonCompleted)) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionFalse))) - cond = util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionSucceeded) + cond = util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionSucceeded) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionTrue))) Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) //Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(canaryRevision)) @@ -1162,36 +1162,36 @@ var _ = SIGDescribe("Rollout", func() { It("V1->V2: Percentage 20%,40%, and scale down replicas from(10) -> to(5)", func() { finder := util.NewControllerFinder(k8sClient) By("Creating Rollout...") - rollout := &v1alpha1.Rollout{} + rollout := &v1beta1.Rollout{} Expect(ReadYamlToObject("./test_data/rollout/rollout_canary_base.yaml", rollout)).ToNot(HaveOccurred()) - rollout.Spec.Strategy.Canary.Steps = []v1alpha1.CanaryStep{ + rollout.Spec.Strategy.Canary.Steps = []v1beta1.CanaryStep{ { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(20), }, - Pause: v1alpha1.RolloutPause{ + Pause: v1beta1.RolloutPause{ Duration: utilpointer.Int32(10), }, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(40), }, - Pause: v1alpha1.RolloutPause{ + Pause: v1beta1.RolloutPause{ Duration: utilpointer.Int32(10), }, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(60), }, - Pause: v1alpha1.RolloutPause{}, + Pause: v1beta1.RolloutPause{}, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(100), }, - Pause: v1alpha1.RolloutPause{ + Pause: v1beta1.RolloutPause{ Duration: utilpointer.Int32(0), }, }, @@ -1215,7 +1215,7 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseHealthy)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseHealthy)) By("check rollout status & paused success") // v1 -> v2, start rollout action @@ -1239,7 +1239,7 @@ var _ = SIGDescribe("Rollout", func() { canaryRevision := crss[0].Labels[apps.DefaultDeploymentUniqueLabelKey] // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseProgressing)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseProgressing)) Expect(rollout.Status.CanaryStatus.CurrentStepIndex).Should(BeNumerically("==", 3)) // scale up replicas, 10 -> 5 @@ -1250,17 +1250,17 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseProgressing)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseProgressing)) Expect(rollout.Status.CanaryStatus.CurrentStepIndex).Should(BeNumerically("==", 3)) Expect(rollout.Status.CanaryStatus.CanaryReplicas).Should(BeNumerically("==", 6)) Expect(rollout.Status.CanaryStatus.CanaryReadyReplicas).Should(BeNumerically("==", 6)) - Expect(rollout.Status.CanaryStatus.CurrentStepState).Should(Equal(v1alpha1.CanaryStepStatePaused)) + Expect(rollout.Status.CanaryStatus.CurrentStepState).Should(Equal(v1beta1.CanaryStepStatePaused)) Expect(rollout.Status.CanaryStatus.PodTemplateHash).Should(Equal(canaryRevision)) // resume rollout canary ResumeRolloutCanary(rollout.Name) By("check rollout canary status success, resume rollout, and wait rollout canary complete") - WaitRolloutStatusPhase(rollout.Name, v1alpha1.RolloutPhaseHealthy) + WaitRolloutStatusPhase(rollout.Name, v1beta1.RolloutPhaseHealthy) By("rollout completed, and check") // check service & ingress & deployment @@ -1286,10 +1286,10 @@ var _ = SIGDescribe("Rollout", func() { } // check progressing succeed Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - cond := util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionProgressing) - Expect(cond.Reason).Should(Equal(v1alpha1.ProgressingReasonCompleted)) + cond := util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionProgressing) + Expect(cond.Reason).Should(Equal(v1beta1.ProgressingReasonCompleted)) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionFalse))) - cond = util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionSucceeded) + cond = util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionSucceeded) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionTrue))) Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) //Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(canaryRevision)) @@ -1299,46 +1299,46 @@ var _ = SIGDescribe("Rollout", func() { It("V1->V2: Percentage 20%,40%, paused and resume", func() { finder := util.NewControllerFinder(k8sClient) By("Creating Rollout...") - rollout := &v1alpha1.Rollout{} + rollout := &v1beta1.Rollout{} Expect(ReadYamlToObject("./test_data/rollout/rollout_canary_base.yaml", rollout)).ToNot(HaveOccurred()) - rollout.Spec.Strategy.Canary.Steps = []v1alpha1.CanaryStep{ + rollout.Spec.Strategy.Canary.Steps = []v1beta1.CanaryStep{ { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(20), }, - Pause: v1alpha1.RolloutPause{ + Pause: v1beta1.RolloutPause{ Duration: utilpointer.Int32(5), }, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(40), }, - Pause: v1alpha1.RolloutPause{ + Pause: v1beta1.RolloutPause{ Duration: utilpointer.Int32(5), }, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(60), }, - Pause: v1alpha1.RolloutPause{ + Pause: v1beta1.RolloutPause{ Duration: utilpointer.Int32(5), }, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(80), }, - Pause: v1alpha1.RolloutPause{ + Pause: v1beta1.RolloutPause{ Duration: utilpointer.Int32(5), }, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(100), }, - Pause: v1alpha1.RolloutPause{ + Pause: v1beta1.RolloutPause{ Duration: utilpointer.Int32(0), }, }, @@ -1366,7 +1366,7 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseHealthy)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseHealthy)) Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(stableRevision)) By("check rollout status & paused success") @@ -1388,21 +1388,21 @@ var _ = SIGDescribe("Rollout", func() { UpdateRollout(rollout) // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseProgressing)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseProgressing)) cIndex := rollout.Status.CanaryStatus.CurrentStepIndex time.Sleep(time.Second * 15) // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - cond := util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionProgressing) - Expect(cond.Reason).Should(Equal(v1alpha1.ProgressingReasonPaused)) + cond := util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionProgressing) + Expect(cond.Reason).Should(Equal(v1beta1.ProgressingReasonPaused)) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionTrue))) Expect(rollout.Status.CanaryStatus.CurrentStepIndex).Should(BeNumerically("==", cIndex)) // resume rollout rollout.Spec.Strategy.Paused = false UpdateRollout(rollout) - WaitRolloutStatusPhase(rollout.Name, v1alpha1.RolloutPhaseHealthy) + WaitRolloutStatusPhase(rollout.Name, v1beta1.RolloutPhaseHealthy) klog.Infof("rollout(%s) completed, and check", namespace) // check service & ingress & deployment @@ -1428,10 +1428,10 @@ var _ = SIGDescribe("Rollout", func() { } // check progressing succeed Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - cond = util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionProgressing) - Expect(cond.Reason).Should(Equal(v1alpha1.ProgressingReasonCompleted)) + cond = util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionProgressing) + Expect(cond.Reason).Should(Equal(v1beta1.ProgressingReasonCompleted)) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionFalse))) - cond = util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionSucceeded) + cond = util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionSucceeded) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionTrue))) Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) WaitRolloutWorkloadGeneration(rollout.Name, workload.Generation) @@ -1440,30 +1440,30 @@ var _ = SIGDescribe("Rollout", func() { It("V1->V2: Percentage 20%,40%, but delete rollout crd", func() { finder := util.NewControllerFinder(k8sClient) By("Creating Rollout...") - rollout := &v1alpha1.Rollout{} + rollout := &v1beta1.Rollout{} Expect(ReadYamlToObject("./test_data/rollout/rollout_canary_base.yaml", rollout)).ToNot(HaveOccurred()) - rollout.Spec.Strategy.Canary.Steps = []v1alpha1.CanaryStep{ + rollout.Spec.Strategy.Canary.Steps = []v1beta1.CanaryStep{ { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(20), }, - Pause: v1alpha1.RolloutPause{ + Pause: v1beta1.RolloutPause{ Duration: utilpointer.Int32(10), }, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(60), }, - Pause: v1alpha1.RolloutPause{ + Pause: v1beta1.RolloutPause{ Duration: utilpointer.Int32(10), }, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(100), }, - Pause: v1alpha1.RolloutPause{ + Pause: v1beta1.RolloutPause{ Duration: utilpointer.Int32(10), }, }, @@ -1491,7 +1491,7 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseHealthy)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseHealthy)) Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(stableRevision)) By("check rollout status & paused success") @@ -1508,7 +1508,7 @@ var _ = SIGDescribe("Rollout", func() { By("check deployment status & paused success") // delete rollout - Expect(k8sClient.DeleteAllOf(context.TODO(), &v1alpha1.Rollout{}, client.InNamespace(namespace), client.PropagationPolicy(metav1.DeletePropagationForeground))).Should(Succeed()) + Expect(k8sClient.DeleteAllOf(context.TODO(), &v1beta1.Rollout{}, client.InNamespace(namespace), client.PropagationPolicy(metav1.DeletePropagationForeground))).Should(Succeed()) WaitRolloutNotFound(rollout.Name) Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) workload.Spec.Paused = false @@ -1541,30 +1541,30 @@ var _ = SIGDescribe("Rollout", func() { It("V1->V2: Percentage 20% v2 failed image, and v3 succeed image", func() { finder := util.NewControllerFinder(k8sClient) By("Creating Rollout...") - rollout := &v1alpha1.Rollout{} + rollout := &v1beta1.Rollout{} Expect(ReadYamlToObject("./test_data/rollout/rollout_canary_base.yaml", rollout)).ToNot(HaveOccurred()) - rollout.Spec.Strategy.Canary.Steps = []v1alpha1.CanaryStep{ + rollout.Spec.Strategy.Canary.Steps = []v1beta1.CanaryStep{ { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(20), }, - Pause: v1alpha1.RolloutPause{ + Pause: v1beta1.RolloutPause{ Duration: utilpointer.Int32(5), }, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(60), }, - Pause: v1alpha1.RolloutPause{ + Pause: v1beta1.RolloutPause{ Duration: utilpointer.Int32(5), }, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(100), }, - Pause: v1alpha1.RolloutPause{ + Pause: v1beta1.RolloutPause{ Duration: utilpointer.Int32(5), }, }, @@ -1592,7 +1592,7 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseHealthy)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseHealthy)) Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(stableRevision)) By("check rollout status & paused success") @@ -1611,11 +1611,11 @@ var _ = SIGDescribe("Rollout", func() { time.Sleep(time.Second * 10) // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseProgressing)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseProgressing)) Expect(rollout.Status.CanaryStatus.CurrentStepIndex).Should(BeNumerically("==", 1)) Expect(rollout.Status.CanaryStatus.CanaryReplicas).Should(BeNumerically("==", 1)) Expect(rollout.Status.CanaryStatus.CanaryReadyReplicas).Should(BeNumerically("==", 0)) - Expect(rollout.Status.CanaryStatus.CurrentStepState).Should(Equal(v1alpha1.CanaryStepStateUpgrade)) + Expect(rollout.Status.CanaryStatus.CurrentStepState).Should(Equal(v1beta1.CanaryStepStateUpgrade)) // update success image, v3 newEnvs = mergeEnvVar(workload.Spec.Template.Spec.Containers[0].Env, v1.EnvVar{Name: "NODE_NAME", Value: "version3"}) @@ -1624,7 +1624,7 @@ var _ = SIGDescribe("Rollout", func() { UpdateDeployment(workload) By("Update deployment image from(v2) -> to(v3)") // wait rollout complete - WaitRolloutStatusPhase(rollout.Name, v1alpha1.RolloutPhaseHealthy) + WaitRolloutStatusPhase(rollout.Name, v1beta1.RolloutPhaseHealthy) klog.Infof("rollout(%s) completed, and check", namespace) // check service & ingress & deployment @@ -1650,10 +1650,10 @@ var _ = SIGDescribe("Rollout", func() { } // check progressing succeed Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - cond := util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionProgressing) - Expect(cond.Reason).Should(Equal(v1alpha1.ProgressingReasonCompleted)) + cond := util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionProgressing) + Expect(cond.Reason).Should(Equal(v1beta1.ProgressingReasonCompleted)) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionFalse))) - cond = util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionSucceeded) + cond = util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionSucceeded) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionTrue))) Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) WaitRolloutWorkloadGeneration(rollout.Name, workload.Generation) @@ -1662,7 +1662,7 @@ var _ = SIGDescribe("Rollout", func() { It("V1->V2: Percentage, 20%,40%,60%,80%,100%, steps changed v1", func() { finder := util.NewControllerFinder(k8sClient) By("Creating Rollout...") - rollout := &v1alpha1.Rollout{} + rollout := &v1beta1.Rollout{} Expect(ReadYamlToObject("./test_data/rollout/rollout_canary_base.yaml", rollout)).ToNot(HaveOccurred()) CreateObject(rollout) By("Creating workload and waiting for all pods ready...") @@ -1695,24 +1695,24 @@ var _ = SIGDescribe("Rollout", func() { WaitRolloutCanaryStepPaused(rollout.Name, 1) // update rollout step configuration - rollout.Spec.Strategy.Canary.Steps = []v1alpha1.CanaryStep{ + rollout.Spec.Strategy.Canary.Steps = []v1beta1.CanaryStep{ { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(10), }, - Pause: v1alpha1.RolloutPause{}, + Pause: v1beta1.RolloutPause{}, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(30), }, - Pause: v1alpha1.RolloutPause{}, + Pause: v1beta1.RolloutPause{}, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(100), }, - Pause: v1alpha1.RolloutPause{ + Pause: v1beta1.RolloutPause{ Duration: utilpointer.Int32(5), }, }, @@ -1721,7 +1721,7 @@ var _ = SIGDescribe("Rollout", func() { By("update rollout configuration, and wait rollout next step(2)") // wait step 1 complete WaitRolloutCanaryStepPaused(rollout.Name, 2) - batch := &v1alpha1.BatchRelease{} + batch := &v1beta1.BatchRelease{} Expect(GetObject(rollout.Name, batch)).NotTo(HaveOccurred()) // canary deployment @@ -1733,7 +1733,7 @@ var _ = SIGDescribe("Rollout", func() { canaryRevision := crss[0].Labels[apps.DefaultDeploymentUniqueLabelKey] // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseProgressing)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseProgressing)) Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(stableRevision)) Expect(rollout.Status.CanaryStatus.PodTemplateHash).Should(Equal(canaryRevision)) Expect(rollout.Status.CanaryStatus.CurrentStepIndex).Should(BeNumerically("==", 2)) @@ -1759,7 +1759,7 @@ var _ = SIGDescribe("Rollout", func() { // resume rollout canary ResumeRolloutCanary(rollout.Name) // wait rollout complete - WaitRolloutStatusPhase(rollout.Name, v1alpha1.RolloutPhaseHealthy) + WaitRolloutStatusPhase(rollout.Name, v1beta1.RolloutPhaseHealthy) klog.Infof("rollout(%s) completed, and check", namespace) // check service & ingress & deployment @@ -1785,10 +1785,10 @@ var _ = SIGDescribe("Rollout", func() { } // check progressing succeed Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - cond := util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionProgressing) - Expect(cond.Reason).Should(Equal(v1alpha1.ProgressingReasonCompleted)) + cond := util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionProgressing) + Expect(cond.Reason).Should(Equal(v1beta1.ProgressingReasonCompleted)) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionFalse))) - cond = util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionSucceeded) + cond = util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionSucceeded) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionTrue))) Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) WaitRolloutWorkloadGeneration(rollout.Name, workload.Generation) @@ -1797,15 +1797,15 @@ var _ = SIGDescribe("Rollout", func() { It("V1->V2: A/B testing, header & cookies", func() { finder := util.NewControllerFinder(k8sClient) By("Creating Rollout...") - rollout := &v1alpha1.Rollout{} + rollout := &v1beta1.Rollout{} Expect(ReadYamlToObject("./test_data/rollout/rollout_canary_base.yaml", rollout)).ToNot(HaveOccurred()) headerType := gatewayv1alpha2.HeaderMatchRegularExpression replica1 := intstr.FromInt(1) replica2 := intstr.FromInt(2) - rollout.Spec.Strategy.Canary.Steps = []v1alpha1.CanaryStep{ + rollout.Spec.Strategy.Canary.Steps = []v1beta1.CanaryStep{ { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ - Matches: []v1alpha1.HttpRouteMatch{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ + Matches: []v1beta1.HttpRouteMatch{ { Headers: []gatewayv1alpha2.HTTPHeaderMatch{ { @@ -1825,15 +1825,15 @@ var _ = SIGDescribe("Rollout", func() { }, }, }, - Pause: v1alpha1.RolloutPause{}, + Pause: v1beta1.RolloutPause{}, Replicas: &replica1, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(30), }, Replicas: &replica2, - Pause: v1alpha1.RolloutPause{}, + Pause: v1beta1.RolloutPause{}, }, } CreateObject(rollout) @@ -1875,7 +1875,7 @@ var _ = SIGDescribe("Rollout", func() { canaryRevision := crss[0].Labels[apps.DefaultDeploymentUniqueLabelKey] // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseProgressing)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseProgressing)) Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(stableRevision)) Expect(rollout.Status.CanaryStatus.PodTemplateHash).Should(Equal(canaryRevision)) Expect(rollout.Status.CanaryStatus.CurrentStepIndex).Should(BeNumerically("==", 1)) @@ -1922,7 +1922,7 @@ var _ = SIGDescribe("Rollout", func() { // resume rollout canary ResumeRolloutCanary(rollout.Name) // wait rollout complete - WaitRolloutStatusPhase(rollout.Name, v1alpha1.RolloutPhaseHealthy) + WaitRolloutStatusPhase(rollout.Name, v1beta1.RolloutPhaseHealthy) klog.Infof("rollout(%s) completed, and check", namespace) // check service & ingress & deployment // ingress @@ -1947,10 +1947,10 @@ var _ = SIGDescribe("Rollout", func() { } // check progressing succeed Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - cond := util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionProgressing) - Expect(cond.Reason).Should(Equal(v1alpha1.ProgressingReasonCompleted)) + cond := util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionProgressing) + Expect(cond.Reason).Should(Equal(v1beta1.ProgressingReasonCompleted)) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionFalse))) - cond = util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionSucceeded) + cond = util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionSucceeded) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionTrue))) Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) WaitRolloutWorkloadGeneration(rollout.Name, workload.Generation) @@ -1964,14 +1964,14 @@ var _ = SIGDescribe("Rollout", func() { defer k8sClient.Delete(context.TODO(), configmap) By("Creating Rollout...") - rollout := &v1alpha1.Rollout{} + rollout := &v1beta1.Rollout{} Expect(ReadYamlToObject("./test_data/rollout/rollout_canary_base.yaml", rollout)).ToNot(HaveOccurred()) replica1 := intstr.FromInt(1) replica2 := intstr.FromInt(2) - rollout.Spec.Strategy.Canary.Steps = []v1alpha1.CanaryStep{ + rollout.Spec.Strategy.Canary.Steps = []v1beta1.CanaryStep{ { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ - Matches: []v1alpha1.HttpRouteMatch{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ + Matches: []v1beta1.HttpRouteMatch{ { Headers: []gatewayv1alpha2.HTTPHeaderMatch{ { @@ -1990,15 +1990,15 @@ var _ = SIGDescribe("Rollout", func() { }, }, }, - Pause: v1alpha1.RolloutPause{}, + Pause: v1beta1.RolloutPause{}, Replicas: &replica1, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(30), }, Replicas: &replica2, - Pause: v1alpha1.RolloutPause{}, + Pause: v1beta1.RolloutPause{}, }, } rollout.Spec.Strategy.Canary.TrafficRoutings[0].Ingress.ClassType = "aliyun-alb" @@ -2043,7 +2043,7 @@ var _ = SIGDescribe("Rollout", func() { canaryRevision := crss[0].Labels[apps.DefaultDeploymentUniqueLabelKey] // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseProgressing)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseProgressing)) Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(stableRevision)) Expect(rollout.Status.CanaryStatus.PodTemplateHash).Should(Equal(canaryRevision)) Expect(rollout.Status.CanaryStatus.CurrentStepIndex).Should(BeNumerically("==", 1)) @@ -2086,7 +2086,7 @@ var _ = SIGDescribe("Rollout", func() { // resume rollout canary ResumeRolloutCanary(rollout.Name) // wait rollout complete - WaitRolloutStatusPhase(rollout.Name, v1alpha1.RolloutPhaseHealthy) + WaitRolloutStatusPhase(rollout.Name, v1beta1.RolloutPhaseHealthy) klog.Infof("rollout(%s) completed, and check", namespace) // check service & ingress & deployment // ingress @@ -2111,10 +2111,10 @@ var _ = SIGDescribe("Rollout", func() { } // check progressing succeed Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - cond := util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionProgressing) - Expect(cond.Reason).Should(Equal(v1alpha1.ProgressingReasonCompleted)) + cond := util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionProgressing) + Expect(cond.Reason).Should(Equal(v1beta1.ProgressingReasonCompleted)) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionFalse))) - cond = util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionSucceeded) + cond = util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionSucceeded) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionTrue))) Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) WaitRolloutWorkloadGeneration(rollout.Name, workload.Generation) @@ -2131,19 +2131,19 @@ var _ = SIGDescribe("Rollout", func() { defer k8sClient.Delete(context.TODO(), configmap) By("Creating Rollout...") - rollout := &v1alpha1.Rollout{} + rollout := &v1beta1.Rollout{} Expect(ReadYamlToObject("./test_data/rollout/rollout_canary_base.yaml", rollout)).ToNot(HaveOccurred()) replica1 := intstr.FromInt(1) replica2 := intstr.FromInt(3) - rollout.Spec.ObjectRef.WorkloadRef = &v1alpha1.WorkloadRef{ + rollout.Spec.ObjectRef.WorkloadRef = &v1beta1.WorkloadRef{ APIVersion: "apps.kruise.io/v1alpha1", Kind: "CloneSet", Name: "echoserver", } - rollout.Spec.Strategy.Canary.Steps = []v1alpha1.CanaryStep{ + rollout.Spec.Strategy.Canary.Steps = []v1beta1.CanaryStep{ { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ - Matches: []v1alpha1.HttpRouteMatch{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ + Matches: []v1beta1.HttpRouteMatch{ { Headers: []gatewayv1alpha2.HTTPHeaderMatch{ { @@ -2162,12 +2162,12 @@ var _ = SIGDescribe("Rollout", func() { }, }, }, - Pause: v1alpha1.RolloutPause{}, + Pause: v1beta1.RolloutPause{}, Replicas: &replica1, }, { Replicas: &replica2, - Pause: v1alpha1.RolloutPause{}, + Pause: v1beta1.RolloutPause{}, }, } rollout.Spec.Strategy.Canary.TrafficRoutings[0].Ingress.ClassType = "aliyun-alb" @@ -2192,7 +2192,7 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseHealthy)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseHealthy)) Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(workload.Status.CurrentRevision[strings.LastIndex(workload.Status.CurrentRevision, "-")+1:])) stableRevision := rollout.Status.CanaryStatus.StableRevision By("check rollout status & paused success") @@ -2215,7 +2215,7 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseProgressing)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseProgressing)) Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(stableRevision)) Expect(rollout.Status.CanaryStatus.CanaryRevision).Should(Equal(workload.Status.UpdateRevision[strings.LastIndex(workload.Status.UpdateRevision, "-")+1:])) Expect(rollout.Status.CanaryStatus.PodTemplateHash).Should(Equal(workload.Status.UpdateRevision[strings.LastIndex(workload.Status.UpdateRevision, "-")+1:])) @@ -2260,7 +2260,7 @@ var _ = SIGDescribe("Rollout", func() { // resume rollout to complete ResumeRolloutCanary(rollout.Name) - WaitRolloutStatusPhase(rollout.Name, v1alpha1.RolloutPhaseHealthy) + WaitRolloutStatusPhase(rollout.Name, v1beta1.RolloutPhaseHealthy) WaitCloneSetAllPodsReady(workload) By("rollout completed, and check") @@ -2285,10 +2285,10 @@ var _ = SIGDescribe("Rollout", func() { // check progressing succeed Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - cond := util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionProgressing) - Expect(cond.Reason).Should(Equal(v1alpha1.ProgressingReasonCompleted)) + cond := util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionProgressing) + Expect(cond.Reason).Should(Equal(v1beta1.ProgressingReasonCompleted)) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionFalse))) - cond = util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionSucceeded) + cond = util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionSucceeded) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionTrue))) Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) WaitRolloutWorkloadGeneration(rollout.Name, workload.Generation) @@ -2298,31 +2298,31 @@ var _ = SIGDescribe("Rollout", func() { KruiseDescribe("Canary rollout with Gateway API", func() { It("V1->V2: Percentage 20%,40%,60%,80%,90%, and replicas=3", func() { By("Creating Rollout...") - rollout := &v1alpha1.Rollout{} + rollout := &v1beta1.Rollout{} Expect(ReadYamlToObject("./test_data/gateway/rollout-test.yaml", rollout)).ToNot(HaveOccurred()) - rollout.Spec.Strategy.Canary.Steps = []v1alpha1.CanaryStep{ + rollout.Spec.Strategy.Canary.Steps = []v1beta1.CanaryStep{ { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(20), }, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(40), }, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(60), }, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(80), }, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(90), }, }, @@ -2347,7 +2347,7 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseHealthy)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseHealthy)) By("check rollout status & paused success") // v1 -> v2, start rollout action @@ -2427,7 +2427,7 @@ var _ = SIGDescribe("Rollout", func() { // resume rollout ResumeRolloutCanary(rollout.Name) - WaitRolloutStatusPhase(rollout.Name, v1alpha1.RolloutPhaseHealthy) + WaitRolloutStatusPhase(rollout.Name, v1beta1.RolloutPhaseHealthy) By("rollout completed, and check") // check service & httproute & deployment // httproute @@ -2453,10 +2453,10 @@ var _ = SIGDescribe("Rollout", func() { } // check progressing succeed Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - cond := util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionProgressing) - Expect(cond.Reason).Should(Equal(v1alpha1.ProgressingReasonCompleted)) + cond := util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionProgressing) + Expect(cond.Reason).Should(Equal(v1beta1.ProgressingReasonCompleted)) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionFalse))) - cond = util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionSucceeded) + cond = util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionSucceeded) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionTrue))) Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) WaitRolloutWorkloadGeneration(rollout.Name, workload.Generation) @@ -2466,23 +2466,23 @@ var _ = SIGDescribe("Rollout", func() { KruiseDescribe("CloneSet canary rollout with Ingress", func() { It("CloneSet V1->V2: Percentage, 20%,60% Succeeded", func() { By("Creating Rollout...") - rollout := &v1alpha1.Rollout{} + rollout := &v1beta1.Rollout{} Expect(ReadYamlToObject("./test_data/rollout/rollout_canary_base.yaml", rollout)).ToNot(HaveOccurred()) - rollout.Spec.Strategy.Canary.Steps = []v1alpha1.CanaryStep{ + rollout.Spec.Strategy.Canary.Steps = []v1beta1.CanaryStep{ { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(20), }, - Pause: v1alpha1.RolloutPause{}, + Pause: v1beta1.RolloutPause{}, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(60), }, - Pause: v1alpha1.RolloutPause{}, + Pause: v1beta1.RolloutPause{}, }, } - rollout.Spec.ObjectRef.WorkloadRef = &v1alpha1.WorkloadRef{ + rollout.Spec.ObjectRef.WorkloadRef = &v1beta1.WorkloadRef{ APIVersion: "apps.kruise.io/v1alpha1", Kind: "CloneSet", Name: "echoserver", @@ -2507,7 +2507,7 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseHealthy)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseHealthy)) Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(workload.Status.CurrentRevision[strings.LastIndex(workload.Status.CurrentRevision, "-")+1:])) stableRevision := rollout.Status.CanaryStatus.StableRevision By("check rollout status & paused success") @@ -2529,7 +2529,7 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseProgressing)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseProgressing)) Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(stableRevision)) Expect(rollout.Status.CanaryStatus.CanaryRevision).Should(Equal(workload.Status.UpdateRevision[strings.LastIndex(workload.Status.UpdateRevision, "-")+1:])) Expect(rollout.Status.CanaryStatus.PodTemplateHash).Should(Equal(workload.Status.UpdateRevision[strings.LastIndex(workload.Status.UpdateRevision, "-")+1:])) @@ -2568,7 +2568,7 @@ var _ = SIGDescribe("Rollout", func() { // resume rollout ResumeRolloutCanary(rollout.Name) - WaitRolloutStatusPhase(rollout.Name, v1alpha1.RolloutPhaseHealthy) + WaitRolloutStatusPhase(rollout.Name, v1beta1.RolloutPhaseHealthy) WaitCloneSetAllPodsReady(workload) By("rollout completed, and check") @@ -2600,10 +2600,10 @@ var _ = SIGDescribe("Rollout", func() { // check progressing succeed Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - cond := util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionProgressing) - Expect(cond.Reason).Should(Equal(v1alpha1.ProgressingReasonCompleted)) + cond := util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionProgressing) + Expect(cond.Reason).Should(Equal(v1beta1.ProgressingReasonCompleted)) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionFalse))) - cond = util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionSucceeded) + cond = util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionSucceeded) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionTrue))) WaitRolloutWorkloadGeneration(rollout.Name, workload.Generation) //Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(canaryRevision)) @@ -2621,9 +2621,9 @@ var _ = SIGDescribe("Rollout", func() { It("V1->V2: Percentage, 20%, and rollback(v1)", func() { By("Creating Rollout...") - rollout := &v1alpha1.Rollout{} + rollout := &v1beta1.Rollout{} Expect(ReadYamlToObject("./test_data/rollout/rollout_canary_base.yaml", rollout)).ToNot(HaveOccurred()) - rollout.Spec.ObjectRef.WorkloadRef = &v1alpha1.WorkloadRef{ + rollout.Spec.ObjectRef.WorkloadRef = &v1beta1.WorkloadRef{ APIVersion: "apps.kruise.io/v1alpha1", Kind: "CloneSet", Name: "echoserver", @@ -2649,7 +2649,7 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseHealthy)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseHealthy)) Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(workload.Status.CurrentRevision[strings.LastIndex(workload.Status.CurrentRevision, "-")+1:])) stableRevision := rollout.Status.CanaryStatus.StableRevision By("check rollout status & paused success") @@ -2672,12 +2672,12 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseProgressing)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseProgressing)) Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(stableRevision)) Expect(rollout.Status.CanaryStatus.CanaryRevision).Should(Equal(workload.Status.UpdateRevision[strings.LastIndex(workload.Status.UpdateRevision, "-")+1:])) Expect(rollout.Status.CanaryStatus.PodTemplateHash).Should(Equal(workload.Status.UpdateRevision[strings.LastIndex(workload.Status.UpdateRevision, "-")+1:])) Expect(rollout.Status.CanaryStatus.CurrentStepIndex).Should(BeNumerically("==", 1)) - Expect(rollout.Status.CanaryStatus.CurrentStepState).Should(Equal(v1alpha1.CanaryStepStateUpgrade)) + Expect(rollout.Status.CanaryStatus.CurrentStepState).Should(Equal(v1beta1.CanaryStepStateUpgrade)) Expect(rollout.Status.CanaryStatus.RolloutHash).Should(Equal(rollout.Annotations[util.RolloutHashAnnotation])) // resume rollout canary @@ -2692,15 +2692,15 @@ var _ = SIGDescribe("Rollout", func() { By("Rollback deployment env NODE_NAME from(version2) -> to(version1)") time.Sleep(time.Second * 2) - WaitRolloutStatusPhase(rollout.Name, v1alpha1.RolloutPhaseHealthy) + WaitRolloutStatusPhase(rollout.Name, v1beta1.RolloutPhaseHealthy) WaitCloneSetAllPodsReady(workload) By("rollout completed, and check") // check progressing canceled Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - cond := util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionProgressing) - Expect(cond.Reason).Should(Equal(v1alpha1.ProgressingReasonCompleted)) + cond := util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionProgressing) + Expect(cond.Reason).Should(Equal(v1beta1.ProgressingReasonCompleted)) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionFalse))) - cond = util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionSucceeded) + cond = util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionSucceeded) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionFalse))) Expect(string(cond.Status)).Should(Equal("False")) Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(stableRevision)) @@ -2732,9 +2732,9 @@ var _ = SIGDescribe("Rollout", func() { It("Cloneset V1->V2: Percentage, 20%,40% and continuous release v3", func() { By("Creating Rollout...") - rollout := &v1alpha1.Rollout{} + rollout := &v1beta1.Rollout{} Expect(ReadYamlToObject("./test_data/rollout/rollout_canary_base.yaml", rollout)).ToNot(HaveOccurred()) - rollout.Spec.ObjectRef.WorkloadRef = &v1alpha1.WorkloadRef{ + rollout.Spec.ObjectRef.WorkloadRef = &v1beta1.WorkloadRef{ APIVersion: "apps.kruise.io/v1alpha1", Kind: "CloneSet", Name: "echoserver", @@ -2759,7 +2759,7 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseHealthy)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseHealthy)) Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(workload.Status.CurrentRevision[strings.LastIndex(workload.Status.CurrentRevision, "-")+1:])) stableRevision := rollout.Status.CanaryStatus.StableRevision By("check rollout status & paused success") @@ -2782,7 +2782,7 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseProgressing)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseProgressing)) Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(stableRevision)) Expect(rollout.Status.CanaryStatus.CanaryRevision).Should(Equal(workload.Status.UpdateRevision[strings.LastIndex(workload.Status.UpdateRevision, "-")+1:])) Expect(rollout.Status.CanaryStatus.PodTemplateHash).Should(Equal(workload.Status.UpdateRevision[strings.LastIndex(workload.Status.UpdateRevision, "-")+1:])) @@ -2806,7 +2806,7 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseProgressing)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseProgressing)) //Expect(rollout.Status.CanaryStatus.CanaryReplicas).Should(BeNumerically("==", 1)) //Expect(rollout.Status.CanaryStatus.CanaryReadyReplicas).Should(BeNumerically("==", 1)) Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(stableRevision)) @@ -2832,7 +2832,7 @@ var _ = SIGDescribe("Rollout", func() { // resume rollout canary ResumeRolloutCanary(rollout.Name) By("check rollout canary status success, resume rollout, and wait rollout canary complete") - WaitRolloutStatusPhase(rollout.Name, v1alpha1.RolloutPhaseHealthy) + WaitRolloutStatusPhase(rollout.Name, v1beta1.RolloutPhaseHealthy) WaitCloneSetAllPodsReady(workload) By("rollout completed, and check") @@ -2864,26 +2864,26 @@ var _ = SIGDescribe("Rollout", func() { // check progressing succeed Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - cond := util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionProgressing) - Expect(cond.Reason).Should(Equal(v1alpha1.ProgressingReasonCompleted)) + cond := util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionProgressing) + Expect(cond.Reason).Should(Equal(v1beta1.ProgressingReasonCompleted)) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionFalse))) - cond = util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionSucceeded) + cond = util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionSucceeded) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionTrue))) WaitRolloutWorkloadGeneration(rollout.Name, workload.Generation) }) It("V1->V2: disable quickly rollback policy without traffic routing", func() { By("Creating Rollout...") - rollout := &v1alpha1.Rollout{} + rollout := &v1beta1.Rollout{} Expect(ReadYamlToObject("./test_data/rollout/rollout_canary_base.yaml", rollout)).ToNot(HaveOccurred()) - rollout.Spec.ObjectRef.WorkloadRef = &v1alpha1.WorkloadRef{ + rollout.Spec.ObjectRef.WorkloadRef = &v1beta1.WorkloadRef{ APIVersion: "apps.kruise.io/v1alpha1", Kind: "CloneSet", Name: "echoserver", } rollout.Spec.Strategy.Canary.TrafficRoutings = nil rollout.Annotations = map[string]string{ - v1alpha1.RollbackInBatchAnnotation: "true", + v1beta1.RollbackInBatchAnnotation: "true", } CreateObject(rollout) @@ -2897,7 +2897,7 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseHealthy)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseHealthy)) Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(workload.Status.CurrentRevision[strings.LastIndex(workload.Status.CurrentRevision, "-")+1:])) stableRevision := rollout.Status.CanaryStatus.StableRevision By("check rollout status & paused success") @@ -2920,7 +2920,7 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseProgressing)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseProgressing)) Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(stableRevision)) Expect(rollout.Status.CanaryStatus.CanaryRevision).Should(Equal(workload.Status.UpdateRevision[strings.LastIndex(workload.Status.UpdateRevision, "-")+1:])) Expect(rollout.Status.CanaryStatus.PodTemplateHash).Should(Equal(workload.Status.UpdateRevision[strings.LastIndex(workload.Status.UpdateRevision, "-")+1:])) @@ -2942,7 +2942,7 @@ var _ = SIGDescribe("Rollout", func() { By("Wait step 2 paused") ResumeRolloutCanary(rollout.Name) By("check rollout canary status success, resume rollout, and wait rollout canary complete") - WaitRolloutStatusPhase(rollout.Name, v1alpha1.RolloutPhaseHealthy) + WaitRolloutStatusPhase(rollout.Name, v1beta1.RolloutPhaseHealthy) WaitCloneSetAllPodsReady(workload) By("rollout completed, and check") @@ -2961,19 +2961,19 @@ var _ = SIGDescribe("Rollout", func() { // check progressing succeed Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - cond := util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionProgressing) - Expect(cond.Reason).Should(Equal(v1alpha1.ProgressingReasonCompleted)) + cond := util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionProgressing) + Expect(cond.Reason).Should(Equal(v1beta1.ProgressingReasonCompleted)) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionFalse))) - cond = util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionSucceeded) + cond = util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionSucceeded) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionTrue))) WaitRolloutWorkloadGeneration(rollout.Name, workload.Generation) }) It("CloneSet V1->V2: Percentage, 20%,40%,60%,80%,100%, no traffic, Succeeded", func() { By("Creating Rollout...") - rollout := &v1alpha1.Rollout{} + rollout := &v1beta1.Rollout{} Expect(ReadYamlToObject("./test_data/rollout/rollout_canary_base.yaml", rollout)).ToNot(HaveOccurred()) - rollout.Spec.ObjectRef.WorkloadRef = &v1alpha1.WorkloadRef{ + rollout.Spec.ObjectRef.WorkloadRef = &v1beta1.WorkloadRef{ APIVersion: "apps.kruise.io/v1alpha1", Kind: "CloneSet", Name: "echoserver", @@ -3005,7 +3005,7 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseHealthy)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseHealthy)) Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(workload.Status.CurrentRevision[strings.LastIndex(workload.Status.CurrentRevision, "-")+1:])) stableRevision := rollout.Status.CanaryStatus.StableRevision By("check rollout status & paused success") @@ -3027,7 +3027,7 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseProgressing)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseProgressing)) Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(stableRevision)) Expect(rollout.Status.CanaryStatus.CanaryRevision).Should(Equal(workload.Status.UpdateRevision[strings.LastIndex(workload.Status.UpdateRevision, "-")+1:])) Expect(rollout.Status.CanaryStatus.PodTemplateHash).Should(Equal(workload.Status.UpdateRevision[strings.LastIndex(workload.Status.UpdateRevision, "-")+1:])) @@ -3037,7 +3037,7 @@ var _ = SIGDescribe("Rollout", func() { // resume rollout ResumeRolloutCanary(rollout.Name) - WaitRolloutStatusPhase(rollout.Name, v1alpha1.RolloutPhaseHealthy) + WaitRolloutStatusPhase(rollout.Name, v1beta1.RolloutPhaseHealthy) WaitCloneSetAllPodsReady(workload) By("rollout completed, and check") @@ -3054,10 +3054,10 @@ var _ = SIGDescribe("Rollout", func() { // check progressing succeed Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - cond := util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionProgressing) - Expect(cond.Reason).Should(Equal(v1alpha1.ProgressingReasonCompleted)) + cond := util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionProgressing) + Expect(cond.Reason).Should(Equal(v1beta1.ProgressingReasonCompleted)) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionFalse))) - cond = util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionSucceeded) + cond = util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionSucceeded) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionTrue))) WaitRolloutWorkloadGeneration(rollout.Name, workload.Generation) //Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(canaryRevision)) @@ -3079,23 +3079,23 @@ var _ = SIGDescribe("Rollout", func() { KruiseDescribe("Native StatefulSet rollout canary with Ingress", func() { It("V1->V2: Percentage, 20%,60% Succeeded", func() { By("Creating Rollout...") - rollout := &v1alpha1.Rollout{} + rollout := &v1beta1.Rollout{} Expect(ReadYamlToObject("./test_data/rollout/rollout_canary_base.yaml", rollout)).ToNot(HaveOccurred()) - rollout.Spec.Strategy.Canary.Steps = []v1alpha1.CanaryStep{ + rollout.Spec.Strategy.Canary.Steps = []v1beta1.CanaryStep{ { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(20), }, - Pause: v1alpha1.RolloutPause{}, + Pause: v1beta1.RolloutPause{}, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(60), }, - Pause: v1alpha1.RolloutPause{}, + Pause: v1beta1.RolloutPause{}, }, } - rollout.Spec.ObjectRef.WorkloadRef = &v1alpha1.WorkloadRef{ + rollout.Spec.ObjectRef.WorkloadRef = &v1beta1.WorkloadRef{ APIVersion: "apps/v1", Kind: "StatefulSet", Name: "echoserver", @@ -3124,7 +3124,7 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseHealthy)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseHealthy)) Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(workload.Status.CurrentRevision)) stableRevision := rollout.Status.CanaryStatus.StableRevision By("check rollout status & paused success") @@ -3146,7 +3146,7 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseProgressing)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseProgressing)) Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(stableRevision)) Expect(rollout.Status.CanaryStatus.CanaryRevision).Should(Equal(workload.Status.UpdateRevision)) Expect(rollout.Status.CanaryStatus.PodTemplateHash).Should(Equal(workload.Status.UpdateRevision)) @@ -3185,7 +3185,7 @@ var _ = SIGDescribe("Rollout", func() { // resume rollout ResumeRolloutCanary(rollout.Name) - WaitRolloutStatusPhase(rollout.Name, v1alpha1.RolloutPhaseHealthy) + WaitRolloutStatusPhase(rollout.Name, v1beta1.RolloutPhaseHealthy) WaitNativeStatefulSetPodsReady(workload) By("rollout completed, and check") @@ -3215,10 +3215,10 @@ var _ = SIGDescribe("Rollout", func() { // check progressing succeed Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - cond := util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionProgressing) - Expect(cond.Reason).Should(Equal(v1alpha1.ProgressingReasonCompleted)) + cond := util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionProgressing) + Expect(cond.Reason).Should(Equal(v1beta1.ProgressingReasonCompleted)) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionFalse))) - cond = util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionSucceeded) + cond = util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionSucceeded) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionTrue))) WaitRolloutWorkloadGeneration(rollout.Name, workload.Generation) //Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(canaryRevision)) @@ -3236,9 +3236,9 @@ var _ = SIGDescribe("Rollout", func() { It("V1->V2: Percentage, 20%,40% and continuous release v3", func() { By("Creating Rollout...") - rollout := &v1alpha1.Rollout{} + rollout := &v1beta1.Rollout{} Expect(ReadYamlToObject("./test_data/rollout/rollout_canary_base.yaml", rollout)).ToNot(HaveOccurred()) - rollout.Spec.ObjectRef.WorkloadRef = &v1alpha1.WorkloadRef{ + rollout.Spec.ObjectRef.WorkloadRef = &v1beta1.WorkloadRef{ APIVersion: "apps/v1", Kind: "StatefulSet", Name: "echoserver", @@ -3266,7 +3266,7 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseHealthy)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseHealthy)) Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(workload.Status.CurrentRevision)) stableRevision := rollout.Status.CanaryStatus.StableRevision By("check rollout status & paused success") @@ -3287,7 +3287,7 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseProgressing)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseProgressing)) Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(stableRevision)) Expect(rollout.Status.CanaryStatus.CanaryRevision).Should(Equal(workload.Status.UpdateRevision)) Expect(rollout.Status.CanaryStatus.PodTemplateHash).Should(Equal(workload.Status.UpdateRevision)) @@ -3311,7 +3311,7 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseProgressing)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseProgressing)) Expect(rollout.Status.CanaryStatus.CanaryReplicas).Should(BeNumerically("==", 1)) Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(stableRevision)) Expect(rollout.Status.CanaryStatus.CanaryRevision).ShouldNot(Equal(canaryRevisionV1)) @@ -3336,7 +3336,7 @@ var _ = SIGDescribe("Rollout", func() { // resume rollout canary ResumeRolloutCanary(rollout.Name) By("check rollout canary status success, resume rollout, and wait rollout canary complete") - WaitRolloutStatusPhase(rollout.Name, v1alpha1.RolloutPhaseHealthy) + WaitRolloutStatusPhase(rollout.Name, v1beta1.RolloutPhaseHealthy) WaitNativeStatefulSetPodsReady(workload) By("rollout completed, and check") @@ -3365,19 +3365,19 @@ var _ = SIGDescribe("Rollout", func() { // check progressing succeed Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - cond := util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionProgressing) - Expect(cond.Reason).Should(Equal(v1alpha1.ProgressingReasonCompleted)) + cond := util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionProgressing) + Expect(cond.Reason).Should(Equal(v1beta1.ProgressingReasonCompleted)) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionFalse))) - cond = util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionSucceeded) + cond = util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionSucceeded) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionTrue))) WaitRolloutWorkloadGeneration(rollout.Name, workload.Generation) }) It("V1->V2: Percentage, 20%, and rollback(v1)", func() { By("Creating Rollout...") - rollout := &v1alpha1.Rollout{} + rollout := &v1beta1.Rollout{} Expect(ReadYamlToObject("./test_data/rollout/rollout_canary_base.yaml", rollout)).ToNot(HaveOccurred()) - rollout.Spec.ObjectRef.WorkloadRef = &v1alpha1.WorkloadRef{ + rollout.Spec.ObjectRef.WorkloadRef = &v1beta1.WorkloadRef{ APIVersion: "apps/v1", Kind: "StatefulSet", Name: "echoserver", @@ -3407,7 +3407,7 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseHealthy)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseHealthy)) Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(workload.Status.CurrentRevision)) stableRevision := rollout.Status.CanaryStatus.StableRevision By("check rollout status & paused success") @@ -3428,12 +3428,12 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseProgressing)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseProgressing)) Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(stableRevision)) Expect(rollout.Status.CanaryStatus.CanaryRevision).Should(Equal(workload.Status.UpdateRevision)) Expect(rollout.Status.CanaryStatus.PodTemplateHash).Should(Equal(workload.Status.UpdateRevision)) Expect(rollout.Status.CanaryStatus.CurrentStepIndex).Should(BeNumerically("==", 1)) - Expect(rollout.Status.CanaryStatus.CurrentStepState).Should(Equal(v1alpha1.CanaryStepStateUpgrade)) + Expect(rollout.Status.CanaryStatus.CurrentStepState).Should(Equal(v1beta1.CanaryStepStateUpgrade)) Expect(rollout.Status.CanaryStatus.RolloutHash).Should(Equal(rollout.Annotations[util.RolloutHashAnnotation])) // resume rollout canary @@ -3453,15 +3453,15 @@ var _ = SIGDescribe("Rollout", func() { Expect(GetObject(fmt.Sprintf("%v-%v", workload.Name, *workload.Spec.Replicas-1), brokenPod)).NotTo(HaveOccurred()) Expect(k8sClient.Delete(context.TODO(), brokenPod)).NotTo(HaveOccurred()) - WaitRolloutStatusPhase(rollout.Name, v1alpha1.RolloutPhaseHealthy) + WaitRolloutStatusPhase(rollout.Name, v1beta1.RolloutPhaseHealthy) WaitNativeStatefulSetPodsReady(workload) By("rollout completed, and check") // check progressing canceled Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - cond := util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionProgressing) - Expect(cond.Reason).Should(Equal(v1alpha1.ProgressingReasonCompleted)) + cond := util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionProgressing) + Expect(cond.Reason).Should(Equal(v1beta1.ProgressingReasonCompleted)) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionFalse))) - cond = util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionSucceeded) + cond = util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionSucceeded) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionFalse))) Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(stableRevision)) @@ -3490,9 +3490,9 @@ var _ = SIGDescribe("Rollout", func() { It("V1->V2: Percentage, 20%,40%,60%,80%,100%, no traffic, Succeeded", func() { By("Creating Rollout...") - rollout := &v1alpha1.Rollout{} + rollout := &v1beta1.Rollout{} Expect(ReadYamlToObject("./test_data/rollout/rollout_canary_base.yaml", rollout)).ToNot(HaveOccurred()) - rollout.Spec.ObjectRef.WorkloadRef = &v1alpha1.WorkloadRef{ + rollout.Spec.ObjectRef.WorkloadRef = &v1beta1.WorkloadRef{ APIVersion: "apps/v1", Kind: "StatefulSet", Name: "echoserver", @@ -3522,7 +3522,7 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseHealthy)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseHealthy)) Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(workload.Status.CurrentRevision)) stableRevision := rollout.Status.CanaryStatus.StableRevision By("check rollout status & paused success") @@ -3542,7 +3542,7 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseProgressing)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseProgressing)) Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(stableRevision)) Expect(rollout.Status.CanaryStatus.CanaryRevision).Should(Equal(workload.Status.UpdateRevision)) Expect(rollout.Status.CanaryStatus.PodTemplateHash).Should(Equal(workload.Status.UpdateRevision)) @@ -3552,7 +3552,7 @@ var _ = SIGDescribe("Rollout", func() { // resume rollout ResumeRolloutCanary(rollout.Name) - WaitRolloutStatusPhase(rollout.Name, v1alpha1.RolloutPhaseHealthy) + WaitRolloutStatusPhase(rollout.Name, v1beta1.RolloutPhaseHealthy) WaitNativeStatefulSetPodsReady(workload) By("rollout completed, and check") @@ -3566,10 +3566,10 @@ var _ = SIGDescribe("Rollout", func() { // check progressing succeed Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - cond := util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionProgressing) - Expect(cond.Reason).Should(Equal(v1alpha1.ProgressingReasonCompleted)) + cond := util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionProgressing) + Expect(cond.Reason).Should(Equal(v1beta1.ProgressingReasonCompleted)) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionFalse))) - cond = util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionSucceeded) + cond = util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionSucceeded) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionTrue))) WaitRolloutWorkloadGeneration(rollout.Name, workload.Generation) //Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(canaryRevision)) @@ -3589,23 +3589,23 @@ var _ = SIGDescribe("Rollout", func() { KruiseDescribe("Advanced StatefulSet rollout canary with Ingress", func() { It("V1->V2: Percentage, 20%,60% Succeeded", func() { By("Creating Rollout...") - rollout := &v1alpha1.Rollout{} + rollout := &v1beta1.Rollout{} Expect(ReadYamlToObject("./test_data/rollout/rollout_canary_base.yaml", rollout)).ToNot(HaveOccurred()) - rollout.Spec.Strategy.Canary.Steps = []v1alpha1.CanaryStep{ + rollout.Spec.Strategy.Canary.Steps = []v1beta1.CanaryStep{ { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(20), }, - Pause: v1alpha1.RolloutPause{}, + Pause: v1beta1.RolloutPause{}, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(60), }, - Pause: v1alpha1.RolloutPause{}, + Pause: v1beta1.RolloutPause{}, }, } - rollout.Spec.ObjectRef.WorkloadRef = &v1alpha1.WorkloadRef{ + rollout.Spec.ObjectRef.WorkloadRef = &v1beta1.WorkloadRef{ APIVersion: "apps.kruise.io/v1beta1", Kind: "StatefulSet", Name: "echoserver", @@ -3634,7 +3634,7 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseHealthy)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseHealthy)) Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(workload.Status.CurrentRevision)) stableRevision := rollout.Status.CanaryStatus.StableRevision By("check rollout status & paused success") @@ -3656,7 +3656,7 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseProgressing)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseProgressing)) Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(stableRevision)) Expect(rollout.Status.CanaryStatus.CanaryRevision).Should(Equal(workload.Status.UpdateRevision)) Expect(rollout.Status.CanaryStatus.PodTemplateHash).Should(Equal(workload.Status.UpdateRevision)) @@ -3696,7 +3696,7 @@ var _ = SIGDescribe("Rollout", func() { // resume rollout ResumeRolloutCanary(rollout.Name) - WaitRolloutStatusPhase(rollout.Name, v1alpha1.RolloutPhaseHealthy) + WaitRolloutStatusPhase(rollout.Name, v1beta1.RolloutPhaseHealthy) WaitAdvancedStatefulSetPodsReady(workload) By("rollout completed, and check") @@ -3726,10 +3726,10 @@ var _ = SIGDescribe("Rollout", func() { // check progressing succeed Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - cond := util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionProgressing) - Expect(cond.Reason).Should(Equal(v1alpha1.ProgressingReasonCompleted)) + cond := util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionProgressing) + Expect(cond.Reason).Should(Equal(v1beta1.ProgressingReasonCompleted)) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionFalse))) - cond = util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionSucceeded) + cond = util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionSucceeded) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionTrue))) WaitRolloutWorkloadGeneration(rollout.Name, workload.Generation) //Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(canaryRevision)) @@ -3747,9 +3747,9 @@ var _ = SIGDescribe("Rollout", func() { It("V1->V2: Percentage, 20%,40% and continuous release v3", func() { By("Creating Rollout...") - rollout := &v1alpha1.Rollout{} + rollout := &v1beta1.Rollout{} Expect(ReadYamlToObject("./test_data/rollout/rollout_canary_base.yaml", rollout)).ToNot(HaveOccurred()) - rollout.Spec.ObjectRef.WorkloadRef = &v1alpha1.WorkloadRef{ + rollout.Spec.ObjectRef.WorkloadRef = &v1beta1.WorkloadRef{ APIVersion: "apps.kruise.io/v1beta1", Kind: "StatefulSet", Name: "echoserver", @@ -3777,7 +3777,7 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseHealthy)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseHealthy)) Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(workload.Status.CurrentRevision)) stableRevision := rollout.Status.CanaryStatus.StableRevision By("check rollout status & paused success") @@ -3798,7 +3798,7 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseProgressing)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseProgressing)) Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(stableRevision)) Expect(rollout.Status.CanaryStatus.CanaryRevision).Should(Equal(workload.Status.UpdateRevision)) Expect(rollout.Status.CanaryStatus.PodTemplateHash).Should(Equal(workload.Status.UpdateRevision)) @@ -3822,7 +3822,7 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseProgressing)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseProgressing)) Expect(rollout.Status.CanaryStatus.CanaryReplicas).Should(BeNumerically("==", 1)) Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(stableRevision)) Expect(rollout.Status.CanaryStatus.CanaryRevision).ShouldNot(Equal(canaryRevisionV1)) @@ -3847,7 +3847,7 @@ var _ = SIGDescribe("Rollout", func() { // resume rollout canary ResumeRolloutCanary(rollout.Name) By("check rollout canary status success, resume rollout, and wait rollout canary complete") - WaitRolloutStatusPhase(rollout.Name, v1alpha1.RolloutPhaseHealthy) + WaitRolloutStatusPhase(rollout.Name, v1beta1.RolloutPhaseHealthy) WaitAdvancedStatefulSetPodsReady(workload) By("rollout completed, and check") @@ -3876,19 +3876,19 @@ var _ = SIGDescribe("Rollout", func() { // check progressing succeed Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - cond := util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionProgressing) - Expect(cond.Reason).Should(Equal(v1alpha1.ProgressingReasonCompleted)) + cond := util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionProgressing) + Expect(cond.Reason).Should(Equal(v1beta1.ProgressingReasonCompleted)) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionFalse))) - cond = util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionSucceeded) + cond = util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionSucceeded) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionTrue))) WaitRolloutWorkloadGeneration(rollout.Name, workload.Generation) }) It("V1->V2: Percentage, 20%, and rollback(v1)", func() { By("Creating Rollout...") - rollout := &v1alpha1.Rollout{} + rollout := &v1beta1.Rollout{} Expect(ReadYamlToObject("./test_data/rollout/rollout_canary_base.yaml", rollout)).ToNot(HaveOccurred()) - rollout.Spec.ObjectRef.WorkloadRef = &v1alpha1.WorkloadRef{ + rollout.Spec.ObjectRef.WorkloadRef = &v1beta1.WorkloadRef{ APIVersion: "apps.kruise.io/v1beta1", Kind: "StatefulSet", Name: "echoserver", @@ -3918,7 +3918,7 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseHealthy)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseHealthy)) Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(workload.Status.CurrentRevision)) stableRevision := rollout.Status.CanaryStatus.StableRevision By("check rollout status & paused success") @@ -3939,12 +3939,12 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseProgressing)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseProgressing)) Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(stableRevision)) Expect(rollout.Status.CanaryStatus.CanaryRevision).Should(Equal(workload.Status.UpdateRevision)) Expect(rollout.Status.CanaryStatus.PodTemplateHash).Should(Equal(workload.Status.UpdateRevision)) Expect(rollout.Status.CanaryStatus.CurrentStepIndex).Should(BeNumerically("==", 1)) - Expect(rollout.Status.CanaryStatus.CurrentStepState).Should(Equal(v1alpha1.CanaryStepStateUpgrade)) + Expect(rollout.Status.CanaryStatus.CurrentStepState).Should(Equal(v1beta1.CanaryStepStateUpgrade)) Expect(rollout.Status.CanaryStatus.RolloutHash).Should(Equal(rollout.Annotations[util.RolloutHashAnnotation])) // resume rollout canary @@ -3964,15 +3964,15 @@ var _ = SIGDescribe("Rollout", func() { Expect(GetObject(fmt.Sprintf("%v-%v", workload.Name, *workload.Spec.Replicas-1), brokenPod)).NotTo(HaveOccurred()) Expect(k8sClient.Delete(context.TODO(), brokenPod)).NotTo(HaveOccurred()) - WaitRolloutStatusPhase(rollout.Name, v1alpha1.RolloutPhaseHealthy) + WaitRolloutStatusPhase(rollout.Name, v1beta1.RolloutPhaseHealthy) WaitAdvancedStatefulSetPodsReady(workload) By("rollout completed, and check") // check progressing canceled Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - cond := util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionProgressing) - Expect(cond.Reason).Should(Equal(v1alpha1.ProgressingReasonCompleted)) + cond := util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionProgressing) + Expect(cond.Reason).Should(Equal(v1beta1.ProgressingReasonCompleted)) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionFalse))) - cond = util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionSucceeded) + cond = util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionSucceeded) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionFalse))) Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(stableRevision)) @@ -4001,9 +4001,9 @@ var _ = SIGDescribe("Rollout", func() { It("V1->V2: Percentage, 20%,40%,60%,80%,100%, no traffic, Succeeded", func() { By("Creating Rollout...") - rollout := &v1alpha1.Rollout{} + rollout := &v1beta1.Rollout{} Expect(ReadYamlToObject("./test_data/rollout/rollout_canary_base.yaml", rollout)).ToNot(HaveOccurred()) - rollout.Spec.ObjectRef.WorkloadRef = &v1alpha1.WorkloadRef{ + rollout.Spec.ObjectRef.WorkloadRef = &v1beta1.WorkloadRef{ APIVersion: "apps.kruise.io/v1beta1", Kind: "StatefulSet", Name: "echoserver", @@ -4033,7 +4033,7 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseHealthy)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseHealthy)) Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(workload.Status.CurrentRevision)) stableRevision := rollout.Status.CanaryStatus.StableRevision By("check rollout status & paused success") @@ -4053,7 +4053,7 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseProgressing)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseProgressing)) Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(stableRevision)) Expect(rollout.Status.CanaryStatus.CanaryRevision).Should(Equal(workload.Status.UpdateRevision)) Expect(rollout.Status.CanaryStatus.PodTemplateHash).Should(Equal(workload.Status.UpdateRevision)) @@ -4063,7 +4063,7 @@ var _ = SIGDescribe("Rollout", func() { // resume rollout ResumeRolloutCanary(rollout.Name) - WaitRolloutStatusPhase(rollout.Name, v1alpha1.RolloutPhaseHealthy) + WaitRolloutStatusPhase(rollout.Name, v1beta1.RolloutPhaseHealthy) WaitAdvancedStatefulSetPodsReady(workload) By("rollout completed, and check") @@ -4077,10 +4077,10 @@ var _ = SIGDescribe("Rollout", func() { // check progressing succeed Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - cond := util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionProgressing) - Expect(cond.Reason).Should(Equal(v1alpha1.ProgressingReasonCompleted)) + cond := util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionProgressing) + Expect(cond.Reason).Should(Equal(v1beta1.ProgressingReasonCompleted)) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionFalse))) - cond = util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionSucceeded) + cond = util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionSucceeded) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionTrue))) WaitRolloutWorkloadGeneration(rollout.Name, workload.Generation) //Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(canaryRevision)) @@ -4101,9 +4101,9 @@ var _ = SIGDescribe("Rollout", func() { KruiseDescribe("Others", func() { It("Patch batch id to pods: normal case", func() { By("Creating Rollout...") - rollout := &v1alpha1.Rollout{} + rollout := &v1beta1.Rollout{} Expect(ReadYamlToObject("./test_data/rollout/rollout_canary_base.yaml", rollout)).ToNot(HaveOccurred()) - rollout.Spec.ObjectRef.WorkloadRef = &v1alpha1.WorkloadRef{ + rollout.Spec.ObjectRef.WorkloadRef = &v1beta1.WorkloadRef{ APIVersion: "apps.kruise.io/v1beta1", Kind: "StatefulSet", Name: "echoserver", @@ -4127,7 +4127,7 @@ var _ = SIGDescribe("Rollout", func() { // workload workload := &appsv1beta1.StatefulSet{} Expect(ReadYamlToObject("./test_data/rollout/advanced_statefulset.yaml", workload)).ToNot(HaveOccurred()) - workload.Labels[v1alpha1.RolloutIDLabel] = "1" + workload.Labels[v1beta1.RolloutIDLabel] = "1" CreateObject(workload) WaitAdvancedStatefulSetPodsReady(workload) @@ -4150,7 +4150,7 @@ var _ = SIGDescribe("Rollout", func() { // resume rollout ResumeRolloutCanary(rollout.Name) By("check rollout canary status success, resume rollout, and wait rollout canary complete") - WaitRolloutStatusPhase(rollout.Name, v1alpha1.RolloutPhaseHealthy) + WaitRolloutStatusPhase(rollout.Name, v1beta1.RolloutPhaseHealthy) WaitAdvancedStatefulSetPodsReady(workload) // check batch id after rollout @@ -4164,41 +4164,41 @@ var _ = SIGDescribe("Rollout", func() { It("patch batch id to pods: scaling case", func() { By("Creating Rollout...") - rollout := &v1alpha1.Rollout{} + rollout := &v1beta1.Rollout{} Expect(ReadYamlToObject("./test_data/rollout/rollout_canary_base.yaml", rollout)).ToNot(HaveOccurred()) - rollout.Spec.ObjectRef.WorkloadRef = &v1alpha1.WorkloadRef{ + rollout.Spec.ObjectRef.WorkloadRef = &v1beta1.WorkloadRef{ APIVersion: "apps.kruise.io/v1alpha1", Kind: "CloneSet", Name: "echoserver", } - rollout.Spec.Strategy.Canary.Steps = []v1alpha1.CanaryStep{ + rollout.Spec.Strategy.Canary.Steps = []v1beta1.CanaryStep{ { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(20), }, - Pause: v1alpha1.RolloutPause{ + Pause: v1beta1.RolloutPause{ Duration: utilpointer.Int32(10), }, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(40), }, - Pause: v1alpha1.RolloutPause{}, + Pause: v1beta1.RolloutPause{}, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(60), }, - Pause: v1alpha1.RolloutPause{ + Pause: v1beta1.RolloutPause{ Duration: utilpointer.Int32(10), }, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(100), }, - Pause: v1alpha1.RolloutPause{ + Pause: v1beta1.RolloutPause{ Duration: utilpointer.Int32(10), }, }, @@ -4216,7 +4216,7 @@ var _ = SIGDescribe("Rollout", func() { // workload workload := &appsv1alpha1.CloneSet{} Expect(ReadYamlToObject("./test_data/rollout/cloneset.yaml", workload)).ToNot(HaveOccurred()) - workload.Labels[v1alpha1.RolloutIDLabel] = "1" + workload.Labels[v1beta1.RolloutIDLabel] = "1" CreateObject(workload) WaitCloneSetAllPodsReady(workload) @@ -4239,7 +4239,7 @@ var _ = SIGDescribe("Rollout", func() { workload.Spec.Replicas = utilpointer.Int32(10) UpdateCloneSet(workload) Eventually(func() bool { - object := &v1alpha1.Rollout{} + object := &v1beta1.Rollout{} Expect(GetObject(rollout.Name, object)).NotTo(HaveOccurred()) return object.Status.CanaryStatus.CanaryReadyReplicas == 4 }, 5*time.Minute, time.Second).Should(BeTrue()) @@ -4252,7 +4252,7 @@ var _ = SIGDescribe("Rollout", func() { // resume rollout canary By("check rollout canary status success, resume rollout, and wait rollout canary complete") ResumeRolloutCanary(rollout.Name) - WaitRolloutStatusPhase(rollout.Name, v1alpha1.RolloutPhaseHealthy) + WaitRolloutStatusPhase(rollout.Name, v1beta1.RolloutPhaseHealthy) WaitCloneSetAllPodsReady(workload) By("rollout completed, and check pod batch label") @@ -4264,47 +4264,47 @@ var _ = SIGDescribe("Rollout", func() { It("patch batch id to pods: rollback case", func() { By("Creating Rollout...") - rollout := &v1alpha1.Rollout{} + rollout := &v1beta1.Rollout{} Expect(ReadYamlToObject("./test_data/rollout/rollout_canary_base.yaml", rollout)).ToNot(HaveOccurred()) - rollout.Spec.ObjectRef.WorkloadRef = &v1alpha1.WorkloadRef{ + rollout.Spec.ObjectRef.WorkloadRef = &v1beta1.WorkloadRef{ APIVersion: "apps.kruise.io/v1alpha1", Kind: "CloneSet", Name: "echoserver", } rollout.Spec.Strategy.Canary.TrafficRoutings = nil rollout.Annotations = map[string]string{ - v1alpha1.RollbackInBatchAnnotation: "true", + v1beta1.RollbackInBatchAnnotation: "true", } - rollout.Spec.Strategy.Canary.Steps = []v1alpha1.CanaryStep{ + rollout.Spec.Strategy.Canary.Steps = []v1beta1.CanaryStep{ { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(20), }, - Pause: v1alpha1.RolloutPause{}, + Pause: v1beta1.RolloutPause{}, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(40), }, - Pause: v1alpha1.RolloutPause{}, + Pause: v1beta1.RolloutPause{}, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(60), }, - Pause: v1alpha1.RolloutPause{}, + Pause: v1beta1.RolloutPause{}, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(80), }, - Pause: v1alpha1.RolloutPause{}, + Pause: v1beta1.RolloutPause{}, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(100), }, - Pause: v1alpha1.RolloutPause{ + Pause: v1beta1.RolloutPause{ Duration: utilpointer.Int32(0), }, }, @@ -4314,7 +4314,7 @@ var _ = SIGDescribe("Rollout", func() { By("Creating workload and waiting for all pods ready...") workload := &appsv1alpha1.CloneSet{} Expect(ReadYamlToObject("./test_data/rollout/cloneset.yaml", workload)).ToNot(HaveOccurred()) - workload.Labels[v1alpha1.RolloutIDLabel] = "1" + workload.Labels[v1beta1.RolloutIDLabel] = "1" CreateObject(workload) WaitCloneSetAllPodsReady(workload) @@ -4343,7 +4343,7 @@ var _ = SIGDescribe("Rollout", func() { By("Update cloneSet env NODE_NAME from(version2) -> to(version1)") Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) newEnvs = mergeEnvVar(workload.Spec.Template.Spec.Containers[0].Env, v1.EnvVar{Name: "NODE_NAME", Value: "version1"}) - workload.Labels[v1alpha1.RolloutIDLabel] = "2" + workload.Labels[v1beta1.RolloutIDLabel] = "2" workload.Spec.Template.Spec.Containers[0].Env = newEnvs UpdateCloneSet(workload) time.Sleep(10 * time.Second) @@ -4370,7 +4370,7 @@ var _ = SIGDescribe("Rollout", func() { By("Wait rollout complete") ResumeRolloutCanary(rollout.Name) - WaitRolloutStatusPhase(rollout.Name, v1alpha1.RolloutPhaseHealthy) + WaitRolloutStatusPhase(rollout.Name, v1beta1.RolloutPhaseHealthy) CheckPodBatchLabel(workload.Namespace, workload.Spec.Selector, "2", "1", 1) CheckPodBatchLabel(workload.Namespace, workload.Spec.Selector, "2", "2", 1) CheckPodBatchLabel(workload.Namespace, workload.Spec.Selector, "2", "3", 1) @@ -4380,47 +4380,47 @@ var _ = SIGDescribe("Rollout", func() { It("patch batch id to pods: only rollout-id changes", func() { By("Creating Rollout...") - rollout := &v1alpha1.Rollout{} + rollout := &v1beta1.Rollout{} Expect(ReadYamlToObject("./test_data/rollout/rollout_canary_base.yaml", rollout)).ToNot(HaveOccurred()) - rollout.Spec.ObjectRef.WorkloadRef = &v1alpha1.WorkloadRef{ + rollout.Spec.ObjectRef.WorkloadRef = &v1beta1.WorkloadRef{ APIVersion: "apps.kruise.io/v1alpha1", Kind: "CloneSet", Name: "echoserver", } rollout.Spec.Strategy.Canary.TrafficRoutings = nil rollout.Annotations = map[string]string{ - v1alpha1.RollbackInBatchAnnotation: "true", + v1beta1.RollbackInBatchAnnotation: "true", } - rollout.Spec.Strategy.Canary.Steps = []v1alpha1.CanaryStep{ + rollout.Spec.Strategy.Canary.Steps = []v1beta1.CanaryStep{ { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(20), }, - Pause: v1alpha1.RolloutPause{}, + Pause: v1beta1.RolloutPause{}, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(40), }, - Pause: v1alpha1.RolloutPause{}, + Pause: v1beta1.RolloutPause{}, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(60), }, - Pause: v1alpha1.RolloutPause{}, + Pause: v1beta1.RolloutPause{}, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(80), }, - Pause: v1alpha1.RolloutPause{}, + Pause: v1beta1.RolloutPause{}, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(100), }, - Pause: v1alpha1.RolloutPause{ + Pause: v1beta1.RolloutPause{ Duration: utilpointer.Int32(0), }, }, @@ -4434,7 +4434,7 @@ var _ = SIGDescribe("Rollout", func() { WaitCloneSetAllPodsReady(workload) By("Only update rollout id = '1', and start rollout") - workload.Labels[v1alpha1.RolloutIDLabel] = "1" + workload.Labels[v1beta1.RolloutIDLabel] = "1" workload.Annotations[util.InRolloutProgressingAnnotation] = "true" UpdateCloneSet(workload) @@ -4453,7 +4453,7 @@ var _ = SIGDescribe("Rollout", func() { CheckPodBatchLabel(workload.Namespace, workload.Spec.Selector, "1", "3", 1) By("Only update rollout id = '2', and check batch label again") - workload.Labels[v1alpha1.RolloutIDLabel] = "2" + workload.Labels[v1beta1.RolloutIDLabel] = "2" UpdateCloneSet(workload) By("wait step(3) pause again") @@ -4470,7 +4470,7 @@ var _ = SIGDescribe("Rollout", func() { By("Wait rollout complete") ResumeRolloutCanary(rollout.Name) - WaitRolloutStatusPhase(rollout.Name, v1alpha1.RolloutPhaseHealthy) + WaitRolloutStatusPhase(rollout.Name, v1beta1.RolloutPhaseHealthy) CheckPodBatchLabel(workload.Namespace, workload.Spec.Selector, "2", "1", 1) CheckPodBatchLabel(workload.Namespace, workload.Spec.Selector, "2", "2", 1) CheckPodBatchLabel(workload.Namespace, workload.Spec.Selector, "2", "3", 1) @@ -4480,47 +4480,47 @@ var _ = SIGDescribe("Rollout", func() { It("patch batch id to pods: only change rollout-id after rolling the first step", func() { By("Creating Rollout...") - rollout := &v1alpha1.Rollout{} + rollout := &v1beta1.Rollout{} Expect(ReadYamlToObject("./test_data/rollout/rollout_canary_base.yaml", rollout)).ToNot(HaveOccurred()) - rollout.Spec.ObjectRef.WorkloadRef = &v1alpha1.WorkloadRef{ + rollout.Spec.ObjectRef.WorkloadRef = &v1beta1.WorkloadRef{ APIVersion: "apps.kruise.io/v1alpha1", Kind: "CloneSet", Name: "echoserver", } rollout.Spec.Strategy.Canary.TrafficRoutings = nil rollout.Annotations = map[string]string{ - v1alpha1.RollbackInBatchAnnotation: "true", + v1beta1.RollbackInBatchAnnotation: "true", } - rollout.Spec.Strategy.Canary.Steps = []v1alpha1.CanaryStep{ + rollout.Spec.Strategy.Canary.Steps = []v1beta1.CanaryStep{ { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(20), }, - Pause: v1alpha1.RolloutPause{}, + Pause: v1beta1.RolloutPause{}, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(40), }, - Pause: v1alpha1.RolloutPause{}, + Pause: v1beta1.RolloutPause{}, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(60), }, - Pause: v1alpha1.RolloutPause{}, + Pause: v1beta1.RolloutPause{}, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(80), }, - Pause: v1alpha1.RolloutPause{}, + Pause: v1beta1.RolloutPause{}, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(100), }, - Pause: v1alpha1.RolloutPause{ + Pause: v1beta1.RolloutPause{ Duration: utilpointer.Int32(0), }, }, @@ -4534,7 +4534,7 @@ var _ = SIGDescribe("Rollout", func() { WaitCloneSetAllPodsReady(workload) By("Only update rollout id = '1', and start rollout") - workload.Labels[v1alpha1.RolloutIDLabel] = "1" + workload.Labels[v1beta1.RolloutIDLabel] = "1" workload.Annotations[util.InRolloutProgressingAnnotation] = "true" UpdateCloneSet(workload) @@ -4543,7 +4543,7 @@ var _ = SIGDescribe("Rollout", func() { CheckPodBatchLabel(workload.Namespace, workload.Spec.Selector, "1", "1", 1) By("Only update rollout id = '2', and check batch label again") - workload.Labels[v1alpha1.RolloutIDLabel] = "2" + workload.Labels[v1beta1.RolloutIDLabel] = "2" UpdateCloneSet(workload) By("wait 30s") @@ -4570,7 +4570,7 @@ var _ = SIGDescribe("Rollout", func() { By("Wait rollout complete") ResumeRolloutCanary(rollout.Name) - WaitRolloutStatusPhase(rollout.Name, v1alpha1.RolloutPhaseHealthy) + WaitRolloutStatusPhase(rollout.Name, v1beta1.RolloutPhaseHealthy) CheckPodBatchLabel(workload.Namespace, workload.Spec.Selector, "2", "1", 1) CheckPodBatchLabel(workload.Namespace, workload.Spec.Selector, "2", "2", 1) CheckPodBatchLabel(workload.Namespace, workload.Spec.Selector, "2", "3", 1) @@ -4582,39 +4582,39 @@ var _ = SIGDescribe("Rollout", func() { KruiseDescribe("Test", func() { It("failure threshold", func() { By("Creating Rollout...") - rollout := &v1alpha1.Rollout{} + rollout := &v1beta1.Rollout{} Expect(ReadYamlToObject("./test_data/rollout/rollout_canary_base.yaml", rollout)).ToNot(HaveOccurred()) - rollout.Spec.ObjectRef.WorkloadRef = &v1alpha1.WorkloadRef{ + rollout.Spec.ObjectRef.WorkloadRef = &v1beta1.WorkloadRef{ APIVersion: "apps.kruise.io/v1alpha1", Kind: "CloneSet", Name: "echoserver", } - rollout.Spec.Strategy.Canary = &v1alpha1.CanaryStrategy{ + rollout.Spec.Strategy.Canary = &v1beta1.CanaryStrategy{ FailureThreshold: &intstr.IntOrString{Type: intstr.String, StrVal: "20%"}, - Steps: []v1alpha1.CanaryStep{ + Steps: []v1beta1.CanaryStep{ { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(10), }, - Pause: v1alpha1.RolloutPause{}, + Pause: v1beta1.RolloutPause{}, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(30), }, - Pause: v1alpha1.RolloutPause{}, + Pause: v1beta1.RolloutPause{}, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(60), }, - Pause: v1alpha1.RolloutPause{}, + Pause: v1beta1.RolloutPause{}, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(100), }, - Pause: v1alpha1.RolloutPause{}, + Pause: v1beta1.RolloutPause{}, }, }, } @@ -4634,7 +4634,7 @@ var _ = SIGDescribe("Rollout", func() { } By("start rollout") - workload.Labels[v1alpha1.RolloutIDLabel] = "1" + workload.Labels[v1beta1.RolloutIDLabel] = "1" newEnvs := mergeEnvVar(workload.Spec.Template.Spec.Containers[0].Env, v1.EnvVar{Name: "NODE_NAME", Value: "version2"}) workload.Spec.Template.Spec.Containers[0].Env = newEnvs UpdateCloneSet(workload) @@ -4667,26 +4667,26 @@ var _ = SIGDescribe("Rollout", func() { KruiseDescribe("Advanced Deployment canary rollout with Ingress", func() { It("advanced deployment rolling with traffic case", func() { By("Creating Rollout...") - rollout := &v1alpha1.Rollout{} + rollout := &v1beta1.Rollout{} Expect(ReadYamlToObject("./test_data/rollout/rollout_canary_base.yaml", rollout)).ToNot(HaveOccurred()) rollout.Annotations = map[string]string{ - v1alpha1.RolloutStyleAnnotation: string(v1alpha1.PartitionRollingStyle), + v1beta1.RolloutStyleAnnotation: string(v1beta1.PartitionRollingStyle), } - rollout.Spec.Strategy.Canary.Steps = []v1alpha1.CanaryStep{ + rollout.Spec.Strategy.Canary.Steps = []v1beta1.CanaryStep{ { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(20), }, - Pause: v1alpha1.RolloutPause{}, + Pause: v1beta1.RolloutPause{}, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(60), }, - Pause: v1alpha1.RolloutPause{}, + Pause: v1beta1.RolloutPause{}, }, } - rollout.Spec.ObjectRef.WorkloadRef = &v1alpha1.WorkloadRef{ + rollout.Spec.ObjectRef.WorkloadRef = &v1beta1.WorkloadRef{ APIVersion: "apps/v1", Kind: "Deployment", Name: "echoserver", @@ -4711,7 +4711,7 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseHealthy)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseHealthy)) By("check rollout status & paused success") // v1 -> v2, start rollout action @@ -4738,7 +4738,7 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseProgressing)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseProgressing)) Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(stableRevision)) Expect(rollout.Status.CanaryStatus.CanaryRevision).Should(Equal(util.ComputeHash(&workload.Spec.Template, nil))) Expect(rollout.Status.CanaryStatus.PodTemplateHash).Should(Equal(GetCanaryRSRevision(workload))) @@ -4779,7 +4779,7 @@ var _ = SIGDescribe("Rollout", func() { // resume rollout ResumeRolloutCanary(rollout.Name) - WaitRolloutStatusPhase(rollout.Name, v1alpha1.RolloutPhaseHealthy) + WaitRolloutStatusPhase(rollout.Name, v1beta1.RolloutPhaseHealthy) WaitDeploymentAllPodsReady(workload) By("rollout completed, and check") @@ -4807,10 +4807,10 @@ var _ = SIGDescribe("Rollout", func() { // check progressing succeed Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - cond := util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionProgressing) - Expect(cond.Reason).Should(Equal(v1alpha1.ProgressingReasonCompleted)) + cond := util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionProgressing) + Expect(cond.Reason).Should(Equal(v1beta1.ProgressingReasonCompleted)) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionFalse))) - cond = util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionSucceeded) + cond = util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionSucceeded) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionTrue))) WaitRolloutWorkloadGeneration(rollout.Name, workload.Generation) //Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(canaryRevision)) @@ -4828,33 +4828,33 @@ var _ = SIGDescribe("Rollout", func() { It("advanced deployment continuous rolling case", func() { By("Creating Rollout...") - rollout := &v1alpha1.Rollout{} + rollout := &v1beta1.Rollout{} Expect(ReadYamlToObject("./test_data/rollout/rollout_canary_base.yaml", rollout)).ToNot(HaveOccurred()) rollout.Annotations = map[string]string{ - v1alpha1.RolloutStyleAnnotation: string(v1alpha1.PartitionRollingStyle), + v1beta1.RolloutStyleAnnotation: string(v1beta1.PartitionRollingStyle), } rollout.Spec.Strategy.Canary.TrafficRoutings = nil - rollout.Spec.Strategy.Canary.Steps = []v1alpha1.CanaryStep{ + rollout.Spec.Strategy.Canary.Steps = []v1beta1.CanaryStep{ { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(20), }, - Pause: v1alpha1.RolloutPause{}, + Pause: v1beta1.RolloutPause{}, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(60), }, - Pause: v1alpha1.RolloutPause{}, + Pause: v1beta1.RolloutPause{}, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(100), }, - Pause: v1alpha1.RolloutPause{Duration: utilpointer.Int32(0)}, + Pause: v1beta1.RolloutPause{Duration: utilpointer.Int32(0)}, }, } - rollout.Spec.ObjectRef.WorkloadRef = &v1alpha1.WorkloadRef{ + rollout.Spec.ObjectRef.WorkloadRef = &v1beta1.WorkloadRef{ APIVersion: "apps/v1", Kind: "Deployment", Name: "echoserver", @@ -4870,7 +4870,7 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseHealthy)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseHealthy)) By("check rollout status & paused success") // v1 -> v2, start rollout action @@ -4912,7 +4912,7 @@ var _ = SIGDescribe("Rollout", func() { UpdateDeployment(workload) WaitRolloutCanaryStepPaused(rollout.Name, 1) - stableRevision = workload.Labels[v1alpha1.DeploymentStableRevisionLabel] + stableRevision = workload.Labels[v1beta1.DeploymentStableRevisionLabel] Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) Expect(rollout.Status.CanaryStatus.StableRevision).Should(Equal(stableRevision)) @@ -4940,33 +4940,33 @@ var _ = SIGDescribe("Rollout", func() { It("advanced deployment rollback case", func() { By("Creating Rollout...") - rollout := &v1alpha1.Rollout{} + rollout := &v1beta1.Rollout{} Expect(ReadYamlToObject("./test_data/rollout/rollout_canary_base.yaml", rollout)).ToNot(HaveOccurred()) rollout.Annotations = map[string]string{ - v1alpha1.RolloutStyleAnnotation: string(v1alpha1.PartitionRollingStyle), + v1beta1.RolloutStyleAnnotation: string(v1beta1.PartitionRollingStyle), } rollout.Spec.Strategy.Canary.TrafficRoutings = nil - rollout.Spec.Strategy.Canary.Steps = []v1alpha1.CanaryStep{ + rollout.Spec.Strategy.Canary.Steps = []v1beta1.CanaryStep{ { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(20), }, - Pause: v1alpha1.RolloutPause{}, + Pause: v1beta1.RolloutPause{}, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(60), }, - Pause: v1alpha1.RolloutPause{}, + Pause: v1beta1.RolloutPause{}, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(100), }, - Pause: v1alpha1.RolloutPause{Duration: utilpointer.Int32(0)}, + Pause: v1beta1.RolloutPause{Duration: utilpointer.Int32(0)}, }, } - rollout.Spec.ObjectRef.WorkloadRef = &v1alpha1.WorkloadRef{ + rollout.Spec.ObjectRef.WorkloadRef = &v1beta1.WorkloadRef{ APIVersion: "apps/v1", Kind: "Deployment", Name: "echoserver", @@ -4982,7 +4982,7 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseHealthy)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseHealthy)) By("check rollout status & paused success") // v1 -> v2, start rollout action @@ -5023,39 +5023,39 @@ var _ = SIGDescribe("Rollout", func() { workload.Spec.Template.Spec.Containers[0].Env = newEnvs UpdateDeployment(workload) - WaitRolloutStatusPhase(rollout.Name, v1alpha1.RolloutPhaseHealthy) + WaitRolloutStatusPhase(rollout.Name, v1beta1.RolloutPhaseHealthy) WaitDeploymentAllPodsReady(workload) }) It("advanced deployment delete rollout case", func() { By("Creating Rollout...") - rollout := &v1alpha1.Rollout{} + rollout := &v1beta1.Rollout{} Expect(ReadYamlToObject("./test_data/rollout/rollout_canary_base.yaml", rollout)).ToNot(HaveOccurred()) rollout.Annotations = map[string]string{ - v1alpha1.RolloutStyleAnnotation: string(v1alpha1.PartitionRollingStyle), + v1beta1.RolloutStyleAnnotation: string(v1beta1.PartitionRollingStyle), } rollout.Spec.Strategy.Canary.TrafficRoutings = nil - rollout.Spec.Strategy.Canary.Steps = []v1alpha1.CanaryStep{ + rollout.Spec.Strategy.Canary.Steps = []v1beta1.CanaryStep{ { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(20), }, - Pause: v1alpha1.RolloutPause{}, + Pause: v1beta1.RolloutPause{}, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(60), }, - Pause: v1alpha1.RolloutPause{}, + Pause: v1beta1.RolloutPause{}, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(100), }, - Pause: v1alpha1.RolloutPause{Duration: utilpointer.Int32(0)}, + Pause: v1beta1.RolloutPause{Duration: utilpointer.Int32(0)}, }, } - rollout.Spec.ObjectRef.WorkloadRef = &v1alpha1.WorkloadRef{ + rollout.Spec.ObjectRef.WorkloadRef = &v1beta1.WorkloadRef{ APIVersion: "apps/v1", Kind: "Deployment", Name: "echoserver", @@ -5071,7 +5071,7 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseHealthy)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseHealthy)) By("check rollout status & paused success") // v1 -> v2, start rollout action @@ -5106,33 +5106,33 @@ var _ = SIGDescribe("Rollout", func() { It("advanced deployment scaling case", func() { By("Creating Rollout...") - rollout := &v1alpha1.Rollout{} + rollout := &v1beta1.Rollout{} Expect(ReadYamlToObject("./test_data/rollout/rollout_canary_base.yaml", rollout)).ToNot(HaveOccurred()) rollout.Annotations = map[string]string{ - v1alpha1.RolloutStyleAnnotation: string(v1alpha1.PartitionRollingStyle), + v1beta1.RolloutStyleAnnotation: string(v1beta1.PartitionRollingStyle), } rollout.Spec.Strategy.Canary.TrafficRoutings = nil - rollout.Spec.Strategy.Canary.Steps = []v1alpha1.CanaryStep{ + rollout.Spec.Strategy.Canary.Steps = []v1beta1.CanaryStep{ { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(20), }, - Pause: v1alpha1.RolloutPause{}, + Pause: v1beta1.RolloutPause{}, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(60), }, - Pause: v1alpha1.RolloutPause{}, + Pause: v1beta1.RolloutPause{}, }, { - TrafficRoutingStrategy: v1alpha1.TrafficRoutingStrategy{ + TrafficRoutingStrategy: v1beta1.TrafficRoutingStrategy{ Weight: utilpointer.Int32(100), }, - Pause: v1alpha1.RolloutPause{Duration: utilpointer.Int32(0)}, + Pause: v1beta1.RolloutPause{Duration: utilpointer.Int32(0)}, }, } - rollout.Spec.ObjectRef.WorkloadRef = &v1alpha1.WorkloadRef{ + rollout.Spec.ObjectRef.WorkloadRef = &v1beta1.WorkloadRef{ APIVersion: "apps/v1", Kind: "Deployment", Name: "echoserver", @@ -5148,7 +5148,7 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseHealthy)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseHealthy)) By("check rollout status & paused success") // v1 -> v2, start rollout action @@ -5176,7 +5176,7 @@ var _ = SIGDescribe("Rollout", func() { workload.Spec.Replicas = utilpointer.Int32(10) UpdateDeployment(workload) Eventually(func() bool { - object := &v1alpha1.Rollout{} + object := &v1beta1.Rollout{} Expect(GetObject(rollout.Name, object)).NotTo(HaveOccurred()) return object.Status.CanaryStatus.CanaryReadyReplicas == 2 }, 5*time.Minute, time.Second).Should(BeTrue()) @@ -5185,7 +5185,7 @@ var _ = SIGDescribe("Rollout", func() { workload.Spec.Replicas = utilpointer.Int32(5) UpdateDeployment(workload) Eventually(func() bool { - object := &v1alpha1.Rollout{} + object := &v1beta1.Rollout{} Expect(GetObject(rollout.Name, object)).NotTo(HaveOccurred()) return object.Status.CanaryStatus.CanaryReadyReplicas == 1 }, 5*time.Minute, time.Second).Should(BeTrue()) @@ -5201,19 +5201,19 @@ var _ = SIGDescribe("Rollout", func() { KruiseDescribe("DaemonSet canary rollout", func() { It("DaemonSet V1->V2: 1,100% Succeeded", func() { By("Creating Rollout...") - rollout := &v1alpha1.Rollout{} + rollout := &v1beta1.Rollout{} Expect(ReadYamlToObject("./test_data/rollout/rollout_canary_daemonset_base.yaml", rollout)).ToNot(HaveOccurred()) - rollout.Spec.Strategy.Canary.Steps = []v1alpha1.CanaryStep{ + rollout.Spec.Strategy.Canary.Steps = []v1beta1.CanaryStep{ { Replicas: &intstr.IntOrString{IntVal: int32(*utilpointer.Int32(1)), Type: intstr.Int}, - Pause: v1alpha1.RolloutPause{}, + Pause: v1beta1.RolloutPause{}, }, { Replicas: &intstr.IntOrString{IntVal: int32(*utilpointer.Int32Ptr(100)), Type: intstr.Int}, - Pause: v1alpha1.RolloutPause{}, + Pause: v1beta1.RolloutPause{}, }, } - rollout.Spec.ObjectRef.WorkloadRef = &v1alpha1.WorkloadRef{ + rollout.Spec.ObjectRef.WorkloadRef = &v1beta1.WorkloadRef{ APIVersion: "apps.kruise.io/v1alpha1", Kind: "DaemonSet", Name: "fluentd-elasticsearch", @@ -5231,7 +5231,7 @@ var _ = SIGDescribe("Rollout", func() { By("check rollout status & paused success") Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseHealthy)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseHealthy)) // v1 -> v2, start rollout action By("Update daemonset env NODE_NAME from(version1) -> to(version2)") @@ -5250,7 +5250,7 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseProgressing)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseProgressing)) Expect(rollout.Status.CanaryStatus.CurrentStepIndex).Should(BeNumerically("==", 1)) Expect(rollout.Status.CanaryStatus.RolloutHash).Should(Equal(rollout.Annotations[util.RolloutHashAnnotation])) @@ -5261,7 +5261,7 @@ var _ = SIGDescribe("Rollout", func() { // resume rollout ResumeRolloutCanary(rollout.Name) - WaitRolloutStatusPhase(rollout.Name, v1alpha1.RolloutPhaseHealthy) + WaitRolloutStatusPhase(rollout.Name, v1beta1.RolloutPhaseHealthy) WaitDaemonSetAllPodsReady(workload) By("rollout completed, and check") @@ -5279,10 +5279,10 @@ var _ = SIGDescribe("Rollout", func() { // check progressing succeed Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - cond := util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionProgressing) - Expect(cond.Reason).Should(Equal(v1alpha1.ProgressingReasonCompleted)) + cond := util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionProgressing) + Expect(cond.Reason).Should(Equal(v1beta1.ProgressingReasonCompleted)) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionFalse))) - cond = util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionSucceeded) + cond = util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionSucceeded) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionTrue))) WaitRolloutWorkloadGeneration(rollout.Name, workload.Generation) @@ -5290,23 +5290,23 @@ var _ = SIGDescribe("Rollout", func() { It("V1->V2: Percentage, 1, 2 and continuous release v3", func() { By("Creating Rollout...") - rollout := &v1alpha1.Rollout{} + rollout := &v1beta1.Rollout{} Expect(ReadYamlToObject("./test_data/rollout/rollout_canary_daemonset_interrupt.yaml", rollout)).ToNot(HaveOccurred()) - rollout.Spec.Strategy.Canary.Steps = []v1alpha1.CanaryStep{ + rollout.Spec.Strategy.Canary.Steps = []v1beta1.CanaryStep{ { Replicas: &intstr.IntOrString{IntVal: int32(*utilpointer.Int32(1)), Type: intstr.Int}, - Pause: v1alpha1.RolloutPause{}, + Pause: v1beta1.RolloutPause{}, }, { Replicas: &intstr.IntOrString{IntVal: int32(*utilpointer.Int32Ptr(2)), Type: intstr.Int}, - Pause: v1alpha1.RolloutPause{}, + Pause: v1beta1.RolloutPause{}, }, { Replicas: &intstr.IntOrString{IntVal: int32(*utilpointer.Int32Ptr(100)), Type: intstr.Int}, - Pause: v1alpha1.RolloutPause{}, + Pause: v1beta1.RolloutPause{}, }, } - rollout.Spec.ObjectRef.WorkloadRef = &v1alpha1.WorkloadRef{ + rollout.Spec.ObjectRef.WorkloadRef = &v1beta1.WorkloadRef{ APIVersion: "apps.kruise.io/v1alpha1", Kind: "DaemonSet", Name: "fluentd-elasticsearch", @@ -5323,7 +5323,7 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseHealthy)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseHealthy)) By("check rollout status & paused success") // v1 -> v2, start rollout action @@ -5344,7 +5344,7 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseProgressing)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseProgressing)) Expect(rollout.Status.CanaryStatus.CurrentStepIndex).Should(BeNumerically("==", 1)) Expect(rollout.Status.CanaryStatus.RolloutHash).Should(Equal(rollout.Annotations[util.RolloutHashAnnotation])) @@ -5372,7 +5372,7 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseProgressing)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseProgressing)) Expect(rollout.Status.CanaryStatus.CurrentStepIndex).Should(BeNumerically("==", 1)) // resume rollout canary @@ -5390,7 +5390,7 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseProgressing)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseProgressing)) Expect(rollout.Status.CanaryStatus.CurrentStepIndex).Should(BeNumerically("==", 2)) // resume rollout canary @@ -5400,7 +5400,7 @@ var _ = SIGDescribe("Rollout", func() { // resume rollout ResumeRolloutCanary(rollout.Name) - WaitRolloutStatusPhase(rollout.Name, v1alpha1.RolloutPhaseHealthy) + WaitRolloutStatusPhase(rollout.Name, v1beta1.RolloutPhaseHealthy) WaitDaemonSetAllPodsReady(workload) By("rollout completed, and check") @@ -5419,10 +5419,10 @@ var _ = SIGDescribe("Rollout", func() { // check progressing succeed Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) - cond := util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionProgressing) - Expect(cond.Reason).Should(Equal(v1alpha1.ProgressingReasonCompleted)) + cond := util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionProgressing) + Expect(cond.Reason).Should(Equal(v1beta1.ProgressingReasonCompleted)) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionFalse))) - cond = util.GetRolloutCondition(rollout.Status, v1alpha1.RolloutConditionSucceeded) + cond = util.GetRolloutCondition(rollout.Status, v1beta1.RolloutConditionSucceeded) Expect(string(cond.Status)).Should(Equal(string(metav1.ConditionTrue))) WaitRolloutWorkloadGeneration(rollout.Name, workload.Generation) }) @@ -5430,19 +5430,19 @@ var _ = SIGDescribe("Rollout", func() { It("V1->V2: 1,100%, but delete rollout crd", func() { // finder := util.NewControllerFinder(k8sClient) By("Creating Rollout...") - rollout := &v1alpha1.Rollout{} + rollout := &v1beta1.Rollout{} Expect(ReadYamlToObject("./test_data/rollout/rollout_canary_daemonset_base.yaml", rollout)).ToNot(HaveOccurred()) - rollout.Spec.Strategy.Canary.Steps = []v1alpha1.CanaryStep{ + rollout.Spec.Strategy.Canary.Steps = []v1beta1.CanaryStep{ { Replicas: &intstr.IntOrString{IntVal: int32(*utilpointer.Int32(1)), Type: intstr.Int}, - Pause: v1alpha1.RolloutPause{}, + Pause: v1beta1.RolloutPause{}, }, { Replicas: &intstr.IntOrString{IntVal: int32(*utilpointer.Int32Ptr(100)), Type: intstr.Int}, - Pause: v1alpha1.RolloutPause{}, + Pause: v1beta1.RolloutPause{}, }, } - rollout.Spec.ObjectRef.WorkloadRef = &v1alpha1.WorkloadRef{ + rollout.Spec.ObjectRef.WorkloadRef = &v1beta1.WorkloadRef{ APIVersion: "apps.kruise.io/v1alpha1", Kind: "DaemonSet", Name: "fluentd-elasticsearch", @@ -5459,7 +5459,7 @@ var _ = SIGDescribe("Rollout", func() { // check rollout status Expect(GetObject(rollout.Name, rollout)).NotTo(HaveOccurred()) Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) - Expect(rollout.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseHealthy)) + Expect(rollout.Status.Phase).Should(Equal(v1beta1.RolloutPhaseHealthy)) By("check rollout status & paused success") // v1 -> v2, start rollout action @@ -5478,7 +5478,7 @@ var _ = SIGDescribe("Rollout", func() { By("check DaemonSet status & paused success") // delete rollout By("Delete rollout crd, and wait DaemonSet ready") - Expect(k8sClient.DeleteAllOf(context.TODO(), &v1alpha1.Rollout{}, client.InNamespace(namespace), client.PropagationPolicy(metav1.DeletePropagationForeground))).Should(Succeed()) + Expect(k8sClient.DeleteAllOf(context.TODO(), &v1beta1.Rollout{}, client.InNamespace(namespace), client.PropagationPolicy(metav1.DeletePropagationForeground))).Should(Succeed()) WaitRolloutNotFound(rollout.Name) Expect(GetObject(workload.Name, workload)).NotTo(HaveOccurred()) workload.Spec.UpdateStrategy.RollingUpdate.Partition = utilpointer.Int32(0) @@ -5502,7 +5502,7 @@ var _ = SIGDescribe("Rollout", func() { }) KruiseDescribe("Disabled rollout tests", func() { - rollout := &v1alpha1.Rollout{} + rollout := &v1beta1.Rollout{} Expect(ReadYamlToObject("./test_data/rollout/rollout_disabled.yaml", rollout)).ToNot(HaveOccurred()) It("Rollout status tests", func() { By("Create an enabled rollout") @@ -5528,7 +5528,7 @@ var _ = SIGDescribe("Rollout", func() { // wait for reconciling time.Sleep(3 * time.Second) Expect(GetObject(rollout1.Name, rollout1)).NotTo(HaveOccurred()) - Expect(rollout1.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseInitial)) + Expect(rollout1.Status.Phase).Should(Equal(v1beta1.RolloutPhaseInitial)) By("Create workload") deploy := &apps.Deployment{} @@ -5536,7 +5536,7 @@ var _ = SIGDescribe("Rollout", func() { CreateObject(deploy) WaitDeploymentAllPodsReady(deploy) Expect(GetObject(rollout1.Name, rollout1)).NotTo(HaveOccurred()) - Expect(rollout1.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseHealthy)) + Expect(rollout1.Status.Phase).Should(Equal(v1beta1.RolloutPhaseHealthy)) By("Updating deployment version-1 to version-2") Expect(GetObject(deploy.Name, deploy)).NotTo(HaveOccurred()) @@ -5561,9 +5561,9 @@ var _ = SIGDescribe("Rollout", func() { By("Batchrelease should be deleted") key := types.NamespacedName{Namespace: namespace, Name: rollout1.Name} - Expect(k8sClient.Get(context.TODO(), key, &v1alpha1.BatchRelease{})).Should(HaveOccurred()) + Expect(k8sClient.Get(context.TODO(), key, &v1beta1.BatchRelease{})).Should(HaveOccurred()) Expect(GetObject(rollout1.Name, rollout1)).NotTo(HaveOccurred()) - Expect(rollout1.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseDisabled)) + Expect(rollout1.Status.Phase).Should(Equal(v1beta1.RolloutPhaseDisabled)) By("Updating deployment version-2 to version-3") Expect(GetObject(deploy.Name, deploy)).NotTo(HaveOccurred()) @@ -5579,7 +5579,7 @@ var _ = SIGDescribe("Rollout", func() { UpdateRollout(rollout1) time.Sleep(3 * time.Second) Expect(GetObject(rollout1.Name, rollout1)).NotTo(HaveOccurred()) - Expect(rollout1.Status.Phase).Should(Equal(v1alpha1.RolloutPhaseHealthy)) + Expect(rollout1.Status.Phase).Should(Equal(v1beta1.RolloutPhaseHealthy)) }) }) }) diff --git a/test/e2e/suite_test.go b/test/e2e/suite_test.go index d344ca6c..e736533d 100644 --- a/test/e2e/suite_test.go +++ b/test/e2e/suite_test.go @@ -30,7 +30,7 @@ import ( . "github.com/onsi/gomega" kruisev1alpha1 "github.com/openkruise/kruise-api/apps/v1alpha1" kruisev1beta1 "github.com/openkruise/kruise-api/apps/v1beta1" - rolloutsv1alpha1 "github.com/openkruise/rollouts/api/v1alpha1" + rolloutsv1beta1 "github.com/openkruise/rollouts/api/v1beta1" crdv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -62,7 +62,7 @@ var _ = BeforeSuite(func(done Done) { logf.SetLogger(zap.New(zap.UseDevMode(true), zap.WriteTo(GinkgoWriter))) err := clientgoscheme.AddToScheme(scheme) Expect(err).Should(BeNil()) - err = rolloutsv1alpha1.AddToScheme(scheme) + err = rolloutsv1beta1.AddToScheme(scheme) Expect(err).Should(BeNil()) err = crdv1.AddToScheme(scheme) Expect(err).Should(BeNil())