@@ -268,7 +268,7 @@ func (r *ROSAControlPlaneReconciler) reconcileNormal(ctx context.Context, rosaSc
268
268
billingAccount = rosaScope .ControlPlane .Spec .BillingAccount
269
269
}
270
270
271
- spec := ocm.Spec {
271
+ ocmClusterSpec := ocm.Spec {
272
272
DryRun : ptr .To (false ),
273
273
Name : rosaScope .RosaClusterName (),
274
274
Region : * rosaScope .ControlPlane .Spec .Region ,
@@ -282,7 +282,6 @@ func (r *ROSAControlPlaneReconciler) reconcileNormal(ctx context.Context, rosaSc
282
282
283
283
SubnetIds : rosaScope .ControlPlane .Spec .Subnets ,
284
284
AvailabilityZones : rosaScope .ControlPlane .Spec .AvailabilityZones ,
285
- NetworkType : rosaScope .ControlPlane .Spec .Network .NetworkType ,
286
285
IsSTS : true ,
287
286
RoleARN : * rosaScope .ControlPlane .Spec .InstallerRoleARN ,
288
287
SupportRoleARN : * rosaScope .ControlPlane .Spec .SupportRoleARN ,
@@ -297,44 +296,48 @@ func (r *ROSAControlPlaneReconciler) reconcileNormal(ctx context.Context, rosaSc
297
296
AWSCreator : creator ,
298
297
}
299
298
300
- _ , machineCIDR , err := net .ParseCIDR (rosaScope .ControlPlane .Spec .Network .MachineCIDR )
301
- if err == nil {
302
- spec .MachineCIDR = * machineCIDR
303
- } else {
304
- // TODO: expose in status
305
- rosaScope .Error (err , "rosacontrolplane.spec.network.machineCIDR invalid" , rosaScope .ControlPlane .Spec .Network .MachineCIDR )
306
- return ctrl.Result {}, nil
307
- }
299
+ if networkSpec := rosaScope .ControlPlane .Spec .Network ; networkSpec != nil {
300
+ if networkSpec .MachineCIDR != "" {
301
+ _ , machineCIDR , err := net .ParseCIDR (networkSpec .MachineCIDR )
302
+ if err != nil {
303
+ // TODO: expose in status
304
+ rosaScope .Error (err , "rosacontrolplane.spec.network.machineCIDR invalid" , networkSpec .MachineCIDR )
305
+ return ctrl.Result {}, nil
306
+ }
307
+ ocmClusterSpec .MachineCIDR = * machineCIDR
308
+ }
308
309
309
- if rosaScope . ControlPlane . Spec . Network .PodCIDR != "" {
310
- _ , podCIDR , err := net .ParseCIDR (rosaScope . ControlPlane . Spec . Network .PodCIDR )
311
- if err = = nil {
312
- spec . PodCIDR = * podCIDR
313
- } else {
314
- // TODO: expose in status.
315
- rosaScope . Error ( err , "rosacontrolplane.spec.network.podCIDR invalid" , rosaScope . ControlPlane . Spec . Network . PodCIDR )
316
- return ctrl. Result {}, nil
310
+ if networkSpec .PodCIDR != "" {
311
+ _ , podCIDR , err := net .ParseCIDR (networkSpec .PodCIDR )
312
+ if err ! = nil {
313
+ // TODO: expose in status.
314
+ rosaScope . Error ( err , "rosacontrolplane.spec.network.podCIDR invalid" , networkSpec . PodCIDR )
315
+ return ctrl. Result {}, nil
316
+ }
317
+ ocmClusterSpec . PodCIDR = * podCIDR
317
318
}
318
- }
319
319
320
- if rosaScope . ControlPlane . Spec . Network .ServiceCIDR != "" {
321
- _ , serviceCIDR , err := net .ParseCIDR (rosaScope . ControlPlane . Spec . Network .ServiceCIDR )
322
- if err = = nil {
323
- spec . ServiceCIDR = * serviceCIDR
324
- } else {
325
- // TODO: expose in status.
326
- rosaScope . Error ( err , "rosacontrolplane.spec.network.serviceCIDR invalid" , rosaScope . ControlPlane . Spec . Network . ServiceCIDR )
327
- return ctrl. Result {}, nil
320
+ if networkSpec .ServiceCIDR != "" {
321
+ _ , serviceCIDR , err := net .ParseCIDR (networkSpec .ServiceCIDR )
322
+ if err ! = nil {
323
+ // TODO: expose in status.
324
+ rosaScope . Error ( err , "rosacontrolplane.spec.network.serviceCIDR invalid" , networkSpec . ServiceCIDR )
325
+ return ctrl. Result {}, nil
326
+ }
327
+ ocmClusterSpec . ServiceCIDR = * serviceCIDR
328
328
}
329
+
330
+ ocmClusterSpec .HostPrefix = networkSpec .HostPrefix
331
+ ocmClusterSpec .NetworkType = networkSpec .NetworkType
329
332
}
330
333
331
334
// Set autoscale replica
332
335
if rosaScope .ControlPlane .Spec .Autoscaling != nil {
333
- spec .MaxReplicas = rosaScope .ControlPlane .Spec .Autoscaling .MaxReplicas
334
- spec .MinReplicas = rosaScope .ControlPlane .Spec .Autoscaling .MinReplicas
336
+ ocmClusterSpec .MaxReplicas = rosaScope .ControlPlane .Spec .Autoscaling .MaxReplicas
337
+ ocmClusterSpec .MinReplicas = rosaScope .ControlPlane .Spec .Autoscaling .MinReplicas
335
338
}
336
339
337
- cluster , err = ocmClient .CreateCluster (spec )
340
+ cluster , err = ocmClient .CreateCluster (ocmClusterSpec )
338
341
if err != nil {
339
342
// TODO: need to expose in status, as likely the spec is invalid
340
343
return ctrl.Result {}, fmt .Errorf ("failed to create OCM cluster: %w" , err )
0 commit comments