@@ -50,9 +50,8 @@ func createConfigMapHandlers(lbc *LoadBalancerController, name string) cache.Res
50
50
}
51
51
}
52
52
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 {
56
55
ListerWatcher : cache .NewListWatchFromClient (
57
56
lbc .client .CoreV1 ().RESTClient (),
58
57
"configmaps" ,
@@ -62,6 +61,12 @@ func (lbc *LoadBalancerController) addConfigMapHandler(handlers cache.ResourceEv
62
61
ResyncPeriod : lbc .resync ,
63
62
Handler : handlers ,
64
63
}
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
+
65
70
lbc .configMapLister .Store , lbc .configMapController = cache .NewInformerWithOptions (options )
66
71
lbc .cacheSyncs = append (lbc .cacheSyncs , lbc .configMapController .HasSynced )
67
72
}
@@ -75,14 +80,17 @@ func (lbc *LoadBalancerController) syncConfigMap(task task) {
75
80
lbc .syncQueue .Requeue (task , err )
76
81
return
77
82
}
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
83
93
}
84
- } else {
85
- lbc .configMap = nil
86
94
}
87
95
88
96
if ! lbc .isNginxReady {
0 commit comments