diff --git a/experiments/experiment_test.go b/experiments/experiment_test.go index 0853a3b361..56ba1f2dbf 100644 --- a/experiments/experiment_test.go +++ b/experiments/experiment_test.go @@ -529,6 +529,7 @@ func TestServiceInheritPortsFromRS(t *testing.T) { assert.NotNil(t, exCtx.templateServices["bar"]) assert.Equal(t, exCtx.templateServices["bar"].Name, "foo-bar") assert.Equal(t, exCtx.templateServices["bar"].Spec.Ports[0].Port, int32(80)) + assert.Equal(t, exCtx.templateServices["bar"].Spec.Ports[0].Name, "testport") } func TestServiceNameSet(t *testing.T) { diff --git a/rollout/trafficrouting.go b/rollout/trafficrouting.go index c00eb66e1b..1077b4f4b7 100644 --- a/rollout/trafficrouting.go +++ b/rollout/trafficrouting.go @@ -354,11 +354,13 @@ func (c *rolloutContext) calculateWeightDestinationsFromExperiment() []v1alpha1. } for _, templateStatus := range c.currentEx.Status.TemplateStatuses { templateWeight := getTemplateWeight(templateStatus.Name) - weightDestinations = append(weightDestinations, v1alpha1.WeightDestination{ - ServiceName: templateStatus.ServiceName, - PodTemplateHash: templateStatus.PodTemplateHash, - Weight: *templateWeight, - }) + if templateWeight != nil { + weightDestinations = append(weightDestinations, v1alpha1.WeightDestination{ + ServiceName: templateStatus.ServiceName, + PodTemplateHash: templateStatus.PodTemplateHash, + Weight: *templateWeight, + }) + } } } return weightDestinations