diff --git a/manifests/crds/rollout-crd.yaml b/manifests/crds/rollout-crd.yaml index 9e4fcf9b3f..2b022a685c 100644 --- a/manifests/crds/rollout-crd.yaml +++ b/manifests/crds/rollout-crd.yaml @@ -65,26 +65,6 @@ spec: description: Name of the service that the rollout modifies as the preview service. type: string - steps: - description: Steps define the order of steps to execute the - bluegreen deployment - items: - description: BlueGreenStep defines a step of a bluegreen deployment. - properties: - pause: - properties: - duration: - description: Duration the amount of time to wait before - moving to the next step. - format: int32 - type: integer - setPreview: - description: SetPreview empty struct to indicate the SetPreview - step - switchActive: - description: SwitchActive empty struct to indicate the - SetActive step - type: array canary: description: ReplicaBasedCanaryStrategy defines parameters for a Replica Based Canary diff --git a/manifests/install.yaml b/manifests/install.yaml index f99cce4da9..636fdd9bc5 100644 --- a/manifests/install.yaml +++ b/manifests/install.yaml @@ -66,26 +66,6 @@ spec: description: Name of the service that the rollout modifies as the preview service. type: string - steps: - description: Steps define the order of steps to execute the - bluegreen deployment - items: - description: BlueGreenStep defines a step of a bluegreen deployment. - properties: - pause: - properties: - duration: - description: Duration the amount of time to wait before - moving to the next step. - format: int32 - type: integer - setPreview: - description: SetPreview empty struct to indicate the SetPreview - step - switchActive: - description: SwitchActive empty struct to indicate the - SetActive step - type: array canary: description: ReplicaBasedCanaryStrategy defines parameters for a Replica Based Canary diff --git a/manifests/namespace-install.yaml b/manifests/namespace-install.yaml index a166d25c48..3160e08853 100644 --- a/manifests/namespace-install.yaml +++ b/manifests/namespace-install.yaml @@ -66,26 +66,6 @@ spec: description: Name of the service that the rollout modifies as the preview service. type: string - steps: - description: Steps define the order of steps to execute the - bluegreen deployment - items: - description: BlueGreenStep defines a step of a bluegreen deployment. - properties: - pause: - properties: - duration: - description: Duration the amount of time to wait before - moving to the next step. - format: int32 - type: integer - setPreview: - description: SetPreview empty struct to indicate the SetPreview - step - switchActive: - description: SwitchActive empty struct to indicate the - SetActive step - type: array canary: description: ReplicaBasedCanaryStrategy defines parameters for a Replica Based Canary diff --git a/pkg/apis/rollouts/v1alpha1/openapi_generated.go b/pkg/apis/rollouts/v1alpha1/openapi_generated.go index a365a313e3..ca92e34644 100644 --- a/pkg/apis/rollouts/v1alpha1/openapi_generated.go +++ b/pkg/apis/rollouts/v1alpha1/openapi_generated.go @@ -30,7 +30,6 @@ import ( func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenAPIDefinition { return map[string]common.OpenAPIDefinition{ "github.com/argoproj/argo-rollouts/pkg/apis/rollouts/v1alpha1.BlueGreenStatus": schema_pkg_apis_rollouts_v1alpha1_BlueGreenStatus(ref), - "github.com/argoproj/argo-rollouts/pkg/apis/rollouts/v1alpha1.BlueGreenStep": schema_pkg_apis_rollouts_v1alpha1_BlueGreenStep(ref), "github.com/argoproj/argo-rollouts/pkg/apis/rollouts/v1alpha1.BlueGreenStrategy": schema_pkg_apis_rollouts_v1alpha1_BlueGreenStrategy(ref), "github.com/argoproj/argo-rollouts/pkg/apis/rollouts/v1alpha1.CanaryStatus": schema_pkg_apis_rollouts_v1alpha1_CanaryStatus(ref), "github.com/argoproj/argo-rollouts/pkg/apis/rollouts/v1alpha1.CanaryStep": schema_pkg_apis_rollouts_v1alpha1_CanaryStep(ref), @@ -74,38 +73,6 @@ func schema_pkg_apis_rollouts_v1alpha1_BlueGreenStatus(ref common.ReferenceCallb } } -func schema_pkg_apis_rollouts_v1alpha1_BlueGreenStep(ref common.ReferenceCallback) common.OpenAPIDefinition { - return common.OpenAPIDefinition{ - Schema: spec.Schema{ - SchemaProps: spec.SchemaProps{ - Description: "BlueGreenStep defines a step of a bluegreen deployment.", - Properties: map[string]spec.Schema{ - "switchActive": { - SchemaProps: spec.SchemaProps{ - Description: "SwitchActive switches the new replicaset to the active service", - Ref: ref("github.com/argoproj/argo-rollouts/pkg/apis/rollouts/v1alpha1.SwitchActive"), - }, - }, - "setPreview": { - SchemaProps: spec.SchemaProps{ - Description: "SetPreview sets the new replicaset to the preview service", - Ref: ref("github.com/argoproj/argo-rollouts/pkg/apis/rollouts/v1alpha1.SetPreview"), - }, - }, - "pause": { - SchemaProps: spec.SchemaProps{ - Description: "Pause freezes the rollout. If an empty struct is provided, it will freeze until a user sets the spec.Pause to false", - Ref: ref("github.com/argoproj/argo-rollouts/pkg/apis/rollouts/v1alpha1.RolloutPause"), - }, - }, - }, - }, - }, - Dependencies: []string{ - "github.com/argoproj/argo-rollouts/pkg/apis/rollouts/v1alpha1.RolloutPause", "github.com/argoproj/argo-rollouts/pkg/apis/rollouts/v1alpha1.SetPreview", "github.com/argoproj/argo-rollouts/pkg/apis/rollouts/v1alpha1.SwitchActive"}, - } -} - func schema_pkg_apis_rollouts_v1alpha1_BlueGreenStrategy(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -126,24 +93,10 @@ func schema_pkg_apis_rollouts_v1alpha1_BlueGreenStrategy(ref common.ReferenceCal Format: "", }, }, - "steps": { - SchemaProps: spec.SchemaProps{ - Description: "Steps define the order of steps to execute the bluegreen deployment", - Type: []string{"array"}, - Items: &spec.SchemaOrArray{ - Schema: &spec.Schema{ - SchemaProps: spec.SchemaProps{ - Ref: ref("github.com/argoproj/argo-rollouts/pkg/apis/rollouts/v1alpha1.BlueGreenStep"), - }, - }, - }, - }, - }, }, }, }, - Dependencies: []string{ - "github.com/argoproj/argo-rollouts/pkg/apis/rollouts/v1alpha1.BlueGreenStep"}, + Dependencies: []string{}, } } diff --git a/pkg/apis/rollouts/v1alpha1/types.go b/pkg/apis/rollouts/v1alpha1/types.go index 0b17f16de5..628d0cb127 100644 --- a/pkg/apis/rollouts/v1alpha1/types.go +++ b/pkg/apis/rollouts/v1alpha1/types.go @@ -72,7 +72,6 @@ type BlueGreenStrategy struct { PreviewService string `json:"previewService,omitempty"` // Steps define the order of steps to execute the bluegreen deployment // +optional - Steps []BlueGreenStep `json:"steps,omitempty"` } // ReplicaBasedCanaryStrategy defines parameters for a Replica Based Canary @@ -116,19 +115,6 @@ type CanaryStep struct { Pause *RolloutPause `json:"pause,omitempty"` } -// BlueGreenStep defines a step of a bluegreen deployment. -type BlueGreenStep struct { - // SwitchActive switches the new replicaset to the active service - // +optional - SwitchActive *SwitchActive `json:"switchActive,omitempty"` - // SetPreview sets the new replicaset to the preview service - // +optional - SetPreview *SetPreview `json:"setPreview,omitempty"` - // Pause freezes the rollout. If an empty struct is provided, it will freeze until a user sets the spec.Pause to false - // +optional - Pause *RolloutPause `json:"pause,omitempty"` -} - // SetPreview empty struct to indicate the SetPreview step type SetPreview struct{} diff --git a/pkg/apis/rollouts/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/rollouts/v1alpha1/zz_generated.deepcopy.go index 2ddc86e6e6..07e613bcae 100644 --- a/pkg/apis/rollouts/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/rollouts/v1alpha1/zz_generated.deepcopy.go @@ -42,47 +42,9 @@ func (in *BlueGreenStatus) DeepCopy() *BlueGreenStatus { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *BlueGreenStep) DeepCopyInto(out *BlueGreenStep) { - *out = *in - if in.SwitchActive != nil { - in, out := &in.SwitchActive, &out.SwitchActive - *out = new(SwitchActive) - **out = **in - } - if in.SetPreview != nil { - in, out := &in.SetPreview, &out.SetPreview - *out = new(SetPreview) - **out = **in - } - if in.Pause != nil { - in, out := &in.Pause, &out.Pause - *out = new(RolloutPause) - (*in).DeepCopyInto(*out) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BlueGreenStep. -func (in *BlueGreenStep) DeepCopy() *BlueGreenStep { - if in == nil { - return nil - } - out := new(BlueGreenStep) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *BlueGreenStrategy) DeepCopyInto(out *BlueGreenStrategy) { *out = *in - if in.Steps != nil { - in, out := &in.Steps, &out.Steps - *out = make([]BlueGreenStep, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } return } @@ -354,7 +316,7 @@ func (in *RolloutStrategy) DeepCopyInto(out *RolloutStrategy) { if in.BlueGreenStrategy != nil { in, out := &in.BlueGreenStrategy, &out.BlueGreenStrategy *out = new(BlueGreenStrategy) - (*in).DeepCopyInto(*out) + **out = **in } if in.CanaryStrategy != nil { in, out := &in.CanaryStrategy, &out.CanaryStrategy diff --git a/utils/conditions/conditions.go b/utils/conditions/conditions.go index d6dfbd9e13..eaf824264b 100644 --- a/utils/conditions/conditions.go +++ b/utils/conditions/conditions.go @@ -113,7 +113,7 @@ func RolloutComplete(rollout *v1alpha1.Rollout, newStatus *v1alpha1.RolloutStatu func ComputeStepHash(rollout *v1alpha1.Rollout) string { rolloutStepHasher := fnv.New32a() if rollout.Spec.Strategy.BlueGreenStrategy != nil { - hashutil.DeepHashObject(rolloutStepHasher, rollout.Spec.Strategy.BlueGreenStrategy.Steps) + return "" } if rollout.Spec.Strategy.CanaryStrategy != nil { hashutil.DeepHashObject(rolloutStepHasher, rollout.Spec.Strategy.CanaryStrategy.Steps) diff --git a/utils/conditions/conditions_test.go b/utils/conditions/conditions_test.go index 748df68448..3c023f592d 100644 --- a/utils/conditions/conditions_test.go +++ b/utils/conditions/conditions_test.go @@ -537,30 +537,12 @@ func TestComputeStepHash(t *testing.T) { roNoStepsHash := ComputeStepHash(roNoSteps) roBlueGreen := ro.DeepCopy() - roBlueGreen.Spec.Strategy.BlueGreenStrategy = &v1alpha1.BlueGreenStrategy{ - Steps: []v1alpha1.BlueGreenStep{ - { - SetPreview: &v1alpha1.SetPreview{}, - }, - }, - } roBlueGreen.Spec.Strategy.CanaryStrategy = nil + roBlueGreen.Spec.Strategy.BlueGreenStrategy = &v1alpha1.BlueGreenStrategy{} roBlueGreenHash := ComputeStepHash(roBlueGreen) - roBlueGreen2 := ro.DeepCopy() - roBlueGreen2.Spec.Strategy.BlueGreenStrategy = &v1alpha1.BlueGreenStrategy{ - Steps: []v1alpha1.BlueGreenStep{ - { - SwitchActive: &v1alpha1.SwitchActive{}, - }, - }, - } - roBlueGreen2.Spec.Strategy.CanaryStrategy = nil - roBlueGreenHash2 := ComputeStepHash(roBlueGreen2) - assert.NotEqual(t, baseline, roWithDiffStepsHash) assert.Equal(t, baseline, roWithSameStepsHash) assert.NotEqual(t, baseline, roNoStepsHash) - assert.NotEqual(t, roBlueGreenHash, roNoStepsHash) - assert.NotEqual(t, roBlueGreenHash, roBlueGreenHash2) + assert.Equal(t, "", roBlueGreenHash) } diff --git a/utils/replicaset/bluegreen.go b/utils/replicaset/bluegreen.go deleted file mode 100644 index 059c9b14be..0000000000 --- a/utils/replicaset/bluegreen.go +++ /dev/null @@ -1,47 +0,0 @@ -package replicaset - -import ( - "github.com/argoproj/argo-rollouts/pkg/apis/rollouts/v1alpha1" -) - -// GetCurrentBlueGreenStep returns the current bluegreen step. If there are no steps or the rollout -// has already executed the last step, the func returns nil -func GetCurrentBlueGreenStep(rollout *v1alpha1.Rollout) (*v1alpha1.BlueGreenStep, *int32) { - if len(rollout.Spec.Strategy.BlueGreenStrategy.Steps) == 0 { - return GetDefaultedBlueGreenSteps(rollout) - } - currentStepIndex := int32(0) - if rollout.Status.CurrentStepIndex != nil { - currentStepIndex = *rollout.Status.CurrentStepIndex - } - if len(rollout.Spec.Strategy.BlueGreenStrategy.Steps) <= int(currentStepIndex) { - return nil, ¤tStepIndex - } - return &rollout.Spec.Strategy.BlueGreenStrategy.Steps[currentStepIndex], ¤tStepIndex -} - -func GetDefaultedBlueGreenSteps(rollout *v1alpha1.Rollout) (*v1alpha1.BlueGreenStep, *int32) { - currentStepIndex := int32(0) - if rollout.Status.CurrentStepIndex != nil { - currentStepIndex = *rollout.Status.CurrentStepIndex - } - if rollout.Spec.Strategy.BlueGreenStrategy.PreviewService == "" { - if currentStepIndex == 0 { - return &v1alpha1.BlueGreenStep{Pause: &v1alpha1.RolloutPause{}}, ¤tStepIndex - } - if currentStepIndex == 1 { - return &v1alpha1.BlueGreenStep{SwitchActive: &v1alpha1.SwitchActive{}}, ¤tStepIndex - } - return nil, ¤tStepIndex - } - if currentStepIndex == 0 { - return &v1alpha1.BlueGreenStep{SetPreview: &v1alpha1.SetPreview{}}, ¤tStepIndex - } - if currentStepIndex == 1 { - return &v1alpha1.BlueGreenStep{Pause: &v1alpha1.RolloutPause{}}, ¤tStepIndex - } - if currentStepIndex == 2 { - return &v1alpha1.BlueGreenStep{SwitchActive: &v1alpha1.SwitchActive{}}, ¤tStepIndex - } - return nil, ¤tStepIndex -} diff --git a/utils/replicaset/bluegreen_test.go b/utils/replicaset/bluegreen_test.go deleted file mode 100644 index b64e6517e4..0000000000 --- a/utils/replicaset/bluegreen_test.go +++ /dev/null @@ -1,100 +0,0 @@ -package replicaset - -import ( - "testing" - - "github.com/stretchr/testify/assert" - "k8s.io/utils/pointer" - - "github.com/argoproj/argo-rollouts/pkg/apis/rollouts/v1alpha1" -) - -func newBlueGreenRollout(specReplicas int32, currentPodHash, activeSelector, preivewSelector string) *v1alpha1.Rollout { - rollout := &v1alpha1.Rollout{ - Spec: v1alpha1.RolloutSpec{ - Replicas: &specReplicas, - Strategy: v1alpha1.RolloutStrategy{ - BlueGreenStrategy: &v1alpha1.BlueGreenStrategy{ - ActiveService: "active", - PreviewService: "preview", - Steps: []v1alpha1.BlueGreenStep{ - { - SetPreview: &v1alpha1.SetPreview{}, - }, { - SwitchActive: &v1alpha1.SwitchActive{}, - }, - }, - }, - }, - }, - Status: v1alpha1.RolloutStatus{ - CurrentPodHash: currentPodHash, - }, - } - if preivewSelector != "" { - rollout.Status.BlueGreen.PreviewSelector = preivewSelector - } - if activeSelector != "" { - rollout.Status.BlueGreen.ActiveSelector = activeSelector - } - return rollout -} - -func TestGetCurrentBlueGreenStep(t *testing.T) { - rollout := newBlueGreenRollout(10, "abcd", "active", "preview") - rollout.Status.CurrentStepIndex = pointer.Int32Ptr(0) - - currentStep, index := GetCurrentBlueGreenStep(rollout) - assert.NotNil(t, currentStep) - assert.Equal(t, int32(0), *index) - - rollout.Status.CurrentStepIndex = pointer.Int32Ptr(2) - noMoreStep, _ := GetCurrentBlueGreenStep(rollout) - assert.Nil(t, noMoreStep) -} - -func TestDefaultedBlueGreenSteps(t *testing.T) { - rollout := newBlueGreenRollout(10, "abcd", "active", "preview") - rollout.Spec.Strategy.BlueGreenStrategy.Steps = nil - - currentStep, index := GetCurrentBlueGreenStep(rollout) - assert.Equal(t, v1alpha1.BlueGreenStep{SetPreview: &v1alpha1.SetPreview{}}, *currentStep) - assert.Equal(t, int32(0), *index) - - rollout.Status.CurrentStepIndex = pointer.Int32Ptr(0) - currentStep, index = GetCurrentBlueGreenStep(rollout) - assert.Equal(t, v1alpha1.BlueGreenStep{SetPreview: &v1alpha1.SetPreview{}}, *currentStep) - assert.Equal(t, int32(0), *index) - - rollout.Status.CurrentStepIndex = pointer.Int32Ptr(1) - currentStep, index = GetCurrentBlueGreenStep(rollout) - assert.Equal(t, v1alpha1.BlueGreenStep{Pause: &v1alpha1.RolloutPause{}}, *currentStep) - assert.Equal(t, int32(1), *index) - - rollout.Status.CurrentStepIndex = pointer.Int32Ptr(2) - currentStep, index = GetCurrentBlueGreenStep(rollout) - assert.Equal(t, v1alpha1.BlueGreenStep{SwitchActive: &v1alpha1.SwitchActive{}}, *currentStep) - assert.Equal(t, int32(2), *index) - - rollout.Status.CurrentStepIndex = pointer.Int32Ptr(3) - currentStep, index = GetCurrentBlueGreenStep(rollout) - assert.Nil(t, currentStep) - assert.Equal(t, int32(3), *index) - - rollout.Spec.Strategy.BlueGreenStrategy.PreviewService = "" - rollout.Status.CurrentStepIndex = pointer.Int32Ptr(0) - currentStep, index = GetCurrentBlueGreenStep(rollout) - assert.Equal(t, v1alpha1.BlueGreenStep{Pause: &v1alpha1.RolloutPause{}}, *currentStep) - assert.Equal(t, int32(0), *index) - - rollout.Status.CurrentStepIndex = pointer.Int32Ptr(1) - currentStep, index = GetCurrentBlueGreenStep(rollout) - assert.Equal(t, v1alpha1.BlueGreenStep{SwitchActive: &v1alpha1.SwitchActive{}}, *currentStep) - assert.Equal(t, int32(1), *index) - - rollout.Status.CurrentStepIndex = pointer.Int32Ptr(2) - currentStep, index = GetCurrentBlueGreenStep(rollout) - assert.Nil(t, currentStep) - assert.Equal(t, int32(2), *index) - -}