@@ -158,6 +158,8 @@ type LoadBalancerController struct {
158158 certManagerController * cm_controller.CmController
159159 externalDNSController * ed_controller.ExtDNSController
160160 batchSyncEnabled bool
161+ updateAllConfigsOnBatch bool
162+ enableBatchReload bool
161163 isIPV6Disabled bool
162164 namespaceWatcherController cache.Controller
163165}
@@ -768,23 +770,23 @@ func (lbc *LoadBalancerController) getNamespacedInformer(ns string) *namespacedI
768770 return nsi
769771}
770772
771- func (lbc * LoadBalancerController ) syncEndpointSlices (task task ) {
773+ func (lbc * LoadBalancerController ) syncEndpointSlices (task task ) bool {
772774 key := task .Key
773775 var obj interface {}
774776 var endpointSliceExists bool
775777 var err error
776- glog . V ( 3 ). Infof ( "Syncing EndpointSlices %v" , key )
778+ var resourcesFound bool
777779
778780 ns , _ , _ := cache .SplitMetaNamespaceKey (key )
779781 obj , endpointSliceExists , err = lbc .getNamespacedInformer (ns ).endpointSliceLister .GetByKey (key )
780782
781783 if err != nil {
782784 lbc .syncQueue .Requeue (task , err )
783- return
785+ return false
784786 }
785787
786788 if ! endpointSliceExists {
787- return
789+ return false
788790 }
789791
790792 endpointSlice := obj .(* discovery_v1.EndpointSlice )
@@ -793,6 +795,7 @@ func (lbc *LoadBalancerController) syncEndpointSlices(task task) {
793795 resourceExes := lbc .createExtendedResources (svcResource )
794796
795797 if len (resourceExes .IngressExes ) > 0 {
798+ resourcesFound = true
796799 glog .V (3 ).Infof ("Updating EndpointSlices for %v" , resourceExes .IngressExes )
797800 err = lbc .configurator .UpdateEndpoints (resourceExes .IngressExes )
798801 if err != nil {
@@ -801,6 +804,7 @@ func (lbc *LoadBalancerController) syncEndpointSlices(task task) {
801804 }
802805
803806 if len (resourceExes .MergeableIngresses ) > 0 {
807+ resourcesFound = true
804808 glog .V (3 ).Infof ("Updating EndpointSlices for %v" , resourceExes .MergeableIngresses )
805809 err = lbc .configurator .UpdateEndpointsMergeableIngress (resourceExes .MergeableIngresses )
806810 if err != nil {
@@ -810,6 +814,7 @@ func (lbc *LoadBalancerController) syncEndpointSlices(task task) {
810814
811815 if lbc .areCustomResourcesEnabled {
812816 if len (resourceExes .VirtualServerExes ) > 0 {
817+ resourcesFound = true
813818 glog .V (3 ).Infof ("Updating EndpointSlices for %v" , resourceExes .VirtualServerExes )
814819 err := lbc .configurator .UpdateEndpointsForVirtualServers (resourceExes .VirtualServerExes )
815820 if err != nil {
@@ -818,13 +823,15 @@ func (lbc *LoadBalancerController) syncEndpointSlices(task task) {
818823 }
819824
820825 if len (resourceExes .TransportServerExes ) > 0 {
826+ resourcesFound = true
821827 glog .V (3 ).Infof ("Updating EndpointSlices for %v" , resourceExes .TransportServerExes )
822828 err := lbc .configurator .UpdateEndpointsForTransportServers (resourceExes .TransportServerExes )
823829 if err != nil {
824830 glog .Errorf ("Error updating EndpointSlices for %v: %v" , resourceExes .TransportServerExes , err )
825831 }
826832 }
827833 }
834+ return resourcesFound
828835}
829836
830837func (lbc * LoadBalancerController ) createExtendedResources (resources []Resource ) configs.ExtendedResources {
@@ -969,15 +976,24 @@ func (lbc *LoadBalancerController) sync(task task) {
969976 lbc .syncLock .Lock ()
970977 defer lbc .syncLock .Unlock ()
971978 }
979+ if lbc .batchSyncEnabled && task .Kind != endpointslice {
980+ lbc .enableBatchReload = true
981+ }
972982 switch task .Kind {
973983 case ingress :
974984 lbc .syncIngress (task )
975985 lbc .updateIngressMetrics ()
976986 lbc .updateTransportServerMetrics ()
977987 case configMap :
988+ if lbc .batchSyncEnabled {
989+ lbc .updateAllConfigsOnBatch = true
990+ }
978991 lbc .syncConfigMap (task )
979992 case endpointslice :
980- lbc .syncEndpointSlices (task )
993+ resourcesFound := lbc .syncEndpointSlices (task )
994+ if lbc .batchSyncEnabled && resourcesFound {
995+ lbc .enableBatchReload = true
996+ }
981997 case secret :
982998 lbc .syncSecret (task )
983999 case service :
@@ -1027,7 +1043,13 @@ func (lbc *LoadBalancerController) sync(task task) {
10271043 if lbc .batchSyncEnabled && lbc .syncQueue .Len () == 0 {
10281044 lbc .batchSyncEnabled = false
10291045 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+ }
10311053
10321054 glog .V (3 ).Infof ("Batch sync completed" )
10331055 }
@@ -2299,7 +2321,6 @@ func (lbc *LoadBalancerController) updateTransportServerMetrics() {
22992321
23002322func (lbc * LoadBalancerController ) syncService (task task ) {
23012323 key := task .Key
2302- glog .V (3 ).Infof ("Syncing service %v" , key )
23032324
23042325 var obj interface {}
23052326 var exists bool
@@ -2317,6 +2338,7 @@ func (lbc *LoadBalancerController) syncService(task task) {
23172338 // In that case we need to update the statuses of all resources
23182339
23192340 if lbc .IsExternalServiceKeyForStatus (key ) {
2341+ glog .V (3 ).Infof ("Syncing service %v" , key )
23202342
23212343 if ! exists {
23222344 // service got removed
@@ -2361,6 +2383,7 @@ func (lbc *LoadBalancerController) syncService(task task) {
23612383 if len (resources ) == 0 {
23622384 return
23632385 }
2386+ glog .V (3 ).Infof ("Syncing service %v" , key )
23642387
23652388 glog .V (3 ).Infof ("Updating %v resources" , len (resources ))
23662389
0 commit comments