@@ -95,7 +95,6 @@ func main() {
95
95
klog .Fatal (err .Error ())
96
96
}
97
97
98
- informerFactory := informers .NewSharedInformerFactory (kubeClient , * resyncPeriod )
99
98
mux := http .NewServeMux ()
100
99
metricsManager := metrics .NewCSIMetricsManager ("" /* driverName */ )
101
100
csiClient , err := csi .New (* csiAddress , * timeout , metricsManager )
@@ -135,15 +134,17 @@ func main() {
135
134
}
136
135
137
136
modifierName := csiModifier .Name ()
138
- mc := controller .NewModifyController (
139
- modifierName ,
140
- csiModifier ,
141
- kubeClient ,
142
- * resyncPeriod ,
143
- informerFactory ,
144
- workqueue .NewItemExponentialFailureRateLimiter (* retryIntervalStart , * retryIntervalMax ),
145
- true , /* retryFailure */
146
- )
137
+ mc := func () controller.ModifyController {
138
+ return controller .NewModifyController (
139
+ modifierName ,
140
+ csiModifier ,
141
+ kubeClient ,
142
+ * resyncPeriod ,
143
+ informers .NewSharedInformerFactory (kubeClient , * resyncPeriod ),
144
+ workqueue .NewItemExponentialFailureRateLimiter (* retryIntervalStart , * retryIntervalMax ),
145
+ true , /* retryFailure */
146
+ )
147
+ }
147
148
leaseChannel := make (chan * v1.Lease )
148
149
go leaseHandler (podName , mc , leaseChannel )
149
150
@@ -162,12 +163,11 @@ func main() {
162
163
}
163
164
},
164
165
})
165
- informerFactory .Start (wait .NeverStop )
166
166
informerFactoryLeases .Start (wait .NeverStop )
167
167
leaseInformer .Run (wait .NeverStop )
168
168
}
169
169
170
- func leaseHandler (podName string , mc controller.ModifyController , leaseChannel chan * v1.Lease ) {
170
+ func leaseHandler (podName string , mc func () controller.ModifyController , leaseChannel chan * v1.Lease ) {
171
171
var cancel context.CancelFunc = nil
172
172
173
173
klog .InfoS ("leaseHandler: Looking for external-resizer lease holder" )
@@ -191,7 +191,7 @@ func leaseHandler(podName string, mc controller.ModifyController, leaseChannel c
191
191
var ctx context.Context
192
192
ctx , cancel = context .WithCancel (context .Background ())
193
193
klog .InfoS ("leaseHandler: Starting ModifyController" , "podName" , podName , "currentLeader" , currentLeader )
194
- go mc .Run (* workers , ctx )
194
+ go mc () .Run (* workers , ctx )
195
195
} else if currentLeader != podName && cancel != nil {
196
196
klog .InfoS ("leaseHandler: Stopping ModifyController" , "podName" , podName , "currentLeader" , currentLeader )
197
197
cancel ()
0 commit comments