Skip to content

Commit c7e8084

Browse files
authored
fix: Istio does not switch the traffic. Fix the VS new object creation when the tls routes nil (argoproj#1553)
Signed-off-by: Andrii Perenesenko <[email protected]>
1 parent 9dc13e5 commit c7e8084

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

rollout/trafficrouting/istio/istio.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,9 @@ func (r *Reconciler) reconcileVirtualService(obj *unstructured.Unstructured, vsv
218218
if err != nil {
219219
return newObj, len(patches) > 0, err
220220
}
221-
err = unstructured.SetNestedSlice(newObj.Object, tlsRoutesI, "spec", Tls)
221+
if tlsRoutesI != nil {
222+
err = unstructured.SetNestedSlice(newObj.Object, tlsRoutesI, "spec", Tls)
223+
}
222224
return newObj, len(patches) > 0, err
223225
}
224226

@@ -525,7 +527,6 @@ func (r *Reconciler) Type() string {
525527
func (r *Reconciler) SetWeight(desiredWeight int32, additionalDestinations ...v1alpha1.WeightDestination) error {
526528
ctx := context.TODO()
527529
var vsvc *unstructured.Unstructured
528-
var err error
529530
var virtualServices []v1alpha1.IstioVirtualService
530531

531532
if istioutil.MultipleVirtualServiceConfigured(r.rollout) {
@@ -541,6 +542,7 @@ func (r *Reconciler) SetWeight(desiredWeight int32, additionalDestinations ...v1
541542
namespace = r.rollout.Namespace
542543
}
543544

545+
var err error
544546
client := r.client.Resource(istioutil.GetIstioVirtualServiceGVR()).Namespace(namespace)
545547
if r.virtualServiceLister != nil {
546548
vsvc, err = r.virtualServiceLister.Namespace(namespace).Get(vsvcName)
@@ -564,9 +566,11 @@ func (r *Reconciler) SetWeight(desiredWeight int32, additionalDestinations ...v1
564566
if err == nil {
565567
r.log.Debugf("Updated VirtualService: %s", modifiedVirtualService)
566568
r.recorder.Eventf(r.rollout, record.EventOptions{EventReason: "Updated VirtualService"}, "VirtualService `%s` set to desiredWeight '%d'", vsvcName, desiredWeight)
569+
} else {
570+
return err
567571
}
568572
}
569-
return err
573+
return nil
570574
}
571575

572576
func (r *Reconciler) VerifyWeight(desiredWeight int32, additionalDestinations ...v1alpha1.WeightDestination) (*bool, error) {

0 commit comments

Comments
 (0)