From 6061e6889bbe7ebe0d95cd30a73db9acb63964fe Mon Sep 17 00:00:00 2001 From: Darshan Hassan Shashikumar <62122269+darshanhs09@users.noreply.github.com> Date: Thu, 12 Aug 2021 04:24:40 -0700 Subject: [PATCH] feat: Multiple VirtualService objects support for canary strategy of Argo Rollouts. Addressed few minor review comments fixes #1100 --- rollout/trafficrouting/istio/istio_test.go | 23 +++++++++------------- utils/istio/istio.go | 3 --- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/rollout/trafficrouting/istio/istio_test.go b/rollout/trafficrouting/istio/istio_test.go index d97e4ab513..dd44dd9305 100644 --- a/rollout/trafficrouting/istio/istio_test.go +++ b/rollout/trafficrouting/istio/istio_test.go @@ -855,17 +855,12 @@ func TestMultipleVirtualServiceReconcileInferredSingleRoute(t *testing.T) { assert.Equal(t, "update", actions[1].GetVerb()) // Verify we actually made the correct change - vsvcUn1, err := client.Resource(istioutil.GetIstioVirtualServiceGVR()).Namespace(ro.Namespace).Get(context.TODO(), "vsvc1", metav1.GetOptions{}) - assert.NoError(t, err) - routes1, _, _ := unstructured.NestedSlice(vsvcUn1.Object, "spec", "http") - route1 := routes1[0].(map[string]interface{}) - checkDestination(t, route1, "stable", 90) - checkDestination(t, route1, "canary", 10) - - vsvcUn2, err := client.Resource(istioutil.GetIstioVirtualServiceGVR()).Namespace(ro.Namespace).Get(context.TODO(), "vsvc2", metav1.GetOptions{}) - assert.NoError(t, err) - routes2, _, _ := unstructured.NestedSlice(vsvcUn2.Object, "spec", "http") - route2 := routes2[0].(map[string]interface{}) - checkDestination(t, route2, "stable", 90) - checkDestination(t, route2, "canary", 10) -} + for _, vsvName := range []string{"vsvc1", "vsvc2"} { + vsvcUn, err := client.Resource(istioutil.GetIstioVirtualServiceGVR()).Namespace(ro.Namespace).Get(context.TODO(), vsvName, metav1.GetOptions{}) + assert.NoError(t, err) + routes, _, _ := unstructured.NestedSlice(vsvcUn.Object, "spec", "http") + route := routes[0].(map[string]interface{}) + checkDestination(t, route, "stable", 90) + checkDestination(t, route, "canary", 10) + } +} \ No newline at end of file diff --git a/utils/istio/istio.go b/utils/istio/istio.go index 252197ba9c..827c54a6a1 100644 --- a/utils/istio/istio.go +++ b/utils/istio/istio.go @@ -80,9 +80,6 @@ func GetRolloutVirtualServiceKeys(ro *v1alpha1.Rollout) []string { } if MultipleVirtualServiceConfigured(ro) { - if canary.TrafficRouting.Istio.VirtualService.Name != "" { - return []string{} - } virtualServices = ro.Spec.Strategy.Canary.TrafficRouting.Istio.VirtualServices } else { virtualServices = []v1alpha1.IstioVirtualService{ro.Spec.Strategy.Canary.TrafficRouting.Istio.VirtualService}