From 9227c2e211825d82a70add738474b9132970d830 Mon Sep 17 00:00:00 2001 From: Yan Bondarenko <202671653+yankawai@users.noreply.github.com> Date: Tue, 1 Dec 2026 19:33:36 +0100 Subject: [PATCH] fix(clickhouse, opensearch): reap finished cleanup Jobs The post-delete PVC cleanup Jobs of ClickHouse and OpenSearch keep only before-hook-creation, so a failed run stays for post-mortem. Helm drops the hook once the release is gone, and nothing else deletes the Job, so every deleted instance leaves a Completed -cleanup Job and its pod in the tenant namespace for good; on the cluster the oldest had sat there for 85 days. Set ttlSecondsAfterFinished to a day, as pre-delete-unpin in kubernetes-nodes does, so a succeeded run is reaped and a failed one still keeps its logs long enough to read. Assisted-by: LLM Signed-off-by: Yan Bondarenko <202671653+yankawai@users.noreply.github.com> --- .../apps/clickhouse/templates/hooks/cleanup-pvc.yaml | 3 +++ packages/apps/clickhouse/tests/cleanup_pvc_test.yaml | 9 +++++++++ .../apps/opensearch/templates/hooks/cleanup-pvc.yaml | 3 +++ packages/apps/opensearch/tests/cleanup_pvc_test.yaml | 9 +++++++++ 4 files changed, 24 insertions(+) diff --git a/packages/apps/clickhouse/templates/hooks/cleanup-pvc.yaml b/packages/apps/clickhouse/templates/hooks/cleanup-pvc.yaml index e7127a2a9..dd814adf3 100644 --- a/packages/apps/clickhouse/templates/hooks/cleanup-pvc.yaml +++ b/packages/apps/clickhouse/templates/hooks/cleanup-pvc.yaml @@ -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: diff --git a/packages/apps/clickhouse/tests/cleanup_pvc_test.yaml b/packages/apps/clickhouse/tests/cleanup_pvc_test.yaml index 37b77cc85..776e82adb 100644 --- a/packages/apps/clickhouse/tests/cleanup_pvc_test.yaml +++ b/packages/apps/clickhouse/tests/cleanup_pvc_test.yaml @@ -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 diff --git a/packages/apps/opensearch/templates/hooks/cleanup-pvc.yaml b/packages/apps/opensearch/templates/hooks/cleanup-pvc.yaml index 438a7203e..55d42f543 100644 --- a/packages/apps/opensearch/templates/hooks/cleanup-pvc.yaml +++ b/packages/apps/opensearch/templates/hooks/cleanup-pvc.yaml @@ -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: diff --git a/packages/apps/opensearch/tests/cleanup_pvc_test.yaml b/packages/apps/opensearch/tests/cleanup_pvc_test.yaml index ba4a54ba8..9c164aa3d 100644 --- a/packages/apps/opensearch/tests/cleanup_pvc_test.yaml +++ b/packages/apps/opensearch/tests/cleanup_pvc_test.yaml @@ -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