From 40422382be68f43f309c31339696efe61ac99f81 Mon Sep 17 00:00:00 2001 From: shunki-fujita Date: Tue, 8 Oct 2024 03:34:57 +0000 Subject: [PATCH] issue-747: Add a finalizer to the MySQLCluster's pods. --- controllers/mysqlcluster_controller.go | 3 ++- pkg/constants/meta.go | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/controllers/mysqlcluster_controller.go b/controllers/mysqlcluster_controller.go index 526b5ecd8..09f541511 100644 --- a/controllers/mysqlcluster_controller.go +++ b/controllers/mysqlcluster_controller.go @@ -784,7 +784,8 @@ func (r *MySQLClusterReconciler) reconcileV1StatefulSet(ctx context.Context, req sts.Spec.WithTemplate(corev1ac.PodTemplateSpec(). WithAnnotations(cluster.Spec.PodTemplate.Annotations). WithLabels(cluster.Spec.PodTemplate.Labels). - WithLabels(labelSet(cluster, false))) + WithLabels(labelSet(cluster, false)). + WithFinalizers(constants.MySQLClusterPodFinalizer)) podSpec := corev1ac.PodSpecApplyConfiguration(*cluster.Spec.PodTemplate.Spec.DeepCopy()) podSpec.WithServiceAccountName(cluster.PrefixedName()) diff --git a/pkg/constants/meta.go b/pkg/constants/meta.go index f7cabf8e6..b1bbdf094 100644 --- a/pkg/constants/meta.go +++ b/pkg/constants/meta.go @@ -26,3 +26,6 @@ const ( // MySQLClusterFinalizer is the finalizer specifier for MySQLCluster. const MySQLClusterFinalizer = "moco.cybozu.com/mysqlcluster" + +// MySQLClusterPodFinalizer is the finalizer specifier for MySQLCluster's pods. +const MySQLClusterPodFinalizer = "moco.cybozu.com/mysqlcluster-pod"