@@ -34,6 +34,7 @@ import (
3434 "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
3535 "sigs.k8s.io/controller-runtime/pkg/log"
3636
37+ "github.com/sap/component-operator-runtime/internal/util"
3738 "github.com/sap/component-operator-runtime/pkg/cluster"
3839 "github.com/sap/component-operator-runtime/pkg/status"
3940 "github.com/sap/component-operator-runtime/pkg/types"
@@ -1318,7 +1319,7 @@ func (r *Reconciler) deleteObject(ctx context.Context, key types.ObjectKey, exis
13181319 }
13191320 if ok := controllerutil .RemoveFinalizer (crd , r .finalizer ); ok {
13201321 // note: 409 error is very likely here (because of concurrent updates happening through the api server); this is why we retry once
1321- if err := r . client . Update (ctx , crd , client . FieldOwner ( r .fieldOwner ) ); err != nil {
1322+ if err := util . UpdateFinalizers (ctx , r . client , crd , r .fieldOwner ); err != nil {
13221323 if i == 1 && apierrors .IsConflict (err ) {
13231324 log .V (1 ).Info ("error while updating CustomResourcedefinition (409 conflict); doing one retry" , "error" , err .Error ())
13241325 continue
@@ -1343,7 +1344,7 @@ func (r *Reconciler) deleteObject(ctx context.Context, key types.ObjectKey, exis
13431344 }
13441345 if ok := controllerutil .RemoveFinalizer (apiService , r .finalizer ); ok {
13451346 // note: 409 error is very likely here (because of concurrent updates happening through the api server); this is why we retry once
1346- if err := r . client . Update (ctx , apiService , client . FieldOwner ( r .fieldOwner ) ); err != nil {
1347+ if err := util . UpdateFinalizers (ctx , r . client , apiService , r .fieldOwner ); err != nil {
13471348 if i == 1 && apierrors .IsConflict (err ) {
13481349 log .V (1 ).Info ("error while updating APIService (409 conflict); doing one retry" , "error" , err .Error ())
13491350 continue
@@ -1371,7 +1372,7 @@ func (r *Reconciler) orphanObject(ctx context.Context, existingObject *unstructu
13711372 if isCrd (existingObject ) || isApiService (existingObject ) {
13721373 object := existingObject .DeepCopy ()
13731374 if controllerutil .RemoveFinalizer (object , r .finalizer ) {
1374- if err := r . client . Update (ctx , object , client . FieldOwner ( r .fieldOwner ) ); err != nil {
1375+ if err := util . UpdateFinalizers (ctx , r . client , object , r .fieldOwner ); err != nil {
13751376 return err
13761377 }
13771378 }
0 commit comments