Skip to content

Commit

Permalink
Merge pull request #7823 from akhilerm/cherry-pick-7771-1.6
Browse files Browse the repository at this point in the history
[release/1.6] support fetching containerd from non public GCS buckets
  • Loading branch information
dmcgowan committed Dec 15, 2022
2 parents 34f7cec + bd7db85 commit b56901d
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions contrib/gce/configure.sh
Expand Up @@ -104,6 +104,17 @@ if [ -f "${CONTAINERD_HOME}/${CONTAINERD_ENV_METADATA}" ]; then
source "${CONTAINERD_HOME}/${CONTAINERD_ENV_METADATA}"
fi

set +x
# GCS_BUCKET_TOKEN_METADATA is the metadata key for the GCS bucket token
GCS_BUCKET_TOKEN_METADATA="GCS_BUCKET_TOKEN"
# GCS_BUCKET_TOKEN should have read access to the bucket from which
# containerd artifacts need to be downloaded
GCS_BUCKET_TOKEN=$(fetch_metadata "${GCS_BUCKET_TOKEN_METADATA}")
if [[ -n "${GCS_BUCKET_TOKEN}" ]]; then
HEADERS=(-H "Authorization: Bearer ${GCS_BUCKET_TOKEN}")
fi
set -x

# CONTAINERD_PKG_PREFIX is the prefix of the cri-containerd tarball name.
# By default use the release tarball with cni built in.
pkg_prefix=${CONTAINERD_PKG_PREFIX:-"cri-containerd-cni"}
Expand All @@ -126,7 +137,7 @@ else

# TODO(random-liu): Put version into the metadata instead of
# deciding it in cloud init. This may cause issue to reboot test.
version=$(curl -f --ipv4 --retry 6 --retry-delay 3 --silent --show-error \
version=$(set +x; curl -X GET "${HEADERS[@]}" -f --ipv4 --retry 6 --retry-delay 3 --silent --show-error \
https://storage.googleapis.com/${deploy_path}/latest)
fi

Expand All @@ -152,7 +163,8 @@ else
echo "${TARBALL_GCS_NAME} is preloaded"
else
# Download and untar the release tar ball.
curl -f --ipv4 -Lo "${TARBALL}" --connect-timeout 20 --max-time 300 --retry 6 --retry-delay 10 "${TARBALL_GCS_PATH}"
$(set +x; curl -X GET "${HEADERS[@]}" -f --ipv4 -Lo "${TARBALL}" --connect-timeout 20 --max-time 300 --retry 6 \
--retry-delay 10 "${TARBALL_GCS_PATH}")
tar xvf "${TARBALL}"
rm -f "${TARBALL}"
fi
Expand Down

0 comments on commit b56901d

Please sign in to comment.