From ae326173340288bf10a7948429346bb9f90ebca3 Mon Sep 17 00:00:00 2001 From: Daniel Del Rio Date: Fri, 24 Feb 2023 16:31:23 +0100 Subject: [PATCH 1/2] Rollback change on service creation with weightless experiments Signed-off-by: Daniel Del Rio --- rollout/experiment.go | 4 +++- rollout/experiment_test.go | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/rollout/experiment.go b/rollout/experiment.go index a6d3bdcd43..aeac6e8049 100644 --- a/rollout/experiment.go +++ b/rollout/experiment.go @@ -64,7 +64,9 @@ func GetExperimentFromTemplate(r *v1alpha1.Rollout, stableRS, newRS *appsv1.Repl Name: templateStep.Name, Replicas: templateStep.Replicas, } - template.Service = &v1alpha1.TemplateService{} + if templateStep.Weight != nil { + template.Service = &v1alpha1.TemplateService{} + } templateRS := &appsv1.ReplicaSet{} switch templateStep.SpecRef { case v1alpha1.CanarySpecRef: diff --git a/rollout/experiment_test.go b/rollout/experiment_test.go index 1c60e9f7c7..e2e50c1f28 100644 --- a/rollout/experiment_test.go +++ b/rollout/experiment_test.go @@ -791,7 +791,7 @@ func TestRolloutCreateExperimentWithService(t *testing.T) { Replicas: pointer.Int32Ptr(1), Weight: pointer.Int32Ptr(5), }, - // Service should also be created for "canary-template" + // Service should NOT be created for "canary-template" { Name: "canary-template", SpecRef: v1alpha1.CanarySpecRef, @@ -818,5 +818,5 @@ func TestRolloutCreateExperimentWithService(t *testing.T) { assert.NotNil(t, ex.Spec.Templates[0].Service) assert.Equal(t, "canary-template", ex.Spec.Templates[1].Name) - assert.NotNil(t, ex.Spec.Templates[1].Service) + assert.Nil(t, ex.Spec.Templates[1].Service) } From 0e8ea9e8f41e2e63438d207cc449aba46187a148 Mon Sep 17 00:00:00 2001 From: Daniel Del Rio Date: Fri, 24 Feb 2023 16:48:39 +0100 Subject: [PATCH 2/2] Update documentation on service creation Signed-off-by: Daniel Del Rio --- docs/features/experiment.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/features/experiment.md b/docs/features/experiment.md index 6740895d68..b282f3b18b 100644 --- a/docs/features/experiment.md +++ b/docs/features/experiment.md @@ -6,7 +6,7 @@ The Experiment CRD allows users to have ephemeral runs of one or more ReplicaSet running ephemeral ReplicaSets, the Experiment CRD can launch AnalysisRuns alongside the ReplicaSets. Generally, those AnalysisRun is used to confirm that new ReplicaSets are running as expected. -A Service routing traffic to the Experiment ReplicaSet is also generated. +A Service routing traffic to the Experiment ReplicaSet is also generated if a weight for that experiment is set. ## Use cases of Experiments @@ -245,7 +245,7 @@ to `experiment-baseline`, leaving the remaining 90% of traffic to the old stack. !!! note When a weighted experiment step with traffic routing is used, a - Service is auto-created for each experiment template. The traffic routers use + service is auto-created for each experiment template. The traffic routers use this service to send traffic to the experiment pods. By default, the generated Service has the name of the ReplicaSet and inherits