From c4002fafc79ebc497377a9b08d748c4f14877d08 Mon Sep 17 00:00:00 2001 From: bati-valensas <150924329+bati-valensas@users.noreply.github.com> Date: Fri, 23 Oct 2026 16:43:35 +0300 Subject: [PATCH] helm: fix bucket hook treating an existing bucket as missing (#11982) * helm: fix bucket hook treating an existing bucket as missing The skip check pipes awk into `grep -q`, which exits on the first match and can leave awk writing into a closed pipe. awk then dies of SIGPIPE and `set -o pipefail` makes the pipeline report that, so a bucket that exists reads as missing: the hook runs `s3.bucket.create`, it errors with "already exists", and `sh -ec` aborts the hook - failing the release. Match in a single awk instead, which reads to EOF and cannot be killed by a closing reader. * helm: force string compare in bucket hook existence check --------- Co-authored-by: Chris Lu --- .../seaweedfs/templates/shared/post-install-bucket-hook.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/k8s/charts/seaweedfs/templates/shared/post-install-bucket-hook.yaml b/k8s/charts/seaweedfs/templates/shared/post-install-bucket-hook.yaml index 11ea7feff6..3952c73fbf 100644 --- a/k8s/charts/seaweedfs/templates/shared/post-install-bucket-hook.yaml +++ b/k8s/charts/seaweedfs/templates/shared/post-install-bucket-hook.yaml @@ -172,7 +172,8 @@ spec: {{- $bucketName := .name }} {{- $bucketLock := or .lock .objectLock .withLock }} bucket_list=$(/bin/echo 's3.bucket.list' | /usr/bin/weed shell) || { echo "Error listing s3 buckets"; exit 1; } - if echo "$bucket_list" | awk '{print $1}' | grep -Fxq "{{ $bucketName }}"; then + {{- /* One awk: grep -q exits early, awk takes SIGPIPE, pipefail fails the test. */}} + if printf '%s\n' "$bucket_list" | awk -v bucket="{{ $bucketName }}" '$1 "" == bucket { found = 1 } END { exit !found }'; then echo "Bucket '{{ $bucketName }}' already exists, skipping creation." else echo "Creating bucket '{{ $bucketName }}'..."