@@ -604,7 +604,7 @@ func (az *Cloud) reconcileLoadBalancer(clusterName string, service *v1.Service,
604
604
lbBackendPoolID := az .getBackendPoolID (lbName , lbBackendPoolName )
605
605
606
606
lbIdleTimeout , err := getIdleTimeout (service )
607
- if err != nil {
607
+ if wantLb && err != nil {
608
608
return nil , err
609
609
}
610
610
@@ -789,7 +789,7 @@ func (az *Cloud) reconcileLoadBalancer(clusterName string, service *v1.Service,
789
789
if az .serviceOwnsRule (service , * existingRule .Name ) {
790
790
keepRule := false
791
791
klog .V (10 ).Infof ("reconcileLoadBalancer for service (%s)(%t): lb rule(%s) - considering evicting" , serviceName , wantLb , * existingRule .Name )
792
- if findRule (expectedRules , existingRule ) {
792
+ if findRule (expectedRules , existingRule , wantLb ) {
793
793
klog .V (10 ).Infof ("reconcileLoadBalancer for service (%s)(%t): lb rule(%s) - keeping" , serviceName , wantLb , * existingRule .Name )
794
794
keepRule = true
795
795
}
@@ -803,7 +803,7 @@ func (az *Cloud) reconcileLoadBalancer(clusterName string, service *v1.Service,
803
803
// update rules: add needed
804
804
for _ , expectedRule := range expectedRules {
805
805
foundRule := false
806
- if findRule (updatedRules , expectedRule ) {
806
+ if findRule (updatedRules , expectedRule , wantLb ) {
807
807
klog .V (10 ).Infof ("reconcileLoadBalancer for service (%s)(%t): lb rule(%s) - already exists" , serviceName , wantLb , * expectedRule .Name )
808
808
foundRule = true
809
809
}
@@ -1474,10 +1474,10 @@ func findProbe(probes []network.Probe, probe network.Probe) bool {
1474
1474
return false
1475
1475
}
1476
1476
1477
- func findRule (rules []network.LoadBalancingRule , rule network.LoadBalancingRule ) bool {
1477
+ func findRule (rules []network.LoadBalancingRule , rule network.LoadBalancingRule , wantLB bool ) bool {
1478
1478
for _ , existingRule := range rules {
1479
1479
if strings .EqualFold (to .String (existingRule .Name ), to .String (rule .Name )) &&
1480
- equalLoadBalancingRulePropertiesFormat (existingRule .LoadBalancingRulePropertiesFormat , rule .LoadBalancingRulePropertiesFormat ) {
1480
+ equalLoadBalancingRulePropertiesFormat (existingRule .LoadBalancingRulePropertiesFormat , rule .LoadBalancingRulePropertiesFormat , wantLB ) {
1481
1481
return true
1482
1482
}
1483
1483
}
@@ -1486,19 +1486,23 @@ func findRule(rules []network.LoadBalancingRule, rule network.LoadBalancingRule)
1486
1486
1487
1487
// equalLoadBalancingRulePropertiesFormat checks whether the provided LoadBalancingRulePropertiesFormat are equal.
1488
1488
// Note: only fields used in reconcileLoadBalancer are considered.
1489
- func equalLoadBalancingRulePropertiesFormat (s , t * network.LoadBalancingRulePropertiesFormat ) bool {
1489
+ func equalLoadBalancingRulePropertiesFormat (s * network. LoadBalancingRulePropertiesFormat , t * network.LoadBalancingRulePropertiesFormat , wantLB bool ) bool {
1490
1490
if s == nil || t == nil {
1491
1491
return false
1492
1492
}
1493
1493
1494
- return reflect .DeepEqual (s .Protocol , t .Protocol ) &&
1494
+ properties := reflect .DeepEqual (s .Protocol , t .Protocol ) &&
1495
1495
reflect .DeepEqual (s .FrontendIPConfiguration , t .FrontendIPConfiguration ) &&
1496
1496
reflect .DeepEqual (s .BackendAddressPool , t .BackendAddressPool ) &&
1497
1497
reflect .DeepEqual (s .LoadDistribution , t .LoadDistribution ) &&
1498
1498
reflect .DeepEqual (s .FrontendPort , t .FrontendPort ) &&
1499
1499
reflect .DeepEqual (s .BackendPort , t .BackendPort ) &&
1500
- reflect .DeepEqual (s .EnableFloatingIP , t .EnableFloatingIP ) &&
1501
- reflect .DeepEqual (s .IdleTimeoutInMinutes , t .IdleTimeoutInMinutes )
1500
+ reflect .DeepEqual (s .EnableFloatingIP , t .EnableFloatingIP )
1501
+
1502
+ if wantLB {
1503
+ return properties && reflect .DeepEqual (s .IdleTimeoutInMinutes , t .IdleTimeoutInMinutes )
1504
+ }
1505
+ return properties
1502
1506
}
1503
1507
1504
1508
// This compares rule's Name, Protocol, SourcePortRange, DestinationPortRange, SourceAddressPrefix, Access, and Direction.
0 commit comments