@@ -229,34 +229,15 @@ func (r *LinodeClusterReconciler) performPreflightChecks(ctx context.Context, lo
229229 // The condition is already set in reconcilePreflightLinodeVPCCheck, so we don't need to set it again
230230 return res , err
231231 }
232-
233- // Only set to true if there was no error
234- conditions .Set (clusterScope .LinodeCluster , metav1.Condition {
235- Type : ConditionPreflightLinodeVPCReady ,
236- Status : metav1 .ConditionTrue ,
237- Reason : "LinodeVPCReady" , // We have to set the reason to not fail object patching
238- })
239232 }
240233 }
241234
242235 if clusterScope .LinodeCluster .Spec .NodeBalancerFirewallRef != nil {
243236 if ! reconciler .ConditionTrue (clusterScope .LinodeCluster , ConditionPreflightLinodeNBFirewallReady ) {
244237 res , err := r .reconcilePreflightLinodeFirewallCheck (ctx , logger , clusterScope )
245238 if err != nil || ! res .IsZero () {
246- conditions .Set (clusterScope .LinodeCluster , metav1.Condition {
247- Type : ConditionPreflightLinodeNBFirewallReady ,
248- Status : metav1 .ConditionFalse ,
249- Reason : "LinodeFirewallNotYetAvailable" , // We have to set the reason to not fail object patching
250- })
251239 return res , err
252240 }
253-
254- // Only set to true if there was no error
255- conditions .Set (clusterScope .LinodeCluster , metav1.Condition {
256- Type : ConditionPreflightLinodeNBFirewallReady ,
257- Status : metav1 .ConditionTrue ,
258- Reason : "LinodeFirewallReady" , // We have to set the reason to not fail object patching
259- })
260241 }
261242 }
262243
@@ -289,17 +270,37 @@ func (r *LinodeClusterReconciler) reconcilePreflightLinodeFirewallCheck(ctx cont
289270 Reason : util .CreateError ,
290271 Message : err .Error (),
291272 })
273+
292274 return ctrl.Result {}, err
293275 }
276+ conditions .Set (clusterScope .LinodeCluster , metav1.Condition {
277+ Type : ConditionPreflightLinodeNBFirewallReady ,
278+ Status : metav1 .ConditionFalse ,
279+ Reason : "LinodeFirewallNotYetAvailable" , // We have to set the reason to not fail object patching
280+ })
281+
294282 return ctrl.Result {RequeueAfter : reconciler .DefaultClusterControllerReconcileDelay }, nil
295283 }
296284 if linodeFirewall .Spec .FirewallID == nil {
297285 logger .Info ("Linode firewall not yet available" )
286+ conditions .Set (clusterScope .LinodeCluster , metav1.Condition {
287+ Type : ConditionPreflightLinodeNBFirewallReady ,
288+ Status : metav1 .ConditionFalse ,
289+ Reason : "LinodeFirewallNotYetAvailable" , // We have to set the reason to not fail object patching
290+ })
291+
298292 return ctrl.Result {RequeueAfter : reconciler .DefaultClusterControllerReconcileDelay }, nil
299293 }
300294
301295 r .Recorder .Event (clusterScope .LinodeCluster , corev1 .EventTypeNormal , string (clusterv1 .ReadyCondition ), "Linode firewall is now available" )
302296
297+ // Only set to true if there was no error
298+ conditions .Set (clusterScope .LinodeCluster , metav1.Condition {
299+ Type : ConditionPreflightLinodeNBFirewallReady ,
300+ Status : metav1 .ConditionTrue ,
301+ Reason : "LinodeFirewallReady" , // We have to set the reason to not fail object patching
302+ })
303+
303304 return ctrl.Result {}, nil
304305}
305306
@@ -316,7 +317,7 @@ func (r *LinodeClusterReconciler) reconcilePreflightLinodeVPCCheck(ctx context.C
316317 Reason : util .CreateError ,
317318 Message : fmt .Sprintf ("VPC with ID %d not found: %v" , vpcID , err ),
318319 })
319- return ctrl.Result {RequeueAfter : reconciler .DefaultClusterControllerReconcileDelay }, err
320+ return ctrl.Result {RequeueAfter : reconciler .DefaultClusterControllerReconcileDelay }, nil
320321 }
321322 // VPC exists, verify it has at least one subnet
322323 if len (vpc .Subnets ) == 0 {
@@ -328,9 +329,17 @@ func (r *LinodeClusterReconciler) reconcilePreflightLinodeVPCCheck(ctx context.C
328329 Reason : util .CreateError ,
329330 Message : err .Error (),
330331 })
331- return ctrl.Result {RequeueAfter : reconciler .DefaultClusterControllerReconcileDelay }, err
332+ return ctrl.Result {RequeueAfter : reconciler .DefaultClusterControllerReconcileDelay }, nil
332333 }
333334 r .Recorder .Event (clusterScope .LinodeCluster , corev1 .EventTypeNormal , string (clusterv1 .ReadyCondition ), fmt .Sprintf ("VPC with ID %d is available" , vpcID ))
335+
336+ // Only set to true if there was no error
337+ conditions .Set (clusterScope .LinodeCluster , metav1.Condition {
338+ Type : ConditionPreflightLinodeVPCReady ,
339+ Status : metav1 .ConditionTrue ,
340+ Reason : "LinodeVPCReady" , // We have to set the reason to not fail object patching
341+ })
342+
334343 return ctrl.Result {}, nil
335344 }
336345
@@ -359,12 +368,29 @@ func (r *LinodeClusterReconciler) reconcilePreflightLinodeVPCCheck(ctx context.C
359368 })
360369 return ctrl.Result {}, err
361370 }
371+ conditions .Set (clusterScope .LinodeCluster , metav1.Condition {
372+ Type : ConditionPreflightLinodeVPCReady ,
373+ Status : metav1 .ConditionFalse ,
374+ Reason : "LinodeVPCNotYetAvailable" , // We have to set the reason to not fail object patching
375+ })
362376 return ctrl.Result {RequeueAfter : reconciler .DefaultClusterControllerReconcileDelay }, nil
363377 } else if ! linodeVPC .Status .Ready {
364378 logger .Info ("LinodeVPC is not yet available" )
379+ conditions .Set (clusterScope .LinodeCluster , metav1.Condition {
380+ Type : ConditionPreflightLinodeVPCReady ,
381+ Status : metav1 .ConditionFalse ,
382+ Reason : "LinodeVPCNotYetAvailable" , // We have to set the reason to not fail object patching
383+ })
365384 return ctrl.Result {RequeueAfter : reconciler .DefaultClusterControllerReconcileDelay }, nil
366385 }
367386 r .Recorder .Event (clusterScope .LinodeCluster , corev1 .EventTypeNormal , string (clusterv1 .ReadyCondition ), "LinodeVPC is now available" )
387+
388+ // Only set to true if there was no error
389+ conditions .Set (clusterScope .LinodeCluster , metav1.Condition {
390+ Type : ConditionPreflightLinodeVPCReady ,
391+ Status : metav1 .ConditionTrue ,
392+ Reason : "LinodeVPCReady" , // We have to set the reason to not fail object patching
393+ })
368394 return ctrl.Result {}, nil
369395}
370396
0 commit comments