Skip to content

Commit

Permalink
perf: parallelize downloadContainerdWasmShims function
Browse files Browse the repository at this point in the history
  • Loading branch information
Zachary Bailey committed Mar 11, 2024
1 parent f27b93e commit 616c5b5
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions parts/linux/cloud-init/artifacts/cse_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ downloadSecureTLSBootstrapKubeletExecPlugin() {
}

downloadContainerdWasmShims() {
local downloadShimPids=()
for shim_version in $CONTAINERD_WASM_VERSIONS; do
binary_version="$(echo "${shim_version}" | tr . -)"
local containerd_wasm_filepath="/usr/local/bin"
Expand All @@ -100,17 +101,21 @@ downloadContainerdWasmShims() {
fi

if [ ! -f "$containerd_wasm_filepath/containerd-shim-spin-${shim_version}" ] || [ ! -f "$containerd_wasm_filepath/containerd-shim-slight-${shim_version}" ]; then
retrycmd_if_failure 30 5 60 curl -fSLv -o "$containerd_wasm_filepath/containerd-shim-spin-${binary_version}-v1" "$containerd_wasm_url/containerd-shim-spin-v1" 2>&1 | tee $CURL_OUTPUT >/dev/null | grep -E "^(curl:.*)|([eE]rr.*)$" && (cat $CURL_OUTPUT && exit $ERR_KRUSTLET_DOWNLOAD_TIMEOUT)
retrycmd_if_failure 30 5 60 curl -fSLv -o "$containerd_wasm_filepath/containerd-shim-slight-${binary_version}-v1" "$containerd_wasm_url/containerd-shim-slight-v1" 2>&1 | tee $CURL_OUTPUT >/dev/null | grep -E "^(curl:.*)|([eE]rr.*)$" && (cat $CURL_OUTPUT && exit $ERR_KRUSTLET_DOWNLOAD_TIMEOUT)
if [ "$shim_version" = "v0.8.0" ]; then
# Only download the wws shim for v0.8.0, wws shim for v0.3.0 and v0.5.1 fail
retrycmd_if_failure 30 5 60 curl -fSLv -o "$containerd_wasm_filepath/containerd-shim-wws-${binary_version}-v1" "$containerd_wasm_url/containerd-shim-wws-v1" 2>&1 | tee $CURL_OUTPUT >/dev/null | grep -E "^(curl:.*)|([eE]rr.*)$" && (cat $CURL_OUTPUT && exit $ERR_KRUSTLET_DOWNLOAD_TIMEOUT)
chmod 755 "$containerd_wasm_filepath/containerd-shim-wws-${binary_version}-v1"
fi
chmod 755 "$containerd_wasm_filepath/containerd-shim-spin-${binary_version}-v1"
chmod 755 "$containerd_wasm_filepath/containerd-shim-slight-${binary_version}-v1"
retrycmd_if_failure 30 5 60 curl -fSLv -o "$containerd_wasm_filepath/containerd-shim-spin-${binary_version}-v1" "$containerd_wasm_url/containerd-shim-spin-v1" 2>&1 | tee $CURL_OUTPUT >/dev/null | grep -E "^(curl:.*)|([eE]rr.*)$" && (cat $CURL_OUTPUT && exit $ERR_KRUSTLET_DOWNLOAD_TIMEOUT) &
downloadShimPids+=($!)
retrycmd_if_failure 30 5 60 curl -fSLv -o "$containerd_wasm_filepath/containerd-shim-slight-${binary_version}-v1" "$containerd_wasm_url/containerd-shim-slight-v1" 2>&1 | tee $CURL_OUTPUT >/dev/null | grep -E "^(curl:.*)|([eE]rr.*)$" && (cat $CURL_OUTPUT && exit $ERR_KRUSTLET_DOWNLOAD_TIMEOUT) &
downloadShimPids+=($!)
retrycmd_if_failure 30 5 60 curl -fSLv -o "$containerd_wasm_filepath/containerd-shim-wws-${binary_version}-v1" "$containerd_wasm_url/containerd-shim-wws-v1" 2>&1 | tee $CURL_OUTPUT >/dev/null | grep -E "^(curl:.*)|([eE]rr.*)$" && (cat $CURL_OUTPUT && exit $ERR_KRUSTLET_DOWNLOAD_TIMEOUT) &
downloadShimPids+=($!)
fi
done
wait ${downloadShimPids[@]}
for shim_version in $CONTAINERD_WASM_VERSIONS; do
binary_version="$(echo "${shim_version}" | tr . -)"
chmod 755 "$containerd_wasm_filepath/containerd-shim-spin-${binary_version}-v1"
chmod 755 "$containerd_wasm_filepath/containerd-shim-slight-${binary_version}-v1"
chmod 755 "$containerd_wasm_filepath/containerd-shim-wws-${binary_version}-v1"
done
}

downloadAzureCNI() {
Expand Down

0 comments on commit 616c5b5

Please sign in to comment.