Skip to content

Commit

Permalink
Fix adding finalizer
Browse files Browse the repository at this point in the history
  • Loading branch information
zreigz committed Nov 14, 2022
1 parent 1551af8 commit 744fd54
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pkg/database/database_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,17 +170,18 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu
return ctrl.Result{}, err
}

if err := kubernetes.TryAddFinalizer(ctx, r.Client, database, DatabaseFinalizer); err != nil {
log.Error(err, "Can't update finalizer")
return ctrl.Result{}, err
}

if err := patchDatabase(ctx, patchHelper, database); err != nil {
if strings.Contains(err.Error(), genericregistry.OptimisticLockErrorMsg) {
return reconcile.Result{RequeueAfter: time.Second * 1}, nil
}
log.Error(err, "failed to patch Database")
return ctrl.Result{}, err
}
if err := kubernetes.TryAddFinalizer(ctx, r.Client, database, DatabaseFinalizer); err != nil {
log.Error(err, "Can't update finalizer")
return ctrl.Result{}, err
}

return ctrl.Result{}, nil
}
Expand All @@ -189,6 +190,7 @@ func (r *Reconciler) deleteDatabaseOp(ctx context.Context, database *databasev1a
if !strings.EqualFold(database.Spec.DriverName, r.DriverName) {
return nil
}

if database.Spec.DeletionPolicy == databasev1alpha1.DeletionPolicyDelete {
req := &databasespec.DriverDeleteDatabaseRequest{
DatabaseId: database.Status.DatabaseID,
Expand Down

0 comments on commit 744fd54

Please sign in to comment.