diff --git a/pkg/controller/ps/configuration.go b/pkg/controller/ps/configuration.go index 7713e25f4..a5eceee84 100644 --- a/pkg/controller/ps/configuration.go +++ b/pkg/controller/ps/configuration.go @@ -96,7 +96,7 @@ func (r *PerconaServerMySQLReconciler) reconcileCustomConfiguration(ctx context. return "", errors.New("resources.limits[memory] or resources.requests[memory] should be specified for template usage in configuration") } - cm := k8s.ConfigMap(cmName, cr.Namespace, configurable.GetConfigMapKey(), configuration) + cm := k8s.ConfigMap(cmName, cr.Namespace, configurable.GetConfigMapKey(), configuration, cr) if !reflect.DeepEqual(currCm.Data, cm.Data) { if err := k8s.EnsureObject(ctx, r.Client, cr, cm, r.Scheme); err != nil { return "", errors.Wrapf(err, "ensure ConfigMap/%s", cmName) diff --git a/pkg/controller/ps/controller.go b/pkg/controller/ps/controller.go index 665a67e88..ccbf28a64 100644 --- a/pkg/controller/ps/controller.go +++ b/pkg/controller/ps/controller.go @@ -710,7 +710,7 @@ func (r *PerconaServerMySQLReconciler) reconcileMySQLAutoConfig(ctx context.Cont config += autotuneParams } - configMap := k8s.ConfigMap(mysql.AutoConfigMapName(cr), cr.Namespace, mysql.CustomConfigKey, config) + configMap := k8s.ConfigMap(mysql.AutoConfigMapName(cr), cr.Namespace, mysql.CustomConfigKey, config, cr) if !reflect.DeepEqual(currentConfigMap.Data, configMap.Data) { if err := k8s.EnsureObject(ctx, r.Client, cr, configMap, r.Scheme); err != nil { return errors.Wrapf(err, "ensure ConfigMap/%s", configMap.Name) diff --git a/pkg/controller/psbackup/controller.go b/pkg/controller/psbackup/controller.go index a1688abee..fad236648 100644 --- a/pkg/controller/psbackup/controller.go +++ b/pkg/controller/psbackup/controller.go @@ -135,7 +135,7 @@ func (r *PerconaServerMySQLBackupReconciler) Reconcile(ctx context.Context, req if cluster.Spec.Backup == nil || !cluster.Spec.Backup.Enabled { status.State = apiv1alpha1.BackupError - status.StateDesc = "spec.backup stanza not found in PerconaServerMySQL CustomResource or backup is disabled" + status.StateDesc = "spec.backup not found in PerconaServerMySQL CustomResource or backup is disabled" return rr, nil } @@ -259,7 +259,7 @@ func (r *PerconaServerMySQLBackupReconciler) createBackupJob(ctx context.Context switch storage.Type { case apiv1alpha1.BackupStorageS3: if storage.S3 == nil { - return errors.New("s3 stanza is required in storage") + return errors.New("s3 is required in storage") } nn := types.NamespacedName{Name: storage.S3.CredentialsSecret, Namespace: cr.Namespace} @@ -279,7 +279,7 @@ func (r *PerconaServerMySQLBackupReconciler) createBackupJob(ctx context.Context status.Destination = destination case apiv1alpha1.BackupStorageGCS: if storage.GCS == nil { - return errors.New("gcs stanza is required in storage") + return errors.New("gcs is required in storage") } nn := types.NamespacedName{Name: storage.GCS.CredentialsSecret, Namespace: cr.Namespace} @@ -299,7 +299,7 @@ func (r *PerconaServerMySQLBackupReconciler) createBackupJob(ctx context.Context status.Destination = destination case apiv1alpha1.BackupStorageAzure: if storage.Azure == nil { - return errors.New("azure stanza is required in storage") + return errors.New("azure is required in storage") } nn := types.NamespacedName{Name: storage.Azure.CredentialsSecret, Namespace: cr.Namespace} diff --git a/pkg/controller/psbackup/controller_test.go b/pkg/controller/psbackup/controller_test.go index f6fec7a3e..bdf9dbdfd 100644 --- a/pkg/controller/psbackup/controller_test.go +++ b/pkg/controller/psbackup/controller_test.go @@ -64,7 +64,7 @@ func TestBackupStatusErrStateDesc(t *testing.T) { } }, ), - stateDesc: "spec.backup stanza not found in PerconaServerMySQL CustomResource or backup is disabled", + stateDesc: "spec.backup not found in PerconaServerMySQL CustomResource or backup is disabled", }, { name: "without storage", diff --git a/pkg/k8s/configmap.go b/pkg/k8s/configmap.go index e14f7b003..59e1dd3c3 100644 --- a/pkg/k8s/configmap.go +++ b/pkg/k8s/configmap.go @@ -1,11 +1,14 @@ package k8s import ( + apiv1alpha1 "github.com/percona/percona-server-mysql-operator/api/v1alpha1" + "github.com/percona/percona-server-mysql-operator/pkg/naming" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -func ConfigMap(name, namespace, filename, data string) *corev1.ConfigMap { +func ConfigMap(name, namespace, filename, data string, cr *apiv1alpha1.PerconaServerMySQL) *corev1.ConfigMap { + return &corev1.ConfigMap{ TypeMeta: metav1.TypeMeta{ APIVersion: "v1", @@ -14,6 +17,7 @@ func ConfigMap(name, namespace, filename, data string) *corev1.ConfigMap { ObjectMeta: metav1.ObjectMeta{ Name: name, Namespace: namespace, + Labels: naming.Labels(name, cr.Name, "percona-server", "database"), }, Data: map[string]string{ filename: data,