Retry APT commands during genesis/join

This avoids issues when, e.g. cloud-init is still installing packages
when the join script executes.

Change-Id: Iba637426480b140013c5ff441b978677f15b6709
This commit is contained in:
Mark Burnett 2017-11-15 16:32:12 -06:00
parent 2fd461d0e8
commit 8de837bfbd
1 changed files with 30 additions and 7 deletions

View File

@ -49,14 +49,37 @@ log === Installing system packages ===
set -x
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install -y --no-install-recommends \
{%- for package in config['HostSystem:packages.additional'] | default([]) %}
{{ package }} \
{%- endfor %}
{{ config['HostSystem:packages.required.docker'] }} \
{{ config['HostSystem:packages.required.socat'] }}
end=$(($(date +%s) + 600))
while true; do
if ! apt-get update; then
now=$(date +%s)
if [[ ${now} -gt ${end} ]]; then
log Failed to update apt-cache.
exit 1
fi
sleep 10
else
break
fi
done
end=$(($(date +%s) + 600))
while true; do
if ! apt-get install -y --no-install-recommends \
{%- for package in config['HostSystem:packages.additional'] | default([]) %}
{{ package }} \
{%- endfor %}
{{ config['HostSystem:packages.required.docker'] }} \
{{ config['HostSystem:packages.required.socat'] }}; then
now=$(date +%s)
if [[ ${now} -gt ${end} ]]; then
log Failed to install apt packages.
exit 1
fi
else
break
fi
done
# Start core processes
#