@@ -98,6 +98,19 @@ func (r *IBMPowerVSImageReconciler) Reconcile(ctx context.Context, req ctrl.Requ
98
98
scopeParams .Zone = cluster .Spec .Zone
99
99
}
100
100
101
+ // Create the scope
102
+ imageScope , err := scope .NewPowerVSImageScope (ctx , scopeParams )
103
+ if err != nil {
104
+ if errors .Is (err , scope .ErrServiceInsanceNotInActiveState ) {
105
+ v1beta2conditions .Set (imageScope .IBMPowerVSImage , metav1.Condition {
106
+ Type : infrav1 .WorkspaceReadyV1Beta2Condition ,
107
+ Status : metav1 .ConditionFalse ,
108
+ Reason : infrav1 .WorkspaceNotReadyV1Beta2Reason ,
109
+ })
110
+ }
111
+ return ctrl.Result {}, fmt .Errorf ("failed to create scope: %w" , err )
112
+ }
113
+
101
114
// Initialize the patch helper
102
115
patchHelper , err := v1beta1patch .NewHelper (ibmPowerVSImage , r .Client )
103
116
if err != nil {
@@ -111,19 +124,6 @@ func (r *IBMPowerVSImageReconciler) Reconcile(ctx context.Context, req ctrl.Requ
111
124
}
112
125
}()
113
126
114
- // Create the scope
115
- imageScope , err := scope .NewPowerVSImageScope (ctx , scopeParams )
116
- if err != nil {
117
- if err == errors .New ("service instance is not in active state" ) {
118
- v1beta2conditions .Set (imageScope .IBMPowerVSImage , metav1.Condition {
119
- Type : infrav1 .WorkspaceReadyV1Beta2Condition ,
120
- Status : metav1 .ConditionFalse ,
121
- Reason : infrav1 .WorkspaceNotReadyV1Beta2Reason ,
122
- })
123
- }
124
- return ctrl.Result {}, fmt .Errorf ("failed to create scope: %w" , err )
125
- }
126
-
127
127
// Handle deleted clusters.
128
128
if ! ibmPowerVSImage .DeletionTimestamp .IsZero () {
129
129
return r .reconcileDelete (ctx , imageScope )
@@ -311,7 +311,6 @@ func (r *IBMPowerVSImageReconciler) reconcileDelete(ctx context.Context, scope *
311
311
312
312
if scope .IBMPowerVSImage .Spec .DeletePolicy != string (infrav1 .DeletePolicyRetain ) {
313
313
if err := scope .DeleteImage (); err != nil {
314
- log .Error (err , "Error deleting IBMPowerVSImage" )
315
314
v1beta1conditions .MarkFalse (scope .IBMPowerVSImage , infrav1 .ImageReadyCondition , clusterv1beta1 .DeletionFailedReason , clusterv1beta1 .ConditionSeverityWarning , "" )
316
315
v1beta2conditions .Set (scope .IBMPowerVSImage , metav1.Condition {
317
316
Type : infrav1 .IBMPowerVSImageReadyV1Beta2Condition ,
0 commit comments