Skip to content

Commit 210b7fe

Browse files
yankawaiIvanHunters
authored andcommitted
fix(kafka): stop the pre-delete hook from wedging the uninstall
Signed-off-by: Yan Bondarenko <[email protected]>
1 parent 9d2fddd commit 210b7fe

2 files changed

Lines changed: 20 additions & 7 deletions

File tree

packages/apps/kafka/templates/delete.yaml renamed to packages/apps/kafka/templates/hooks/delete.yaml

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,25 @@ spec:
5151
- |
5252
set -eu
5353
echo "Deleting KafkaTopics for {{ .Release.Name }} before the topic-operator is removed"
54-
kubectl -n {{ .Release.Namespace }} delete kafkatopics.kafka.strimzi.io \
55-
-l 'strimzi.io/cluster={{ .Release.Name }}' \
56-
--ignore-not-found=true \
57-
--wait=true \
58-
--timeout=180s \
59-
--request-timeout=20s
54+
if ! out=$(kubectl -n {{ .Release.Namespace }} delete kafkatopics.kafka.strimzi.io \
55+
-l 'strimzi.io/cluster={{ .Release.Name }}' \
56+
--ignore-not-found=true \
57+
--wait=true \
58+
--timeout=180s \
59+
--request-timeout=20s 2>&1); then
60+
printf '%s\n' "${out}"
61+
case "${out}" in
62+
*"the server doesn't have a resource type"*|*"no matches for kind"*)
63+
echo "KafkaTopic CRD absent; nothing to delete" ;;
64+
*"timed out waiting for the condition"*)
65+
echo "WARNING: topics still hold the strimzi.io/topic-operator finalizer after 180s." >&2
66+
echo "WARNING: leaving them behind so the uninstall can finish; clear the finalizer by hand." >&2 ;;
67+
*)
68+
echo "ERROR: deleting KafkaTopics failed: ${out}" >&2; exit 1 ;;
69+
esac
70+
else
71+
printf '%s\n' "${out}"
72+
fi
6073
volumeMounts:
6174
- name: tmp
6275
mountPath: /tmp

‎packages/apps/kafka/tests/delete_test.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
suite: Kafka pre-delete cleanup
22

33
templates:
4-
- templates/delete.yaml
4+
- templates/hooks/delete.yaml
55

66
release:
77
name: kafka-test

0 commit comments

Comments
 (0)