Skip to content

Commit

Permalink
Use deep copy when updating the virtual service routes
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanprodan committed Jan 16, 2019
1 parent 4bf3b70 commit 10c2bde
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/controller/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 10c2bde

Please sign in to comment.