@@ -128,15 +128,10 @@ type reconcileResult struct {
128128 error
129129}
130130
131- func (update * powerVSCluster ) updateCondition (condition bool , conditionArgs ... interface {} ) {
131+ func (update * powerVSCluster ) updateCondition (condition capiv1beta1. Condition ) {
132132 update .mu .Lock ()
133133 defer update .mu .Unlock ()
134- if condition {
135- conditions .MarkTrue (update .cluster , conditionArgs [0 ].(capiv1beta1.ConditionType ))
136- return
137- }
138-
139- conditions .MarkFalse (update .cluster , conditionArgs [0 ].(capiv1beta1.ConditionType ), conditionArgs [1 ].(string ), conditionArgs [2 ].(capiv1beta1.ConditionSeverity ), conditionArgs [3 ].(string ), conditionArgs [4 :]... )
134+ conditions .Set (update .cluster , & condition )
140135}
141136
142137func (r * IBMPowerVSClusterReconciler ) reconcilePowerVSResources (clusterScope * scope.PowerVSClusterScope , powerVSCluster * powerVSCluster , ch chan reconcileResult , wg * sync.WaitGroup ) {
@@ -146,27 +141,45 @@ func (r *IBMPowerVSClusterReconciler) reconcilePowerVSResources(clusterScope *sc
146141 powerVSLog .Info ("Reconciling PowerVS service instance" )
147142 if requeue , err := clusterScope .ReconcilePowerVSServiceInstance (); err != nil {
148143 powerVSLog .Error (err , "failed to reconcile PowerVS service instance" )
149- powerVSCluster .updateCondition (false , infrav1beta2 .ServiceInstanceReadyCondition , infrav1beta2 .ServiceInstanceReconciliationFailedReason , capiv1beta1 .ConditionSeverityError , err .Error ())
144+ powerVSCluster .updateCondition (capiv1beta1.Condition {
145+ Status : corev1 .ConditionFalse ,
146+ Type : infrav1beta2 .ServiceInstanceReadyCondition ,
147+ Reason : infrav1beta2 .ServiceInstanceReconciliationFailedReason ,
148+ Severity : capiv1beta1 .ConditionSeverityError ,
149+ Message : err .Error (),
150+ })
150151 ch <- reconcileResult {reconcile.Result {}, err }
151152 return
152153 } else if requeue {
153154 powerVSLog .Info ("PowerVS service instance creation is pending, requeuing" )
154155 ch <- reconcileResult {reconcile.Result {Requeue : true }, nil }
155156 return
156157 }
157- powerVSCluster .updateCondition (true , infrav1beta2 .ServiceInstanceReadyCondition )
158+ powerVSCluster .updateCondition (capiv1beta1.Condition {
159+ Status : corev1 .ConditionTrue ,
160+ Type : infrav1beta2 .ServiceInstanceReadyCondition ,
161+ })
158162
159163 clusterScope .IBMPowerVSClient .WithClients (powervs.ServiceOptions {CloudInstanceID : clusterScope .GetServiceInstanceID ()})
160164
161165 // reconcile network
162166 powerVSLog .Info ("Reconciling network" )
163167 if networkActive , err := clusterScope .ReconcileNetwork (); err != nil {
164168 powerVSLog .Error (err , "failed to reconcile PowerVS network" )
165- powerVSCluster .updateCondition (false , infrav1beta2 .NetworkReadyCondition , infrav1beta2 .NetworkReconciliationFailedReason , capiv1beta1 .ConditionSeverityError , err .Error ())
169+ powerVSCluster .updateCondition (capiv1beta1.Condition {
170+ Status : corev1 .ConditionFalse ,
171+ Type : infrav1beta2 .NetworkReadyCondition ,
172+ Reason : infrav1beta2 .NetworkReconciliationFailedReason ,
173+ Severity : capiv1beta1 .ConditionSeverityError ,
174+ Message : err .Error (),
175+ })
166176 ch <- reconcileResult {reconcile.Result {}, err }
167177 return
168178 } else if networkActive {
169- powerVSCluster .updateCondition (true , infrav1beta2 .NetworkReadyCondition )
179+ powerVSCluster .updateCondition (capiv1beta1.Condition {
180+ Status : corev1 .ConditionTrue ,
181+ Type : infrav1beta2 .NetworkReadyCondition ,
182+ })
170183 return
171184 }
172185 // Do not want to block the reconciliation of other resources like setting up TG and COS, so skipping the requeue and only logging the info.
@@ -179,49 +192,85 @@ func (r *IBMPowerVSClusterReconciler) reconcileVPCResources(clusterScope *scope.
179192 vpcLog .Info ("Reconciling VPC" )
180193 if requeue , err := clusterScope .ReconcileVPC (); err != nil {
181194 clusterScope .Error (err , "failed to reconcile VPC" )
182- powerVSCluster .updateCondition (false , infrav1beta2 .VPCReadyCondition , infrav1beta2 .VPCReconciliationFailedReason , capiv1beta1 .ConditionSeverityError , err .Error ())
195+ powerVSCluster .updateCondition (capiv1beta1.Condition {
196+ Status : corev1 .ConditionFalse ,
197+ Type : infrav1beta2 .VPCReadyCondition ,
198+ Reason : infrav1beta2 .VPCReconciliationFailedReason ,
199+ Severity : capiv1beta1 .ConditionSeverityError ,
200+ Message : err .Error (),
201+ })
183202 ch <- reconcileResult {reconcile.Result {}, err }
184203 return
185204 } else if requeue {
186205 vpcLog .Info ("VPC creation is pending, requeuing" )
187206 ch <- reconcileResult {reconcile.Result {Requeue : true }, nil }
188207 return
189208 }
190- powerVSCluster .updateCondition (true , infrav1beta2 .VPCReadyCondition )
209+ powerVSCluster .updateCondition (capiv1beta1.Condition {
210+ Status : corev1 .ConditionTrue ,
211+ Type : infrav1beta2 .VPCReadyCondition ,
212+ })
191213
192214 // reconcile VPC Subnet
193215 vpcLog .Info ("Reconciling VPC subnets" )
194216 if requeue , err := clusterScope .ReconcileVPCSubnets (); err != nil {
195217 vpcLog .Error (err , "failed to reconcile VPC subnets" )
196- powerVSCluster .updateCondition (false , infrav1beta2 .VPCSubnetReadyCondition , infrav1beta2 .VPCSubnetReconciliationFailedReason , capiv1beta1 .ConditionSeverityError , err .Error ())
218+ powerVSCluster .updateCondition (capiv1beta1.Condition {
219+ Status : corev1 .ConditionFalse ,
220+ Type : infrav1beta2 .VPCSubnetReadyCondition ,
221+ Reason : infrav1beta2 .VPCSubnetReconciliationFailedReason ,
222+ Severity : capiv1beta1 .ConditionSeverityError ,
223+ Message : err .Error (),
224+ })
197225 ch <- reconcileResult {reconcile.Result {}, err }
198226 return
199227 } else if requeue {
200228 vpcLog .Info ("VPC subnet creation is pending, requeuing" )
201229 ch <- reconcileResult {reconcile.Result {Requeue : true }, nil }
202230 return
203231 }
204- powerVSCluster .updateCondition (true , infrav1beta2 .VPCSubnetReadyCondition )
232+ powerVSCluster .updateCondition (capiv1beta1.Condition {
233+ Status : corev1 .ConditionTrue ,
234+ Type : infrav1beta2 .VPCSubnetReadyCondition ,
235+ })
205236
206237 // reconcile VPC security group
207238 vpcLog .Info ("Reconciling VPC security group" )
208239 if err := clusterScope .ReconcileVPCSecurityGroups (); err != nil {
209240 vpcLog .Error (err , "failed to reconcile VPC security groups" )
210- powerVSCluster .updateCondition (false , infrav1beta2 .VPCSecurityGroupReadyCondition , infrav1beta2 .VPCSecurityGroupReconciliationFailedReason , capiv1beta1 .ConditionSeverityError , err .Error ())
241+ powerVSCluster .updateCondition (capiv1beta1.Condition {
242+ Status : corev1 .ConditionFalse ,
243+ Type : infrav1beta2 .VPCSecurityGroupReadyCondition ,
244+ Reason : infrav1beta2 .VPCSecurityGroupReconciliationFailedReason ,
245+ Severity : capiv1beta1 .ConditionSeverityError ,
246+ Message : err .Error (),
247+ })
211248 ch <- reconcileResult {reconcile.Result {}, err }
212249 return
213250 }
214- powerVSCluster .updateCondition (true , infrav1beta2 .VPCSecurityGroupReadyCondition )
251+ powerVSCluster .updateCondition (capiv1beta1.Condition {
252+ Status : corev1 .ConditionTrue ,
253+ Type : infrav1beta2 .VPCSecurityGroupReadyCondition ,
254+ })
215255
216256 // reconcile LoadBalancer
217257 vpcLog .Info ("Reconciling VPC load balancers" )
218258 if loadBalancerReady , err := clusterScope .ReconcileLoadBalancers (); err != nil {
219259 vpcLog .Error (err , "failed to reconcile VPC load balancers" )
220- powerVSCluster .updateCondition (false , infrav1beta2 .LoadBalancerReadyCondition , infrav1beta2 .LoadBalancerReconciliationFailedReason , capiv1beta1 .ConditionSeverityError , err .Error ())
260+ powerVSCluster .updateCondition (capiv1beta1.Condition {
261+ Status : corev1 .ConditionFalse ,
262+ Type : infrav1beta2 .LoadBalancerReadyCondition ,
263+ Reason : infrav1beta2 .LoadBalancerReconciliationFailedReason ,
264+ Severity : capiv1beta1 .ConditionSeverityError ,
265+ Message : err .Error (),
266+ })
221267 ch <- reconcileResult {reconcile.Result {}, err }
222268 return
223269 } else if loadBalancerReady {
224- powerVSCluster .updateCondition (true , infrav1beta2 .LoadBalancerReadyCondition )
270+ powerVSCluster .updateCondition (capiv1beta1.Condition {
271+ Status : corev1 .ConditionTrue ,
272+ Type : infrav1beta2 .LoadBalancerReadyCondition ,
273+ })
225274 return
226275 }
227276 // Do not want to block the reconciliation of other resources like setting up TG and COS, so skipping the requeue and only logging the info.
0 commit comments