Skip to content

Commit 0aa112f

Browse files
committed
Modify minio copy template for better handling of errors
1 parent 8493f3b commit 0aa112f

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

infra/fridge/isolated-cluster/k8s/argo_workflows/templates.yaml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,20 @@ spec:
2727
copy_jobs=""
2828
for file in $(echo "{{inputs.parameters.files}}" | tr ";" " "); do
2929
echo "Copying $file"
30-
curl -s --cacert $cert_file https://minio.argo-artifacts.svc.cluster.local/{{inputs.parameters.bucket}}/$file > /data/$file &
30+
(
31+
tmp_out=$(mktemp)
32+
http_code=$(curl -s --cacert $cert_file \
33+
https://minio.argo-artifacts.svc.cluster.local/{{inputs.parameters.bucket}}/$file \
34+
-o $tmp_out \
35+
-w "%{http_code}")
36+
if [ "$http_code" -lt 200 ] || [ "$http_code" -ge 300 ]; then
37+
echo "Failed to copy $file (HTTP $http_code)"
38+
echo "Response: $(cat $tmp_out)"
39+
rm -f $tmp_out
40+
exit 1
41+
fi
42+
mv $tmp_out /data/$file
43+
) &
3144
copy_jobs="$copy_jobs $!"
3245
done
3346
@@ -38,7 +51,7 @@ spec:
3851
3952
if [ "$code" -ne 0 ]; then
4053
echo "Copy failed (PID $pid, exit code $code)"
41-
kill $pids 2>/dev/null # Stop all remaining downloads
54+
kill $copy_jobs 2>/dev/null # Stop all remaining downloads
4255
exit "$code"
4356
fi
4457
done

0 commit comments

Comments
 (0)