@@ -128,15 +128,10 @@ type reconcileResult struct {
128
128
error
129
129
}
130
130
131
- func (update * powerVSCluster ) updateCondition (condition bool , conditionArgs ... interface {} ) {
131
+ func (update * powerVSCluster ) updateCondition (condition capiv1beta1. Condition ) {
132
132
update .mu .Lock ()
133
133
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 )
140
135
}
141
136
142
137
func (r * IBMPowerVSClusterReconciler ) reconcilePowerVSResources (clusterScope * scope.PowerVSClusterScope , powerVSCluster * powerVSCluster , ch chan reconcileResult , wg * sync.WaitGroup ) {
@@ -146,27 +141,45 @@ func (r *IBMPowerVSClusterReconciler) reconcilePowerVSResources(clusterScope *sc
146
141
powerVSLog .Info ("Reconciling PowerVS service instance" )
147
142
if requeue , err := clusterScope .ReconcilePowerVSServiceInstance (); err != nil {
148
143
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
+ })
150
151
ch <- reconcileResult {reconcile.Result {}, err }
151
152
return
152
153
} else if requeue {
153
154
powerVSLog .Info ("PowerVS service instance creation is pending, requeuing" )
154
155
ch <- reconcileResult {reconcile.Result {Requeue : true }, nil }
155
156
return
156
157
}
157
- powerVSCluster .updateCondition (true , infrav1beta2 .ServiceInstanceReadyCondition )
158
+ powerVSCluster .updateCondition (capiv1beta1.Condition {
159
+ Status : corev1 .ConditionTrue ,
160
+ Type : infrav1beta2 .ServiceInstanceReadyCondition ,
161
+ })
158
162
159
163
clusterScope .IBMPowerVSClient .WithClients (powervs.ServiceOptions {CloudInstanceID : clusterScope .GetServiceInstanceID ()})
160
164
161
165
// reconcile network
162
166
powerVSLog .Info ("Reconciling network" )
163
167
if networkActive , err := clusterScope .ReconcileNetwork (); err != nil {
164
168
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
+ })
166
176
ch <- reconcileResult {reconcile.Result {}, err }
167
177
return
168
178
} else if networkActive {
169
- powerVSCluster .updateCondition (true , infrav1beta2 .NetworkReadyCondition )
179
+ powerVSCluster .updateCondition (capiv1beta1.Condition {
180
+ Status : corev1 .ConditionTrue ,
181
+ Type : infrav1beta2 .NetworkReadyCondition ,
182
+ })
170
183
return
171
184
}
172
185
// 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.
179
192
vpcLog .Info ("Reconciling VPC" )
180
193
if requeue , err := clusterScope .ReconcileVPC (); err != nil {
181
194
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
+ })
183
202
ch <- reconcileResult {reconcile.Result {}, err }
184
203
return
185
204
} else if requeue {
186
205
vpcLog .Info ("VPC creation is pending, requeuing" )
187
206
ch <- reconcileResult {reconcile.Result {Requeue : true }, nil }
188
207
return
189
208
}
190
- powerVSCluster .updateCondition (true , infrav1beta2 .VPCReadyCondition )
209
+ powerVSCluster .updateCondition (capiv1beta1.Condition {
210
+ Status : corev1 .ConditionTrue ,
211
+ Type : infrav1beta2 .VPCReadyCondition ,
212
+ })
191
213
192
214
// reconcile VPC Subnet
193
215
vpcLog .Info ("Reconciling VPC subnets" )
194
216
if requeue , err := clusterScope .ReconcileVPCSubnets (); err != nil {
195
217
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
+ })
197
225
ch <- reconcileResult {reconcile.Result {}, err }
198
226
return
199
227
} else if requeue {
200
228
vpcLog .Info ("VPC subnet creation is pending, requeuing" )
201
229
ch <- reconcileResult {reconcile.Result {Requeue : true }, nil }
202
230
return
203
231
}
204
- powerVSCluster .updateCondition (true , infrav1beta2 .VPCSubnetReadyCondition )
232
+ powerVSCluster .updateCondition (capiv1beta1.Condition {
233
+ Status : corev1 .ConditionTrue ,
234
+ Type : infrav1beta2 .VPCSubnetReadyCondition ,
235
+ })
205
236
206
237
// reconcile VPC security group
207
238
vpcLog .Info ("Reconciling VPC security group" )
208
239
if err := clusterScope .ReconcileVPCSecurityGroups (); err != nil {
209
240
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
+ })
211
248
ch <- reconcileResult {reconcile.Result {}, err }
212
249
return
213
250
}
214
- powerVSCluster .updateCondition (true , infrav1beta2 .VPCSecurityGroupReadyCondition )
251
+ powerVSCluster .updateCondition (capiv1beta1.Condition {
252
+ Status : corev1 .ConditionTrue ,
253
+ Type : infrav1beta2 .VPCSecurityGroupReadyCondition ,
254
+ })
215
255
216
256
// reconcile LoadBalancer
217
257
vpcLog .Info ("Reconciling VPC load balancers" )
218
258
if loadBalancerReady , err := clusterScope .ReconcileLoadBalancers (); err != nil {
219
259
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
+ })
221
267
ch <- reconcileResult {reconcile.Result {}, err }
222
268
return
223
269
} else if loadBalancerReady {
224
- powerVSCluster .updateCondition (true , infrav1beta2 .LoadBalancerReadyCondition )
270
+ powerVSCluster .updateCondition (capiv1beta1.Condition {
271
+ Status : corev1 .ConditionTrue ,
272
+ Type : infrav1beta2 .LoadBalancerReadyCondition ,
273
+ })
225
274
return
226
275
}
227
276
// 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