Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
inelpandzic committed Aug 19, 2024
1 parent 37dffb6 commit e730d4f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
10 changes: 0 additions & 10 deletions api/v1alpha1/perconaservermysql_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -840,16 +840,6 @@ func (cr *PerconaServerMySQL) CheckNSetDefaults(ctx context.Context, serverVersi
return nil
}

func (cr *PerconaServerMySQL) FinalizerApplied(finalizer string) bool {
for _, f := range cr.GetFinalizers() {
if f == finalizer {
return true
}
}

return false
}

const (
BinVolumeName = "bin"
BinVolumePath = "/opt/percona"
Expand Down
5 changes: 3 additions & 2 deletions pkg/controller/ps/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import (
k8sretry "k8s.io/client-go/util/retry"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
logf "sigs.k8s.io/controller-runtime/pkg/log"

apiv1alpha1 "github.com/percona/percona-server-mysql-operator/api/v1alpha1"
Expand Down Expand Up @@ -190,7 +191,7 @@ func (r *PerconaServerMySQLReconciler) deleteMySQLPods(ctx context.Context, cr *

// If `delete-mysql-pvc` finalizer is also applied we need to remove all the secrets,
// but we need to do it here since there are needed to apply this finalizer.
if cr.FinalizerApplied(naming.FinalizerDeleteMySQLPvc) {
if controllerutil.ContainsFinalizer(cr, naming.FinalizerDeleteMySQLPvc) {
secretNames := []string{
cr.Spec.SecretsName,
"internal-" + cr.Name,
Expand Down Expand Up @@ -403,7 +404,7 @@ func (r *PerconaServerMySQLReconciler) deleteMySQLPvc(ctx context.Context, cr *a

// If `delete-mysql-in-order` finalizer is applied, we will let that handler
// remove all the secrets, since they are needed to remove pods in order.
if cr.FinalizerApplied(naming.FinalizerDeletePodsInOrder) {
if controllerutil.ContainsFinalizer(cr, naming.FinalizerDeleteMySQLPvc) {
return nil
}

Expand Down

0 comments on commit e730d4f

Please sign in to comment.