@@ -50,9 +50,8 @@ func createConfigMapHandlers(lbc *LoadBalancerController, name string) cache.Res
5050 }
5151}
5252
53- // addConfigMapHandler adds the handler for config maps to the controller
54- func (lbc * LoadBalancerController ) addConfigMapHandler (handlers cache.ResourceEventHandlerFuncs , namespace string ) {
55- options := cache.InformerOptions {
53+ func (lbc * LoadBalancerController ) getConfigMapHandlerOptions (handlers cache.ResourceEventHandlerFuncs , namespace string ) cache.InformerOptions {
54+ return cache.InformerOptions {
5655 ListerWatcher : cache .NewListWatchFromClient (
5756 lbc .client .CoreV1 ().RESTClient (),
5857 "configmaps" ,
@@ -62,6 +61,12 @@ func (lbc *LoadBalancerController) addConfigMapHandler(handlers cache.ResourceEv
6261 ResyncPeriod : lbc .resync ,
6362 Handler : handlers ,
6463 }
64+ }
65+
66+ // addConfigMapHandler adds the handler for config maps to the controller
67+ func (lbc * LoadBalancerController ) addConfigMapHandler (handlers cache.ResourceEventHandlerFuncs , namespace string ) {
68+ options := lbc .getConfigMapHandlerOptions (handlers , namespace )
69+
6570 lbc .configMapLister .Store , lbc .configMapController = cache .NewInformerWithOptions (options )
6671 lbc .cacheSyncs = append (lbc .cacheSyncs , lbc .configMapController .HasSynced )
6772}
@@ -75,14 +80,17 @@ func (lbc *LoadBalancerController) syncConfigMap(task task) {
7580 lbc .syncQueue .Requeue (task , err )
7681 return
7782 }
78- if configExists {
79- lbc .configMap = obj .(* v1.ConfigMap )
80- externalStatusAddress , exists := lbc .configMap .Data ["external-status-address" ]
81- if exists {
82- lbc .statusUpdater .SaveStatusFromExternalStatus (externalStatusAddress )
83+ switch key {
84+ case lbc .nginxConfigMapName :
85+ if configExists {
86+ lbc .configMap = obj .(* v1.ConfigMap )
87+ externalStatusAddress , exists := lbc .configMap .Data ["external-status-address" ]
88+ if exists {
89+ lbc .statusUpdater .SaveStatusFromExternalStatus (externalStatusAddress )
90+ }
91+ } else {
92+ lbc .configMap = nil
8393 }
84- } else {
85- lbc .configMap = nil
8694 }
8795
8896 if ! lbc .isNginxReady {
0 commit comments