fix(clickhouse, opensearch): reap finished cleanup Jobs (#5543)

## What this PR does

Every deleted ClickHouse or OpenSearch leaves a Completed
`<release>-cleanup` Job and its pod in the tenant namespace for good,
because the post-delete hooks keep only `before-hook-creation` and have
no TTL. The commit adds `ttlSecondsAfterFinished: 86400` to both Jobs,
the same value `pre-delete-unpin` in kubernetes-nodes uses, so a
succeeded run is reaped and a failed one still keeps its logs for a day.

The cleanup tests of both charts gain a case for the TTL; it fails on
main and passes here, and the 46 ClickHouse and 153 OpenSearch tests
pass.

Closes #5542

### Screenshots

Not a UI change.

### Downstream repositories

- [x] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up:
- [ ]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up:
- [ ]
[cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack)
- follow-up:
- [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up:
- [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up:
- [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) -
follow-up:
- [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) -
follow-up:
- [ ]
[cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server)
- follow-up:
- [ ]
[cozystack/external-apps-example](https://github.com/cozystack/external-apps-example)
- follow-up:
- [ ] [cozystack/examples](https://github.com/cozystack/examples) -
follow-up:
- [ ] [cozystack/community](https://github.com/cozystack/community) -
follow-up:

### Release note

```release-note
fix(clickhouse, opensearch): the post-delete cleanup Job of a deleted ClickHouse or OpenSearch is removed a day after it finishes instead of staying in the tenant namespace for good.
```


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

<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **Improvements**
* Completed PVC cleanup jobs and their pods are now eligible for
automatic removal after one day in ClickHouse and OpenSearch, helping
prevent finished cleanup resources from lingering.
* Failed cleanup jobs remain available for troubleshooting during that
retention period.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Aleksei Sviridkin authored and GitHub committed 2026-12-02 05:13:31 +03:00
commit 40a3b0ba2c
4 files changed
+24

No files matched your search

@@ -13,6 +13,9 @@ metadata:
# hook-succeeded so they are reclaimed after a successful uninstall.
"helm.sh/hook-delete-policy": before-hook-creation
spec:
# Helm does not own a post-delete hook after the release is gone, so only
# this reaps the finished Job and its pod; a failed run keeps its logs a day.
ttlSecondsAfterFinished: 86400
activeDeadlineSeconds: 270
template:
metadata:
@@ -101,3 +101,12 @@ tests:
- equal:
path: subjects[0].name
value: ch-test-cleanup
- it: "reaps the finished cleanup Job after a day"
documentSelector:
path: kind
value: Job
asserts:
- equal:
path: spec.ttlSecondsAfterFinished
value: 86400
@@ -10,6 +10,9 @@ metadata:
"helm.sh/hook-weight": "10"
"helm.sh/hook-delete-policy": before-hook-creation
spec:
# Helm does not own a post-delete hook after the release is gone, so only
# this reaps the finished Job and its pod; a failed run keeps its logs a day.
ttlSecondsAfterFinished: 86400
backoffLimit: 1
activeDeadlineSeconds: 120
template:
@@ -103,3 +103,12 @@ tests:
- equal:
path: subjects[0].name
value: os-test-cleanup
- it: "reaps the finished cleanup Job after a day"
documentSelector:
path: kind
value: Job
asserts:
- equal:
path: spec.ttlSecondsAfterFinished
value: 86400