mirror of
https://github.com/cozystack/cozystack.git
synced 2026-10-29 08:07:33 +09:00
fix(kafka): fail closed when listing topics for an all-topics backup
In the empty-TOPICS (back up all non-internal topics) branch, the topic list was resolved with a single pipeline under set -eu without pipefail: TLIST=$(kafka-topics.sh --list | grep -v '^_' || true) The pipeline's exit status is grep's alone, so a real broker error (unreachable / auth) that emits no stdout makes grep exit 1, || true swallows it, and TLIST is empty - indistinguishable from 'no non-internal topics'. The backup then drains nothing, tars an empty dir, PUTs it and reports success: a silent empty backup a later restore would treat as authoritative. Split the --list into its own command substitution so a broker error aborts the Pod under set -e; filter internal topics only afterwards, so an empty TLIST means genuinely no user topics. Signed-off-by: Andrey Kolkov <andrey.kolkov@aenix.io> Assisted-by: LLM
This commit is contained in:
1 parent
c84f77ac16
commit
b099f8dde4
1 file changed
+9
-1
@@ -156,7 +156,15 @@ spec:
|
||||
if [ -n "\${TOPICS}" ]; then
|
||||
TLIST=\$(printf '%s' "\${TOPICS}" | tr ', ' ' ')
|
||||
else
|
||||
TLIST=\$("\${BIN}"/kafka-topics.sh --bootstrap-server "\${BOOT}" --list | grep -v '^_' || true)
|
||||
# Fail closed: run --list as its own command so a broker
|
||||
# error (unreachable / auth) aborts the Pod under set -e
|
||||
# instead of the pipe masking the exit status to grep's and
|
||||
# || true swallowing it. Only then filter internal topics, so
|
||||
# an empty TLIST means genuinely no non-internal topics -
|
||||
# never a silently swallowed failure that would PUT an empty
|
||||
# tarball and report success.
|
||||
raw=\$("\${BIN}"/kafka-topics.sh --bootstrap-server "\${BOOT}" --list)
|
||||
TLIST=\$(printf '%s\n' "\${raw}" | grep -v '^_' || true)
|
||||
fi
|
||||
echo "backing up topics [\${TLIST}] from \${BOOT}"
|
||||
MANIFEST="\${WORK}/manifest.txt"
|
||||
|
||||
Reference in new issue
Block a user