mirror of https://github.com/zulip/zulip.git
test-install: Wait for network in the lxc container.
Ubuntu 20.04 "focal" comes up to runlevel 5 several seconds before it is able to successfully resolve hosts, causing `prepare-base` to fail while fetching from the apt repositories. Add an additional check to verify that outbound networking is running before returning from `lxc-wait`.
This commit is contained in:
parent
fc31eaa356
commit
e0b725be63
|
@ -27,16 +27,36 @@ if [ "$EUID" -ne 0 ]; then
|
|||
fi
|
||||
|
||||
# We poll.
|
||||
for _ in {1..60}; do
|
||||
echo "lxc-wait: $CONTAINER_NAME: polling for boot..." >&2
|
||||
runlevel="$(lxc-attach --clear-env -n "$CONTAINER_NAME" -- runlevel 2>/dev/null)" \
|
||||
|| { sleep 1; continue; }
|
||||
if [ "$runlevel" != "${0%[0-9]}" ]; then
|
||||
echo "lxc-wait: $CONTAINER_NAME: booted!" >&2
|
||||
exit 0
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
poll_runlevel() {
|
||||
for _ in {1..60}; do
|
||||
echo "lxc-wait: $CONTAINER_NAME: polling for boot..." >&2
|
||||
runlevel="$(lxc-attach --clear-env -n "$CONTAINER_NAME" -- runlevel 2>/dev/null)" \
|
||||
|| { sleep 1; continue; }
|
||||
if [ "$runlevel" != "${0%[0-9]}" ]; then
|
||||
echo "lxc-wait: $CONTAINER_NAME: booted!" >&2
|
||||
poll_network
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
echo "error: timeout waiting for container to boot" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
||||
poll_network() {
|
||||
for _ in {1..60}; do
|
||||
echo "lxc-wait: $CONTAINER_NAME: polling for network..." >&2
|
||||
# New hosts don't have `host` or `nslookup`
|
||||
lxc-attach --clear-env -n "$CONTAINER_NAME" -- \
|
||||
ping -q -c 1 archive.ubuntu.com 2>/dev/null >/dev/null \
|
||||
|| { sleep 1; continue; }
|
||||
echo "lxc-wait: $CONTAINER_NAME: network is up!" >&2
|
||||
exit 0
|
||||
done
|
||||
echo "error: timeout waiting for container to get network" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
||||
poll_runlevel
|
||||
|
||||
echo "error: timeout waiting for container to boot" >&2
|
||||
exit 1
|
||||
|
|
Loading…
Reference in New Issue