fix(backups): let the controller delete operator MariaDB Backups

Deleting a MariaDB Backup now deletes the k8s.mariadb.com/Backup that
wrote its dump, once the dump itself is gone, so the controller needs
the delete verb on that resource. Restores stay create-only.

Assisted-by: LLM
Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
This commit is contained in:
Alexey Artamonov committed 2026-11-06 16:04:04 +03:00
1 parent 195de033e8
commit 55f1fd33a8
2 files changed
+34 -5

No files matched your search

@@ -146,15 +146,16 @@ rules:
# MariaDB strategy: read the operator-side MariaDB CR to surface "not yet
# rendered" preconditions, create one-shot k8s.mariadb.com/Backup CRs on
# the BackupJob path, and create k8s.mariadb.com/Restore CRs on the
# RestoreJob path. The driver only ever Creates/Lists/Gets these objects -
# it does not patch or delete them; their lifecycle is owned by
# mariadb-operator and (for cleanup) by tenants / explicit teardown flows,
# never by this controller.
# RestoreJob path. A Backup is deleted once the dump it wrote is, when its
# Cozystack Backup is deleted; a Restore is never deleted.
- apiGroups: ["k8s.mariadb.com"]
resources: ["mariadbs"]
verbs: ["get", "list", "watch"]
- apiGroups: ["k8s.mariadb.com"]
resources: ["backups", "restores"]
resources: ["backups"]
verbs: ["get", "list", "watch", "create", "delete"]
- apiGroups: ["k8s.mariadb.com"]
resources: ["restores"]
verbs: ["get", "list", "watch", "create"]
# MongoDB strategy: read the operator-side PerconaServerMongoDB CR to gate on
# the backup preconditions, create one-shot PerconaServerMongoDBBackup CRs on the
@@ -0,0 +1,28 @@
suite: RBAC of the MariaDB dump cleanup
# Deleting a MariaDB Backup deletes its operator Backup once the dump is gone.
# The Go unit tests run with no authorization, so a missing verb only shows up
# on a cluster, where every such Backup would stay Terminating.
templates:
- templates/rbac.yaml
release:
name: backupstrategy-controller
namespace: cozy-backup-controller
tests:
- it: "ClusterRole can delete operator Backups but not Restores"
asserts:
- contains:
path: rules
content:
apiGroups: ["k8s.mariadb.com"]
resources: ["backups"]
verbs: ["get", "list", "watch", "create", "delete"]
- contains:
path: rules
content:
apiGroups: ["k8s.mariadb.com"]
resources: ["restores"]
verbs: ["get", "list", "watch", "create"]