@@ -98,6 +98,19 @@ func (r *IBMPowerVSImageReconciler) Reconcile(ctx context.Context, req ctrl.Requ
9898 scopeParams .Zone = cluster .Spec .Zone
9999 }
100100
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+
101114 // Initialize the patch helper
102115 patchHelper , err := v1beta1patch .NewHelper (ibmPowerVSImage , r .Client )
103116 if err != nil {
@@ -111,19 +124,6 @@ func (r *IBMPowerVSImageReconciler) Reconcile(ctx context.Context, req ctrl.Requ
111124 }
112125 }()
113126
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-
127127 // Handle deleted clusters.
128128 if ! ibmPowerVSImage .DeletionTimestamp .IsZero () {
129129 return r .reconcileDelete (ctx , imageScope )
@@ -311,7 +311,6 @@ func (r *IBMPowerVSImageReconciler) reconcileDelete(ctx context.Context, scope *
311311
312312 if scope .IBMPowerVSImage .Spec .DeletePolicy != string (infrav1 .DeletePolicyRetain ) {
313313 if err := scope .DeleteImage (); err != nil {
314- log .Error (err , "Error deleting IBMPowerVSImage" )
315314 v1beta1conditions .MarkFalse (scope .IBMPowerVSImage , infrav1 .ImageReadyCondition , clusterv1beta1 .DeletionFailedReason , clusterv1beta1 .ConditionSeverityWarning , "" )
316315 v1beta2conditions .Set (scope .IBMPowerVSImage , metav1.Condition {
317316 Type : infrav1 .IBMPowerVSImageReadyV1Beta2Condition ,
0 commit comments