From 79de65aad6fb7a816e607caf6ddb166720493eda Mon Sep 17 00:00:00 2001 From: Mattia Eleuteri Date: Mon, 16 Nov 2026 14:48:17 +0100 Subject: [PATCH] fix(mariadb): let mariadb-operator watch the credentials Secret A password changed in users..password is written to the -credentials Secret, but mariadb-operator reconciles a User on a change of its passwordSecretKeyRef Secret only when that Secret carries the k8s.mariadb.com/watch label. Without it the new password reaches the server only on the operator's periodic SQL requeue, 10h plus up to 1h of jitter after the last reconcile, and the previous password stays valid until then, even across a pod restart. Main already carries the label since the passwords became chart-generated (9f857f64e), which is a breaking change and not a backport candidate. Add only the label on release-1.6. Assisted-by: LLM Signed-off-by: Mattia Eleuteri --- packages/apps/mariadb/templates/secret.yaml | 9 +++++++ .../tests/credentials_secret_watch_test.yaml | 24 +++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 packages/apps/mariadb/tests/credentials_secret_watch_test.yaml diff --git a/packages/apps/mariadb/templates/secret.yaml b/packages/apps/mariadb/templates/secret.yaml index aa2bd50e3..639813eb5 100644 --- a/packages/apps/mariadb/templates/secret.yaml +++ b/packages/apps/mariadb/templates/secret.yaml @@ -25,6 +25,15 @@ apiVersion: v1 kind: Secret metadata: name: {{ .Release.Name }}-credentials + labels: + {{- /* + mariadb-operator reconciles a User when its passwordSecretKeyRef Secret + changes only if that Secret carries this label. Without it, a password + changed in users..password reaches the server only on the operator's + periodic SQL requeue (10h plus up to 1h of jitter), and the previous + password stays valid until then. + */}} + k8s.mariadb.com/watch: "" stringData: {{- range $name, $u := $usersWithRoot }} {{ $name }}: {{ index $passwords $name }} diff --git a/packages/apps/mariadb/tests/credentials_secret_watch_test.yaml b/packages/apps/mariadb/tests/credentials_secret_watch_test.yaml new file mode 100644 index 000000000..a3054d2bb --- /dev/null +++ b/packages/apps/mariadb/tests/credentials_secret_watch_test.yaml @@ -0,0 +1,24 @@ +suite: MariaDB credentials Secret is watched by mariadb-operator + +templates: + - templates/secret.yaml + +tests: + - it: labels the credentials Secret so a changed user password is reconciled on change + release: + name: mariadb-test + namespace: tenant-test + set: + users: + alice: + password: rotated-password + maxUserConnections: 10 + asserts: + - isKind: + of: Secret + - equal: + path: metadata.labels["k8s.mariadb.com/watch"] + value: "" + - equal: + path: stringData.alice + value: rotated-password