From 10c2bdec864a2e91c61b5edd8bda29f8266b67f7 Mon Sep 17 00:00:00 2001 From: stefanprodan Date: Wed, 16 Jan 2019 13:13:07 +0200 Subject: [PATCH] Use deep copy when updating the virtual service routes --- pkg/controller/router.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/controller/router.go b/pkg/controller/router.go index ce8f787b2..f01594b95 100644 --- a/pkg/controller/router.go +++ b/pkg/controller/router.go @@ -276,13 +276,15 @@ func (c *CanaryRouter) SetRoutes( } return fmt.Errorf("VirtualService %s.%s query error %v", targetName, cd.Namespace, err) } - vs.Spec.Http = []istiov1alpha3.HTTPRoute{ + + vsCopy := vs.DeepCopy() + vsCopy.Spec.Http = []istiov1alpha3.HTTPRoute{ { Route: []istiov1alpha3.DestinationWeight{primary, canary}, }, } - vs, err = c.istioClient.NetworkingV1alpha3().VirtualServices(cd.Namespace).Update(vs) + vs, err = c.istioClient.NetworkingV1alpha3().VirtualServices(cd.Namespace).Update(vsCopy) if err != nil { return fmt.Errorf("VirtualService %s.%s update failed: %v", targetName, cd.Namespace, err)