Skip to content

Commit d70deb0

Browse files
Merge pull request #328 from stuggi/add_finalizer
Always check to add finalizer on galera
2 parents 119a21f + 04a5875 commit d70deb0

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

controllers/mariadbdatabase_controller.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,14 +144,13 @@ func (r *MariaDBDatabaseReconciler) Reconcile(ctx context.Context, req ctrl.Requ
144144
}
145145

146146
// here we know that Galera exists so add a finalizer to ourselves and to the db CR. Before this point there is no reason to have a finalizer on ourselves as nothing to cleanup.
147-
if instance.DeletionTimestamp.IsZero() || isNewInstance { // this condition can be removed if you wish as it is always true at this point otherwise we would returned earlier.
148-
if controllerutil.AddFinalizer(dbGalera, fmt.Sprintf("%s-%s", helper.GetFinalizer(), instance.Name)) {
149-
err := r.Update(ctx, dbGalera)
150-
if err != nil {
151-
return ctrl.Result{}, err
152-
}
147+
if controllerutil.AddFinalizer(dbGalera, fmt.Sprintf("%s-%s", helper.GetFinalizer(), instance.Name)) {
148+
err := r.Update(ctx, dbGalera)
149+
if err != nil {
150+
return ctrl.Result{}, err
153151
}
154-
152+
}
153+
if instance.DeletionTimestamp.IsZero() || isNewInstance { // this condition can be removed if you wish as it is always true at this point otherwise we would returned earlier.
155154
if controllerutil.AddFinalizer(instance, helper.GetFinalizer()) {
156155
// we need to persist this right away
157156
return ctrl.Result{}, nil

0 commit comments

Comments
 (0)