Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

Add a loop to wait for master and filer services in post-install-bucket-hook (#6240)

Omar Hamadeh8ebbf37e8ece
diff --git a/k8s/charts/seaweedfs/templates/post-install-bucket-hook.yaml b/k8s/charts/seaweedfs/templates/post-install-bucket-hook.yaml
index 2260bd84a2..44d6508987 100644
--- a/k8s/charts/seaweedfs/templates/post-install-bucket-hook.yaml
+++ b/k8s/charts/seaweedfs/templates/post-install-bucket-hook.yaml
@@ -32,9 +32,9 @@ spec:
- name: WEED_CLUSTER_DEFAULT
value: "sw"
- name: WEED_CLUSTER_SW_MASTER
- value: "{{ template "seaweedfs.name" . }}-master.{{ .Release.Namespace }}:9333"
+ value: "{{ template "seaweedfs.name" . }}-master.{{ .Release.Namespace }}:{{ .Values.master.port }}"
- name: WEED_CLUSTER_SW_FILER
- value: "{{ template "seaweedfs.name" . }}-filer-client.{{ .Release.Namespace }}:8888"
+ value: "{{ template "seaweedfs.name" . }}-filer-client.{{ .Release.Namespace }}:{{ .Values.filer.port }}"
- name: POD_IP
valueFrom:
fieldRef:
@@ -53,6 +53,26 @@ spec:
- "/bin/sh"
- "-ec"
- |
+ wait_for_service() {
+ local url=$1
+ local max_attempts=60 # 5 minutes total (5s * 60)
+ local attempt=1
+
+ echo "Waiting for service at $url..."
+ while [ $attempt -le $max_attempts ]; do
+ if wget -q --spider "$url" >/dev/null 2>&1; then
+ echo "Service at $url is up!"
+ return 0
+ fi
+ echo "Attempt $attempt: Service not ready yet, retrying in 5s..."
+ sleep 5
+ attempt=$((attempt + 1))
+ done
+ echo "Service at $url failed to become ready within 5 minutes"
+ exit 1
+ }
+ wait_for_service "http://$WEED_CLUSTER_SW_MASTER{{ .Values.master.readinessProbe.httpGet.path }}"
+ wait_for_service "http://$WEED_CLUSTER_SW_FILER{{ .Values.filer.readinessProbe.httpGet.path }}"
{{- range $reg, $props := $.Values.filer.s3.createBuckets }}
exec /bin/echo \
"s3.bucket.create --name {{ $props.name }}" |\