Skip to content

Commit

Permalink
fix: use canary service name in alternate backend (#7)
Browse files Browse the repository at this point in the history
Signed-off-by: Chetan Banavikalmutt <[email protected]>
  • Loading branch information
chetan-rns authored Mar 1, 2024
1 parent b691f2d commit 6c4e773
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func (r *RpcPlugin) updateRoute(ctx context.Context, routeName string, rollout *
slog.Info("updating alternate backend weight to " + string(desiredWeight))
openshiftRoute.Spec.AlternateBackends = []routev1.RouteTargetReference{{
Kind: "Service",
Name: routeName,
Name: rollout.Spec.Strategy.Canary.CanaryService,
Weight: &desiredWeight,
}}
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/plugin/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,10 @@ var _ = Describe("Test TrafficRouter plugin for OpenShift route", func() {

// verify if the weights have been updated in the route.
Expect(100 - desiredWeight).To(Equal(*route.Spec.To.Weight))
Expect(route.Spec.AlternateBackends).Should(HaveLen(1))
Expect(route.Spec.AlternateBackends[0].Kind).To(Equal("Service"))
Expect(desiredWeight).To(Equal(*route.Spec.AlternateBackends[0].Weight))
Expect(route.Spec.AlternateBackends[0].Name).To(Equal(rollout.Spec.Strategy.Canary.CanaryService))
})

It("should return an error if the plugin config is not present", func() {
Expand Down

0 comments on commit 6c4e773

Please sign in to comment.