Skip to content

Commit d6f1795

Browse files
committed
update conditions during patch
1 parent b1a1e37 commit d6f1795

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

api/v1beta2/conditions_consts.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -362,9 +362,12 @@ const (
362362

363363
// IBMPowerVSImage's Ready condition and corresponding reasons that will be used in v1Beta2 API version.
364364
const (
365-
// IBMPowerVSImageReadyV1Beta2Condition is true if the IBMPowerVSImage's deletionTimestamp is not set, IBMPowerVSImage's
366-
// FailureDomainsReady, VCenterAvailable and ClusterModulesReady conditions are true.
367-
IBMPowerVSImageReadyV1Beta2Condition = clusterv1beta1.ReadyV1Beta2Condition
365+
// IBMPowerVSImageReadyCondition is true if the IBMPowerVSImage's deletionTimestamp is not set, IBMPowerVSImage's
366+
IBMPowerVSImageReadyCondition = clusterv1beta1.ReadyV1Beta2Condition
367+
368+
// IBMPowerVSImageReadyV1Beta2Condition documents the status of the image that is controlled
369+
// by the IBMPowerVSImage.
370+
IBMPowerVSImageReadyV1Beta2Condition = "ImageReady"
368371

369372
// IBMPowerVSImageReadyV1Beta2Reason surfaces when the IBMPowerVSImage readiness criteria is met.
370373
IBMPowerVSImageReadyV1Beta2Reason = clusterv1beta1.ReadyV1Beta2Reason

controllers/ibmpowervsimage_controller.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ func (r *IBMPowerVSImageReconciler) Reconcile(ctx context.Context, req ctrl.Requ
8484
var cluster *infrav1.IBMPowerVSCluster
8585
scopeParams := scope.PowerVSImageScopeParams{
8686
Client: r.Client,
87-
Logger: log,
8887
IBMPowerVSImage: ibmPowerVSImage,
8988
ServiceEndpoint: r.ServiceEndpoint,
9089
}
@@ -99,7 +98,7 @@ func (r *IBMPowerVSImageReconciler) Reconcile(ctx context.Context, req ctrl.Requ
9998
}
10099

101100
// Create the scope
102-
imageScope, err := scope.NewPowerVSImageScope(scopeParams)
101+
imageScope, err := scope.NewPowerVSImageScope(ctx, scopeParams)
103102
if err != nil {
104103
return ctrl.Result{}, fmt.Errorf("failed to create scope: %w", err)
105104
}
@@ -240,7 +239,7 @@ func reconcileImage(ctx context.Context, img *models.ImageReference, imageScope
240239
v1beta1conditions.MarkTrue(imageScope.IBMPowerVSImage, infrav1.ImageReadyCondition)
241240
v1beta2conditions.Set(imageScope.IBMPowerVSImage, metav1.Condition{
242241
Type: infrav1.IBMPowerVSImageReadyV1Beta2Condition,
243-
Status: metav1.ConditionFalse,
242+
Status: metav1.ConditionTrue,
244243
Reason: infrav1.IBMPowerVSImageReadyV1Beta2Reason,
245244
})
246245

@@ -329,7 +328,7 @@ func (r *IBMPowerVSImageReconciler) SetupWithManager(mgr ctrl.Manager) error {
329328
}
330329

331330
func patchIBMPowerVSImage(ctx context.Context, patchHelper *v1beta1patch.Helper, ibmPowerVSImage *infrav1.IBMPowerVSImage) error {
332-
// Before computing ready condition, make sure that InstanceReady is always set.
331+
// Before computing ready condition, make sure that ImageReady is always set.
333332
// NOTE: This is required because v1beta2 conditions comply to guideline requiring conditions to be set at the
334333
// first reconcile.
335334
if c := v1beta2conditions.Get(ibmPowerVSImage, infrav1.IBMPowerVSImageReadyV1Beta2Condition); c == nil {
@@ -351,13 +350,13 @@ func patchIBMPowerVSImage(ctx context.Context, patchHelper *v1beta1patch.Helper,
351350
// always update the readyCondition.
352351
v1beta1conditions.SetSummary(ibmPowerVSImage,
353352
v1beta1conditions.WithConditions(
354-
infrav1.InstanceReadyCondition,
353+
infrav1.ImageReadyCondition,
355354
),
356355
)
357356

358-
if err := v1beta2conditions.SetSummaryCondition(ibmPowerVSImage, ibmPowerVSImage, infrav1.IBMPowerVSImageReadyV1Beta2Condition,
357+
if err := v1beta2conditions.SetSummaryCondition(ibmPowerVSImage, ibmPowerVSImage, infrav1.IBMPowerVSImageReadyCondition,
359358
v1beta2conditions.ForConditionTypes{
360-
infrav1.IBMPowerVSMachineInstanceReadyV1Beta2Condition,
359+
infrav1.IBMPowerVSImageReadyV1Beta2Condition,
361360
},
362361
// Using a custom merge strategy to override reasons applied during merge.
363362
v1beta2conditions.CustomMergeStrategy{
@@ -371,13 +370,13 @@ func patchIBMPowerVSImage(ctx context.Context, patchHelper *v1beta1patch.Helper,
371370
),
372371
},
373372
); err != nil {
374-
return fmt.Errorf("failed to set %s condition: %w", infrav1.IBMPowerVSImageReadyV1Beta2Condition, err)
373+
return fmt.Errorf("failed to set %s condition: %w", infrav1.IBMPowerVSImageReadyCondition, err)
375374
}
376375

377376
// Patch the IBMPowerVSImage resource.
378377
return patchHelper.Patch(ctx, ibmPowerVSImage, v1beta1patch.WithOwnedV1Beta2Conditions{Conditions: []string{
378+
infrav1.IBMPowerVSImageReadyCondition,
379379
infrav1.IBMPowerVSImageReadyV1Beta2Condition,
380-
infrav1.IBMPowerVSMachineInstanceReadyV1Beta2Condition,
381380
clusterv1beta1.PausedV1Beta2Condition,
382381
}})
383382
}

0 commit comments

Comments
 (0)