Skip to content

Commit

Permalink
fix: append weighted destination only when weight is mentioned in exp…
Browse files Browse the repository at this point in the history
…eriment template

Signed-off-by: divyansh375 <[email protected]>
  • Loading branch information
divyansh375 committed Apr 20, 2023
1 parent e7e45f7 commit 90e544c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions experiments/experiment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
12 changes: 7 additions & 5 deletions rollout/trafficrouting.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 90e544c

Please sign in to comment.