Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: rollout experiment template changing reference rs template labels. Fixes #1596 #1597

Merged
merged 2 commits into from
Nov 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions USERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Organizations below are **officially** using Argo Rollouts. Please send a PR wit
1. [Codefresh](https://codefresh.io/)
1. [Databricks](https://github.com/databricks)
1. [Devtron Labs](https://github.com/devtron-labs/devtron)
1. [Farfetch](https://www.farfetch.com/)
1. [Intuit](https://www.intuit.com/)
1. [New Relic](https://newrelic.com/)
1. [Nitro](https://www.gonitro.com)
Expand Down
4 changes: 2 additions & 2 deletions rollout/experiment.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ func GetExperimentFromTemplate(r *v1alpha1.Rollout, stableRS, newRS *appsv1.Repl
templateRS := &appsv1.ReplicaSet{}
switch templateStep.SpecRef {
case v1alpha1.CanarySpecRef:
templateRS = newRS
templateRS = newRS.DeepCopy()
case v1alpha1.StableSpecRef:
templateRS = stableRS
templateRS = stableRS.DeepCopy()
default:
return nil, fmt.Errorf("Invalid template step SpecRef: must be canary or stable")
}
Expand Down
35 changes: 35 additions & 0 deletions rollout/experiment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,41 @@ func TestGetExperimentFromTemplate(t *testing.T) {
assert.Nil(t, err)
}

func TestGetExperimentFromTemplateModifiedLabelsDoesntChangeRefReplicatSet(t *testing.T) {
steps := []v1alpha1.CanaryStep{{
Experiment: &v1alpha1.RolloutExperimentStep{
Templates: []v1alpha1.RolloutExperimentTemplate{{
Name: "stable-template",
SpecRef: v1alpha1.StableSpecRef,
Replicas: pointer.Int32Ptr(1),
}},
},
}}

r1 := newCanaryRollout("foo", 1, nil, steps, pointer.Int32Ptr(0), intstr.FromInt(0), intstr.FromInt(1))
r2 := bumpVersion(r1)
r2.Spec.Strategy.Canary.Steps[0].Experiment.Templates[0].Metadata.Annotations = map[string]string{"abc": "def"}
r2.Spec.Strategy.Canary.Steps[0].Experiment.Templates[0].Metadata.Labels = map[string]string{"123": "456"}

rs1 := newReplicaSetWithStatus(r1, 1, 1)
rs2 := newReplicaSetWithStatus(r2, 1, 1)
stableRsTemplate := rs1.Spec.Template.DeepCopy()
canaryRsTemplate := rs2.Spec.Template.DeepCopy()
rs1PodHash := rs1.Labels[v1alpha1.DefaultRolloutUniqueLabelKey]

r2.Status.CurrentStepIndex = pointer.Int32Ptr(0)
r2.Status.StableRS = rs1PodHash

_, err := GetExperimentFromTemplate(r2, rs1, rs2)
assert.Nil(t, err)
assert.Equal(t, stableRsTemplate, &rs1.Spec.Template)

r2.Spec.Strategy.Canary.Steps[0].Experiment.Templates[0].SpecRef = v1alpha1.CanarySpecRef
_, err = GetExperimentFromTemplate(r2, rs1, rs2)
assert.Nil(t, err)
assert.Equal(t, canaryRsTemplate, &rs2.Spec.Template)
}

func TestDeleteExperimentWithNoMatchingRS(t *testing.T) {
f := newFixture(t)
defer f.Close()
Expand Down