@@ -158,6 +158,8 @@ type LoadBalancerController struct {
158
158
certManagerController * cm_controller.CmController
159
159
externalDNSController * ed_controller.ExtDNSController
160
160
batchSyncEnabled bool
161
+ updateAllConfigsOnBatch bool
162
+ enableBatchReload bool
161
163
isIPV6Disabled bool
162
164
namespaceWatcherController cache.Controller
163
165
}
@@ -768,23 +770,23 @@ func (lbc *LoadBalancerController) getNamespacedInformer(ns string) *namespacedI
768
770
return nsi
769
771
}
770
772
771
- func (lbc * LoadBalancerController ) syncEndpointSlices (task task ) {
773
+ func (lbc * LoadBalancerController ) syncEndpointSlices (task task ) bool {
772
774
key := task .Key
773
775
var obj interface {}
774
776
var endpointSliceExists bool
775
777
var err error
776
- glog . V ( 3 ). Infof ( "Syncing EndpointSlices %v" , key )
778
+ var resourcesFound bool
777
779
778
780
ns , _ , _ := cache .SplitMetaNamespaceKey (key )
779
781
obj , endpointSliceExists , err = lbc .getNamespacedInformer (ns ).endpointSliceLister .GetByKey (key )
780
782
781
783
if err != nil {
782
784
lbc .syncQueue .Requeue (task , err )
783
- return
785
+ return false
784
786
}
785
787
786
788
if ! endpointSliceExists {
787
- return
789
+ return false
788
790
}
789
791
790
792
endpointSlice := obj .(* discovery_v1.EndpointSlice )
@@ -793,6 +795,7 @@ func (lbc *LoadBalancerController) syncEndpointSlices(task task) {
793
795
resourceExes := lbc .createExtendedResources (svcResource )
794
796
795
797
if len (resourceExes .IngressExes ) > 0 {
798
+ resourcesFound = true
796
799
glog .V (3 ).Infof ("Updating EndpointSlices for %v" , resourceExes .IngressExes )
797
800
err = lbc .configurator .UpdateEndpoints (resourceExes .IngressExes )
798
801
if err != nil {
@@ -801,6 +804,7 @@ func (lbc *LoadBalancerController) syncEndpointSlices(task task) {
801
804
}
802
805
803
806
if len (resourceExes .MergeableIngresses ) > 0 {
807
+ resourcesFound = true
804
808
glog .V (3).Infof ("Updating EndpointSlices for %v" , resourceExes .MergeableIngresses )
805
809
err = lbc .configurator .UpdateEndpointsMergeableIngress (resourceExes .MergeableIngresses )
806
810
if err != nil {
@@ -810,6 +814,7 @@ func (lbc *LoadBalancerController) syncEndpointSlices(task task) {
810
814
811
815
if lbc .areCustomResourcesEnabled {
812
816
if len (resourceExes .VirtualServerExes ) > 0 {
817
+ resourcesFound = true
813
818
glog .V (3 ).Infof ("Updating EndpointSlices for %v" , resourceExes .VirtualServerExes )
814
819
err := lbc .configurator .UpdateEndpointsForVirtualServers (resourceExes .VirtualServerExes )
815
820
if err != nil {
@@ -818,13 +823,15 @@ func (lbc *LoadBalancerController) syncEndpointSlices(task task) {
818
823
}
819
824
820
825
if len (resourceExes .TransportServerExes ) > 0 {
826
+ resourcesFound = true
821
827
glog .V (3 ).Infof ("Updating EndpointSlices for %v" , resourceExes .TransportServerExes )
822
828
err := lbc .configurator .UpdateEndpointsForTransportServers (resourceExes .TransportServerExes )
823
829
if err != nil {
824
830
glog .Errorf ("Error updating EndpointSlices for %v: %v" , resourceExes .TransportServerExes , err )
825
831
}
826
832
}
827
833
}
834
+ return resourcesFound
828
835
}
829
836
830
837
func (lbc * LoadBalancerController ) createExtendedResources (resources []Resource ) configs.ExtendedResources {
@@ -969,15 +976,24 @@ func (lbc *LoadBalancerController) sync(task task) {
969
976
lbc .syncLock .Lock ()
970
977
defer lbc .syncLock .Unlock ()
971
978
}
979
+ if lbc .batchSyncEnabled && task .Kind != endpointslice {
980
+ lbc .enableBatchReload = true
981
+ }
972
982
switch task .Kind {
973
983
case ingress :
974
984
lbc .syncIngress (task )
975
985
lbc .updateIngressMetrics ()
976
986
lbc .updateTransportServerMetrics ()
977
987
case configMap :
988
+ if lbc .batchSyncEnabled {
989
+ lbc .updateAllConfigsOnBatch = true
990
+ }
978
991
lbc .syncConfigMap (task )
979
992
case endpointslice :
980
- lbc .syncEndpointSlices (task )
993
+ resourcesFound := lbc .syncEndpointSlices (task )
994
+ if lbc .batchSyncEnabled && resourcesFound {
995
+ lbc .enableBatchReload = true
996
+ }
981
997
case secret :
982
998
lbc .syncSecret (task )
983
999
case service :
@@ -1027,7 +1043,13 @@ func (lbc *LoadBalancerController) sync(task task) {
1027
1043
if lbc .batchSyncEnabled && lbc .syncQueue .Len () == 0 {
1028
1044
lbc .batchSyncEnabled = false
1029
1045
lbc .configurator .EnableReloads ()
1030
- lbc .updateAllConfigs ()
1046
+ if lbc .updateAllConfigsOnBatch {
1047
+ lbc .updateAllConfigs ()
1048
+ } else {
1049
+ if err := lbc .configurator .ReloadForBatchUpdates (lbc .enableBatchReload ); err != nil {
1050
+ glog .Errorf ("error reloading for batch updates: %v" , err )
1051
+ }
1052
+ }
1031
1053
1032
1054
glog .V (3 ).Infof ("Batch sync completed" )
1033
1055
}
@@ -2299,7 +2321,6 @@ func (lbc *LoadBalancerController) updateTransportServerMetrics() {
2299
2321
2300
2322
func (lbc * LoadBalancerController ) syncService (task task ) {
2301
2323
key := task .Key
2302
- glog .V (3 ).Infof ("Syncing service %v" , key )
2303
2324
2304
2325
var obj interface {}
2305
2326
var exists bool
@@ -2317,6 +2338,7 @@ func (lbc *LoadBalancerController) syncService(task task) {
2317
2338
// In that case we need to update the statuses of all resources
2318
2339
2319
2340
if lbc .IsExternalServiceKeyForStatus (key ) {
2341
+ glog .V (3 ).Infof ("Syncing service %v" , key )
2320
2342
2321
2343
if ! exists {
2322
2344
// service got removed
@@ -2361,6 +2383,7 @@ func (lbc *LoadBalancerController) syncService(task task) {
2361
2383
if len (resources ) == 0 {
2362
2384
return
2363
2385
}
2386
+ glog .V (3 ).Infof ("Syncing service %v" , key )
2364
2387
2365
2388
glog .V (3 ).Infof ("Updating %v resources" , len (resources ))
2366
2389
0 commit comments