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