From 7ae0d49e809d2b115072db523ff1c429f9b6b8c6 Mon Sep 17 00:00:00 2001 From: Carlos Sanchez Date: Fri, 11 Jan 2019 17:40:50 +0100 Subject: [PATCH] Tries to create VirtualService that already exists When canary name is different than deployment name VirtualService croc-hunter-jenkinsx.jx-staging create error virtualservices.networking.istio.io "croc-hunter-jenkinsx" already exists --- pkg/controller/router.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/controller/router.go b/pkg/controller/router.go index f85e8e133..1d71b4d5a 100644 --- a/pkg/controller/router.go +++ b/pkg/controller/router.go @@ -164,12 +164,13 @@ func (c *CanaryRouter) createServices(cd *flaggerv1.Canary) error { } func (c *CanaryRouter) createVirtualService(cd *flaggerv1.Canary) error { - canaryName := cd.Spec.TargetRef.Name + canaryName := cd.Name primaryName := fmt.Sprintf("%s-primary", canaryName) hosts := append(cd.Spec.Service.Hosts, canaryName) gateways := append(cd.Spec.Service.Gateways, "mesh") virtualService, err := c.istioClient.NetworkingV1alpha3().VirtualServices(cd.Namespace).Get(canaryName, metav1.GetOptions{}) if errors.IsNotFound(err) { + c.logger.Debugf("VirtualService %s.%s not found", canaryName, cd.Namespace) virtualService = &istiov1alpha3.VirtualService{ ObjectMeta: metav1.ObjectMeta{ Name: cd.Name, @@ -212,6 +213,7 @@ func (c *CanaryRouter) createVirtualService(cd *flaggerv1.Canary) error { }, } + c.logger.Debugf("Creating VirtualService %s.%s", virtualService.GetName(), cd.Namespace) _, err = c.istioClient.NetworkingV1alpha3().VirtualServices(cd.Namespace).Create(virtualService) if err != nil { return fmt.Errorf("VirtualService %s.%s create error %v", cd.Name, cd.Namespace, err)