Skip to content

Commit

Permalink
perf: add variable for max parallel image pulls
Browse files Browse the repository at this point in the history
  • Loading branch information
Zachary Bailey committed Apr 22, 2024
1 parent bab959d commit ae24506
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion vhdbuilder/packer/install-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,9 @@ string_replace() {
echo ${1//\*/$2}
}

PARALLEL_CONTAINER_IMAGE_PULL_LIMIT=$(nproc --ignore=2)
echo "Limit for parallel container image pulls set to $PARALLEL_CONTAINER_IMAGE_PULL_LIMIT"

declare -a containerImagePids=()

ContainerImages=$(jq ".ContainerImages" $COMPONENTS_FILEPATH | jq .[] --monochrome-output --compact-output)
Expand Down Expand Up @@ -300,7 +303,7 @@ for imageToBePulled in ${ContainerImages[*]}; do
pullContainerImage ${cliTool} ${CONTAINER_IMAGE} &
containerImagePids+=($!)
echo " - ${CONTAINER_IMAGE}" >> ${VHD_LOGS_FILEPATH}
while [[ $(jobs -p | wc -l) -ge 13 ]]; do # Set maximum number of parallel pulls to 13
while [[ $(jobs -p | wc -l) -ge $PARALLEL_CONTAINER_IMAGE_PULL_LIMIT ]]; do
wait -n
done
done
Expand Down Expand Up @@ -456,6 +459,9 @@ for KUBE_PROXY_IMAGE_VERSION in ${KUBE_PROXY_IMAGE_VERSIONS}; do
CONTAINER_IMAGE="mcr.microsoft.com/oss/kubernetes/kube-proxy:v${KUBE_PROXY_IMAGE_VERSION}"
pullContainerImage ${cliTool} ${CONTAINER_IMAGE} &
kubeProxyPids+=($!)
while [[ $(jobs -p | wc -l) -ge $PARALLEL_CONTAINER_IMAGE_PULL_LIMIT ]]; do
wait -n
done
done
wait ${kubeProxyPids[@]} # Wait for all background processes to finish

Expand Down

0 comments on commit ae24506

Please sign in to comment.