Skip to content

Commit 38766d4

Browse files
committed
ensure VirtualService is updated when delegation is enabled
Signed-off-by: Jhuliano Skittberg Moreno <[email protected]>
1 parent ff1ad85 commit 38766d4

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pkg/router/istio.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,19 @@ func (ir *IstioRouter) reconcileVirtualService(canary *flaggerv1.Canary) error {
294294
}
295295

296296
if canary.Spec.Service.Delegation {
297+
updateVS := len(virtualService.Spec.Hosts) > 0 || len(virtualService.Spec.Gateways) > 0
297298
// delegate VirtualService requires the hosts and gateway empty.
298299
virtualService.Spec.Gateways = []string{}
299300
virtualService.Spec.Hosts = []string{}
301+
302+
if updateVS {
303+
_, err = ir.istioClient.NetworkingV1beta1().VirtualServices(canary.Namespace).Update(context.TODO(), virtualService, metav1.UpdateOptions{})
304+
if err != nil {
305+
return fmt.Errorf("VirtualService %s.%s update error: %w", apexName, canary.Namespace, err)
306+
}
307+
ir.logger.With("canary", fmt.Sprintf("%s.%s", canary.Name, canary.Namespace)).
308+
Infof("VirtualService %s.%s updated for delegation", virtualService.GetName(), canary.Namespace)
309+
}
300310
}
301311

302312
ignoreCmpOptions := []cmp.Option{

0 commit comments

Comments
 (0)