@@ -77,8 +77,17 @@ func (r *JobReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.R
7777 return ctrl.Result {}, err
7878 }
7979
80- // If the job status is `done`, we have nothing to do
80+ // If the job status is `done`, we have nothing to do, should remove finalizer if set
8181 if sfs .Annotations [iamProbeStatus ] == iamProbeDone {
82+ if controllerutil .RemoveFinalizer (& job , finalizerName ) {
83+ if err := r .Update (ctx , & job ); err != nil {
84+ if apierrors .IsConflict (err ) {
85+ return ctrl.Result {Requeue : true }, nil
86+ }
87+ log .Error (err , "failed to remove finalizer" )
88+ return ctrl.Result {}, err
89+ }
90+ }
8291 return ctrl.Result {}, nil
8392 }
8493
@@ -152,6 +161,9 @@ func (r *JobReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.R
152161
153162 if controllerutil .RemoveFinalizer (& job , finalizerName ) {
154163 if err := r .Update (ctx , & job ); err != nil {
164+ if apierrors .IsConflict (err ) {
165+ return ctrl.Result {Requeue : true }, nil
166+ }
155167 log .Error (err , "failed to remove finalizer" )
156168 return ctrl.Result {}, err
157169 }
0 commit comments