@@ -105,22 +105,11 @@ func startNodeIpamController(ctx context.Context, controllerContext ControllerCo
105
105
return nil , false , nil
106
106
}
107
107
108
- // failure: bad cidrs in config
109
- clusterCIDRs , dualStack , err := processCIDRs (controllerContext .ComponentConfig .KubeCloudShared .ClusterCIDR )
108
+ clusterCIDRs , err := validateCIDRs (controllerContext .ComponentConfig .KubeCloudShared .ClusterCIDR )
110
109
if err != nil {
111
110
return nil , false , err
112
111
}
113
112
114
- // failure: more than one cidr but they are not configured as dual stack
115
- if len (clusterCIDRs ) > 1 && ! dualStack {
116
- return nil , false , fmt .Errorf ("len of ClusterCIDRs==%v and they are not configured as dual stack (at least one from each IPFamily)" , len (clusterCIDRs ))
117
- }
118
-
119
- // failure: more than cidrs is not allowed even with dual stack
120
- if len (clusterCIDRs ) > 2 {
121
- return nil , false , fmt .Errorf ("len of clusters is:%v > more than max allowed of 2" , len (clusterCIDRs ))
122
- }
123
-
124
113
// service cidr processing
125
114
if len (strings .TrimSpace (controllerContext .ComponentConfig .NodeIPAMController .ServiceCIDR )) != 0 {
126
115
_ , serviceCIDR , err = netutils .ParseCIDRSloppy (controllerContext .ComponentConfig .NodeIPAMController .ServiceCIDR )
@@ -238,22 +227,11 @@ func startRouteController(ctx context.Context, controllerContext ControllerConte
238
227
return nil , false , nil
239
228
}
240
229
241
- // failure: bad cidrs in config
242
- clusterCIDRs , dualStack , err := processCIDRs (controllerContext .ComponentConfig .KubeCloudShared .ClusterCIDR )
230
+ clusterCIDRs , err := validateCIDRs (controllerContext .ComponentConfig .KubeCloudShared .ClusterCIDR )
243
231
if err != nil {
244
232
return nil , false , err
245
233
}
246
234
247
- // failure: more than one cidr but they are not configured as dual stack
248
- if len (clusterCIDRs ) > 1 && ! dualStack {
249
- return nil , false , fmt .Errorf ("len of ClusterCIDRs==%v and they are not configured as dual stack (at least one from each IPFamily" , len (clusterCIDRs ))
250
- }
251
-
252
- // failure: more than cidrs is not allowed even with dual stack
253
- if len (clusterCIDRs ) > 2 {
254
- return nil , false , fmt .Errorf ("length of clusterCIDRs is:%v more than max allowed of 2" , len (clusterCIDRs ))
255
- }
256
-
257
235
routeController := routecontroller .New (routes ,
258
236
controllerContext .ClientBuilder .ClientOrDie ("route-controller" ),
259
237
controllerContext .InformerFactory .Core ().V1 ().Nodes (),
@@ -297,10 +275,6 @@ func startPersistentVolumeBinderController(ctx context.Context, controllerContex
297
275
}
298
276
299
277
func startAttachDetachController (ctx context.Context , controllerContext ControllerContext ) (controller.Interface , bool , error ) {
300
- if controllerContext .ComponentConfig .AttachDetachController .ReconcilerSyncLoopPeriod .Duration < time .Second {
301
- return nil , true , fmt .Errorf ("duration time must be greater than one second as set via command line option reconcile-sync-loop-period" )
302
- }
303
-
304
278
csiNodeInformer := controllerContext .InformerFactory .Storage ().V1 ().CSINodes ()
305
279
csiDriverInformer := controllerContext .InformerFactory .Storage ().V1 ().CSIDrivers ()
306
280
@@ -581,6 +555,29 @@ func startTTLAfterFinishedController(ctx context.Context, controllerContext Cont
581
555
return nil , true , nil
582
556
}
583
557
558
+ // processCIDRs is a helper function that works on a comma separated cidrs and returns
559
+ // a list of typed cidrs
560
+ // error if failed to parse any of the cidrs or invalid length of cidrs
561
+ func validateCIDRs (cidrsList string ) ([]* net.IPNet , error ) {
562
+ // failure: bad cidrs in config
563
+ clusterCIDRs , dualStack , err := processCIDRs (cidrsList )
564
+ if err != nil {
565
+ return nil , err
566
+ }
567
+
568
+ // failure: more than one cidr but they are not configured as dual stack
569
+ if len (clusterCIDRs ) > 1 && ! dualStack {
570
+ return nil , fmt .Errorf ("len of ClusterCIDRs==%v and they are not configured as dual stack (at least one from each IPFamily" , len (clusterCIDRs ))
571
+ }
572
+
573
+ // failure: more than cidrs is not allowed even with dual stack
574
+ if len (clusterCIDRs ) > 2 {
575
+ return nil , fmt .Errorf ("length of clusterCIDRs is:%v more than max allowed of 2" , len (clusterCIDRs ))
576
+ }
577
+
578
+ return clusterCIDRs , nil
579
+ }
580
+
584
581
// processCIDRs is a helper function that works on a comma separated cidrs and returns
585
582
// a list of typed cidrs
586
583
// a flag if cidrs represents a dual stack
0 commit comments