diff --git a/deploy/objectstorage/init.sh b/deploy/objectstorage/init.sh index d0b27b91c54..5fbe719077d 100644 --- a/deploy/objectstorage/init.sh +++ b/deploy/objectstorage/init.sh @@ -4,8 +4,27 @@ export readonly ARCH=${1:-amd64} mkdir -p tars RetryPullImageInterval=3 +RetryPullFileInterval=3 RetrySleepSeconds=3 +retryPullFile() { + local file=$1 + local retry=0 + local retryMax=3 + set +e + while [ $retry -lt $RetryPullFileInterval ]; do + curl $file --create-dirs -o ./etc/minio-binaries/mc >/dev/null && break + retry=$(($retry + 1)) + echo "retry pull file $file, retry times: $retry" + sleep $RetrySleepSeconds + done + set -e + if [ $retry -eq $retryMax ]; then + echo "pull file $file failed" + exit 1 + fi +} + retryPullImage() { local image=$1 local retry=0 @@ -27,6 +46,7 @@ retryPullImage() { retryPullImage ghcr.io/labring/sealos-cloud-objectstorage-controller:latest retryPullImage ghcr.io/labring/sealos-cloud-objectstorage-frontend:latest retryPullImage ghcr.io/labring/sealos-cloud-minio-service:latest +retryPullFile https://dl.min.io/client/mc/release/linux-amd64/mc sealos save -o tars/objectstorage-controller.tar ghcr.io/labring/sealos-cloud-objectstorage-controller:latest sealos save -o tars/objectstorage-frontend.tar ghcr.io/labring/sealos-cloud-objectstorage-frontend:latest diff --git a/deploy/objectstorage/scripts/minio.sh b/deploy/objectstorage/scripts/minio.sh index eac780362fb..68eab45f217 100644 --- a/deploy/objectstorage/scripts/minio.sh +++ b/deploy/objectstorage/scripts/minio.sh @@ -28,12 +28,8 @@ function deploy_minio() { } function init_minio() { - if [ ! -f "$HOME/minio-binaries/mc" ]; then - curl https://dl.min.io/client/mc/release/linux-amd64/mc --create-dirs -o $HOME/minio-binaries/mc - fi - - chmod +x $HOME/minio-binaries/mc - export PATH=$PATH:$HOME/minio-binaries/ + chmod +x ./etc/minio-binaries/mc + export PATH=$PATH:./etc/minio-binaries/ while kubectl wait -l statefulset.kubernetes.io/pod-name=object-storage-pool-0-0 --for=condition=ready pod -n objectstorage-system --timeout=-1s 2>&1 | grep -q "error: no matching resources found"; do sleep 1