Files
cozystack/internal
Alexey Artamonov f147b22d86 fix(backups): delete a MariaDB dump when its Backup is deleted
Deleting a MariaDB Backup left its dump in the bucket for good:
mariadb-operator's maxRetention prunes only from inside the next run of
the same prefix, and a Plan never deletes a Backup, so on the platform
bucket nothing else ever removes it.

Every run of an application writes under one prefix, so the key deleted
has to be proven to be this Backup's. It is the dump the Backup records,
or, for a Backup taken before dumps were recorded, the one the existing
ownership match attributes to its operator Backup. That match is
recorded on the Backup before the delete, so a retry deletes the same
key by name instead of matching again against a bucket that no longer
holds it. Without proof the Backup is released with a Warning and
nothing is deleted, the operator Backup included, since any later
attribution starts from it. The operator Backup is deleted only after
its dump, and the delete waits while a RestoreJob still restores from
the Backup.

The delete runs in the controller through the same minio client the
size probe uses, so it verifies TLS the way mariadb-operator did when
it wrote the dump. A dump on the platform bucket, which the operator
Backup names by its bucket and by the projected credentials Secret, is
reached through the platform's current endpoint and keys, still
trusting a CA the strategy pinned, so a Backup taken before the
endpoint moved is still deleted.

Platform credentials that cannot be read fall back to the ones the
operator Backup names. A failed delete holds the Backup and retries
with a Warning naming the skip-artifact-cleanup annotation, except in
a terminating namespace, where the Backup is released with a Warning
so it does not hold the namespace.

Assisted-by: LLM
Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
2026-11-06 17:24:29 +03:00
..