Thursday, 15 February 2018

Re: autopkgtest-build-lxd failing with bionic

Hello Iain, all,

Iain Lane [2018-02-15 18:48 +0000]:
> There's a patch attached here which fixes the problem for me. I'm not
> sure if there's a better way to do this - basically it starts
> and waits for it to become active, with a timeout.
> Review appreciated.

I wouldn't pick on any of these: is a sloppily defined
shim for SysV init backwards compatibility, and may not ever get started (in
fact, that's the goal ☺); and the container might not use networkd, so I
wouldn't use s-n-wait-online either. I think querying

[ -n "$(ip route show to 0/0)" ]

is asking the question more directly, i. e. "do I have a default route", and is
ignorant of exactly how the network is brought up (by networkd, NM, ifupdown,
or not explicitly at all as the container might share the host's network

> From: Iain Lane <>
> Date: Thu, 15 Feb 2018 16:21:59 +0000
> Subject: [PATCH] lxd: If we're running systemd, wait until the network is up
> We execute `apt-get update' more or less as soon as the container is
> started. In some situations this is too early: it can be before network
> is fully working.
> If we have systemd, use to wait until it thinks
> networking is up.
> ---
> tools/autopkgtest-build-lxd | 19 ++++++++++++++++++-
> virt/autopkgtest-virt-lxd | 2 ++
> 2 files changed, 20 insertions(+), 1 deletion(-)
> diff --git a/tools/autopkgtest-build-lxd b/tools/autopkgtest-build-lxd
> index 623d5eb..9350a81 100755
> --- a/tools/autopkgtest-build-lxd
> +++ b/tools/autopkgtest-build-lxd
> @@ -68,7 +68,7 @@ setup() {
> lxc exec "$CONTAINER" -- chmod 644 /etc/apt/apt.conf.d/01proxy
> fi
> - # wait until it is booted: lxc exec works and we get a numeric runlevel
> + # wait until it is booted: lxc exec works, we get a numeric runlevel and networking is up

I agree that just adding it into this existing polling loop is the right place.
Adding the above default route test here should do nicely?

Also, this polling loop is still using a "runlevel == 2" test, which by now
might get a bit rusty. But I figure that's another story.. :-)