Files
cozystack/packages/apps
scooby87 5b26ec3462 fix(mariadb): clean up orphaned operator-generated secrets (#3056) (#3071)
## What this PR does

After deleting a `MariaDB` app CR with metrics and/or replication
enabled, two
Secrets created by the mariadb-operator were left orphaned in the tenant
namespace:

- `<release>-metrics-password`
- `<release>-repl-password`

These are generated by the operator (`k8s.mariadb.com/v1alpha1`) as a
side
effect of `metrics.enabled` / `replication.enabled`, so they are **not**
Helm-owned and survive `helm uninstall`. The existing post-delete hook
(`templates/hooks/cleanup-pvc.yaml`) only swept PVCs, leaving the
Secrets behind.

This PR extends that hook to also clean them up:

- grants the cleanup `Role` RBAC on `secrets`;
- deletes both password Secrets by name with `--ignore-not-found`;
- adds a `helm-unittest` suite locking in the behaviour, plus a `test`
Makefile
target so the package's tests actually run in CI
(`hack/helm-unit-tests.sh`
  only runs packages that define a `test` target).

Fixes #3056.

### Release note

```release-note
fix(mariadb): garbage-collect operator-generated metrics-password / repl-password Secrets when a MariaDB app is deleted
```


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Bug Fixes**
* Improved MariaDB uninstall cleanup to remove leftover
operator-generated password Secrets in addition to persistent
volumes/claims.
* Hardened the cleanup hook Job with stricter pod/container security
settings, least-privilege Secret permissions, idempotent deletions for
missing resources, and correct non-zero exit on real failures.
* **Tests**
* Added a cleanup hook test suite validating Secret deletion behavior,
failure propagation, and that cleanup RBAC grants least-privilege access
only to the required Secrets.
  * Added a Helm unit test `test` target for the MariaDB chart.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-06-30 18:05:55 +03:00
..
2026-06-22 10:55:37 +00:00
2026-06-25 14:33:28 +03:00
2026-03-25 15:59:22 +05:00
2025-08-07 14:07:05 +03:00

How to test packages local

cd packages/core/installer
make image-cozystack REGISTRY=YOUR_CUSTOM_REGISTRY
make apply
kubectl delete po -l app=source-controller -n cozy-fluxcd