@@ -196,13 +196,13 @@ func (r *ServiceBindingReconciler) Reconcile(ctx context.Context, req ctrl.Reque
196196
197197 smClient , err := r .GetSMClient (ctx , serviceInstance )
198198 if err != nil {
199- return utils .MarkAsTransientError (ctx , r .Client , common .Unknown , err , serviceBinding )
199+ return utils .HandleOperationFailure (ctx , r .Client , serviceBinding , common .Unknown , err )
200200 }
201201
202202 smBinding , err := r .getBindingForRecovery (ctx , smClient , serviceBinding )
203203 if err != nil {
204204 log .Error (err , "failed to check binding recovery" )
205- return utils .MarkAsTransientError (ctx , r .Client , smClientTypes .CREATE , err , serviceBinding )
205+ return utils .HandleServiceManagerError (ctx , r .Client , serviceBinding , smClientTypes .CREATE , err )
206206 }
207207 if smBinding != nil {
208208 return r .recover (ctx , serviceBinding , smBinding )
@@ -230,7 +230,7 @@ func (r *ServiceBindingReconciler) createBinding(ctx context.Context, smClient s
230230 bindingParameters , _ , err := utils .BuildSMRequestParameters (serviceBinding .Namespace , serviceBinding .Spec .Parameters , serviceBinding .Spec .ParametersFrom )
231231 if err != nil {
232232 log .Error (err , "failed to parse smBinding parameters" )
233- return utils .MarkAsNonTransientError (ctx , r .Client , smClientTypes .CREATE , err , serviceBinding )
233+ return utils .HandleOperationFailure (ctx , r .Client , serviceBinding , smClientTypes .CREATE , err )
234234 }
235235
236236 smBinding , operationURL , bindErr := smClient .Bind (& smClientTypes.ServiceBinding {
@@ -246,13 +246,13 @@ func (r *ServiceBindingReconciler) createBinding(ctx context.Context, smClient s
246246
247247 if bindErr != nil {
248248 log .Error (err , "failed to create service binding" , "serviceInstanceID" , serviceInstance .Status .InstanceID )
249- return utils .HandleError (ctx , r .Client , smClientTypes .CREATE , bindErr , serviceBinding )
249+ return utils .HandleServiceManagerError (ctx , r .Client , serviceBinding , smClientTypes .CREATE , bindErr )
250250 }
251251
252252 if operationURL != "" {
253253 var bindingID string
254254 if bindingID = sm .ExtractBindingID (operationURL ); len (bindingID ) == 0 {
255- return utils .MarkAsNonTransientError (ctx , r .Client , smClientTypes .CREATE , fmt .Errorf ("failed to extract smBinding ID from operation URL %s" , operationURL ), serviceBinding )
255+ return utils .HandleOperationFailure (ctx , r .Client , serviceBinding , smClientTypes .CREATE , fmt .Errorf ("failed to extract smBinding ID from operation URL %s" , operationURL ))
256256 }
257257 serviceBinding .Status .BindingID = bindingID
258258
@@ -264,7 +264,7 @@ func (r *ServiceBindingReconciler) createBinding(ctx context.Context, smClient s
264264 log .Error (err , "unable to update ServiceBinding status" )
265265 return ctrl.Result {}, err
266266 }
267- return ctrl.Result {Requeue : true , RequeueAfter : r .Config .PollInterval }, nil
267+ return ctrl.Result {RequeueAfter : r .Config .PollInterval }, nil
268268 }
269269
270270 log .Info ("Binding created successfully" )
@@ -292,14 +292,14 @@ func (r *ServiceBindingReconciler) delete(ctx context.Context, serviceBinding *v
292292 if controllerutil .ContainsFinalizer (serviceBinding , common .FinalizerName ) {
293293 smClient , err := r .GetSMClient (ctx , serviceInstance )
294294 if err != nil {
295- return utils .MarkAsTransientError (ctx , r .Client , common . Unknown , err , serviceBinding )
295+ return utils .HandleOperationFailure (ctx , r .Client , serviceBinding , smClientTypes . DELETE , err )
296296 }
297297
298298 if len (serviceBinding .Status .BindingID ) == 0 {
299299 log .Info ("No binding id found validating binding does not exists in SM before removing finalizer" )
300300 smBinding , err := r .getBindingForRecovery (ctx , smClient , serviceBinding )
301301 if err != nil {
302- return ctrl. Result {}, err
302+ return utils . HandleServiceManagerError ( ctx , r . Client , serviceBinding , smClientTypes . DELETE , err )
303303 }
304304 if smBinding != nil {
305305 log .Info ("binding exists in SM continue with deletion" )
@@ -328,7 +328,7 @@ func (r *ServiceBindingReconciler) delete(ctx context.Context, serviceBinding *v
328328 log .Info (fmt .Sprintf ("Deleting binding with id %v from SM" , serviceBinding .Status .BindingID ))
329329 operationURL , unbindErr := smClient .Unbind (serviceBinding .Status .BindingID , nil , utils .BuildUserInfo (ctx , serviceBinding .Spec .UserInfo ))
330330 if unbindErr != nil {
331- return utils .HandleDeleteError (ctx , r .Client , unbindErr , serviceBinding )
331+ return utils .HandleServiceManagerError (ctx , r .Client , serviceBinding , smClientTypes . DELETE , unbindErr )
332332 }
333333
334334 if operationURL != "" {
@@ -339,7 +339,7 @@ func (r *ServiceBindingReconciler) delete(ctx context.Context, serviceBinding *v
339339 if err := utils .UpdateStatus (ctx , r .Client , serviceBinding ); err != nil {
340340 return ctrl.Result {}, err
341341 }
342- return ctrl.Result {Requeue : true , RequeueAfter : r .Config .PollInterval }, nil
342+ return ctrl.Result {RequeueAfter : r .Config .PollInterval }, nil
343343 }
344344
345345 log .Info ("Binding was deleted successfully" )
@@ -354,7 +354,7 @@ func (r *ServiceBindingReconciler) poll(ctx context.Context, serviceBinding *v1.
354354
355355 smClient , err := r .GetSMClient (ctx , serviceInstance )
356356 if err != nil {
357- return utils .MarkAsTransientError (ctx , r .Client , common .Unknown , err , serviceBinding )
357+ return utils .HandleOperationFailure (ctx , r .Client , serviceBinding , common .Unknown , err )
358358 }
359359
360360 status , statusErr := smClient .Status (serviceBinding .Status .OperationURL , nil )
@@ -375,7 +375,7 @@ func (r *ServiceBindingReconciler) poll(ctx context.Context, serviceBinding *v1.
375375 }
376376
377377 if status == nil {
378- return utils .MarkAsTransientError (ctx , r .Client , serviceBinding .Status .OperationType , fmt .Errorf ("failed to get last operation status of %s" , serviceBinding .Name ), serviceBinding )
378+ return utils .HandleOperationFailure (ctx , r .Client , serviceBinding , serviceBinding .Status .OperationType , fmt .Errorf ("failed to get last operation status of %s" , serviceBinding .Name ))
379379 }
380380 switch status .State {
381381 case smClientTypes .INPROGRESS :
@@ -388,9 +388,9 @@ func (r *ServiceBindingReconciler) poll(ctx context.Context, serviceBinding *v1.
388388 return ctrl.Result {}, err
389389 }
390390 }
391- return ctrl.Result {Requeue : true , RequeueAfter : r .Config .PollInterval }, nil
391+ return ctrl.Result {RequeueAfter : r .Config .PollInterval }, nil
392392 case smClientTypes .FAILED :
393- // non transient error - should not retry
393+ // if async operation failed we should not retry
394394 utils .SetFailureConditions (status .Type , status .Description , serviceBinding , true )
395395 if serviceBinding .Status .OperationType == smClientTypes .DELETE {
396396 serviceBinding .Status .OperationURL = ""
@@ -822,10 +822,7 @@ func (r *ServiceBindingReconciler) validateSecretNameIsAvailable(ctx context.Con
822822func (r * ServiceBindingReconciler ) handleSecretError (ctx context.Context , op smClientTypes.OperationCategory , err error , binding * v1.ServiceBinding ) (ctrl.Result , error ) {
823823 log := utils .GetLogger (ctx )
824824 log .Error (err , fmt .Sprintf ("failed to store secret %s for binding %s" , binding .Spec .SecretName , binding .Name ))
825- if apierrors .ReasonForError (err ) == metav1 .StatusReasonUnknown {
826- return utils .MarkAsNonTransientError (ctx , r .Client , op , err , binding )
827- }
828- return utils .MarkAsTransientError (ctx , r .Client , op , err , binding )
825+ return utils .HandleOperationFailure (ctx , r .Client , binding , op , err )
829826}
830827
831828func (r * ServiceBindingReconciler ) getInstanceInfo (ctx context.Context , binding * v1.ServiceBinding ) (map [string ]string , error ) {
0 commit comments