@@ -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
}
@@ -1476,10 +1476,10 @@ func findProbe(probes []network.Probe, probe network.Probe) bool {
1476
1476
return false
1477
1477
}
1478
1478
1479
- func findRule (rules []network.LoadBalancingRule , rule network.LoadBalancingRule ) bool {
1479
+ func findRule (rules []network.LoadBalancingRule , rule network.LoadBalancingRule , wantLB bool ) bool {
1480
1480
for _ , existingRule := range rules {
1481
1481
if strings .EqualFold (to .String (existingRule .Name ), to .String (rule .Name )) &&
1482
- equalLoadBalancingRulePropertiesFormat (existingRule .LoadBalancingRulePropertiesFormat , rule .LoadBalancingRulePropertiesFormat ) {
1482
+ equalLoadBalancingRulePropertiesFormat (existingRule .LoadBalancingRulePropertiesFormat , rule .LoadBalancingRulePropertiesFormat , wantLB ) {
1483
1483
return true
1484
1484
}
1485
1485
}
@@ -1488,19 +1488,23 @@ func findRule(rules []network.LoadBalancingRule, rule network.LoadBalancingRule)
1488
1488
1489
1489
// equalLoadBalancingRulePropertiesFormat checks whether the provided LoadBalancingRulePropertiesFormat are equal.
1490
1490
// Note: only fields used in reconcileLoadBalancer are considered.
1491
- func equalLoadBalancingRulePropertiesFormat (s , t * network.LoadBalancingRulePropertiesFormat ) bool {
1491
+ func equalLoadBalancingRulePropertiesFormat (s * network. LoadBalancingRulePropertiesFormat , t * network.LoadBalancingRulePropertiesFormat , wantLB bool ) bool {
1492
1492
if s == nil || t == nil {
1493
1493
return false
1494
1494
}
1495
1495
1496
- return reflect .DeepEqual (s .Protocol , t .Protocol ) &&
1496
+ properties := reflect .DeepEqual (s .Protocol , t .Protocol ) &&
1497
1497
reflect .DeepEqual (s .FrontendIPConfiguration , t .FrontendIPConfiguration ) &&
1498
1498
reflect .DeepEqual (s .BackendAddressPool , t .BackendAddressPool ) &&
1499
1499
reflect .DeepEqual (s .LoadDistribution , t .LoadDistribution ) &&
1500
1500
reflect .DeepEqual (s .FrontendPort , t .FrontendPort ) &&
1501
1501
reflect .DeepEqual (s .BackendPort , t .BackendPort ) &&
1502
- reflect .DeepEqual (s .EnableFloatingIP , t .EnableFloatingIP ) &&
1503
- reflect .DeepEqual (s .IdleTimeoutInMinutes , t .IdleTimeoutInMinutes )
1502
+ reflect .DeepEqual (s .EnableFloatingIP , t .EnableFloatingIP )
1503
+
1504
+ if wantLB {
1505
+ return properties && reflect .DeepEqual (s .IdleTimeoutInMinutes , t .IdleTimeoutInMinutes )
1506
+ }
1507
+ return properties
1504
1508
}
1505
1509
1506
1510
// This compares rule's Name, Protocol, SourcePortRange, DestinationPortRange, SourceAddressPrefix, Access, and Direction.
0 commit comments