<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Feb 15, 2018 at 2:00 PM, Steve Langasek <span dir="ltr"><<a href="mailto:steve.langasek@ubuntu.com" target="_blank">steve.langasek@ubuntu.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-">On Thu, Feb 15, 2018 at 06:48:31PM +0000, Iain Lane wrote:<br>
> [ autopkgtest-devel, this is<br>
>   <a href="https://lists.ubuntu.com/archives/ubuntu-devel/2018-February/040138.html" rel="noreferrer" target="_blank">https://lists.ubuntu.com/<wbr>archives/ubuntu-devel/2018-<wbr>February/040138.html</a><br>
>   and thread FYI - Reply-To / Mail-Followup-To set to exclude<br>
>   ubuntu-devel from this subthread so reviews go to the right place ]<br>
<br>
> On Thu, Feb 15, 2018 at 10:28:05AM -0500, Stéphane Graber wrote:<br>
> > […]<br>
> > And confirmed that networking inside both of them works fine here.<br>
<br>
> > I wonder if it's a netplan vs ifupdown thing hitting autopkgtest in this case?<br>
<br>
> I can build images: images(!) quite fine here, but when actually using<br>
> them I see these temporary resolution failures most of the time during<br>
> the initial apt-get update.<br>
<br>
> I tracked this down to a race condition - basically we try to do the<br>
> `apt-get update' before networking is fully up. (OK, I just saw Julian's<br>
> post which came in while I was writing this and says the same thing...)<br>
<br>
> There's a patch attached here which fixes the problem for me. I'm not<br>
> sure if there's a better way to do this - basically it starts<br>
> network-online.target and waits for it to become active, with a timeout.<br>
> Review appreciated.<br>
<br>
</span>It's a bit odd to be "start"ing a target in this manner.  Is it even<br>
necessary to start the target, or would it be sufficient to just check<br>
is-active in a loop?<br>
<br>
In that case, I would suggest:<br>
<br>
            timeout=60<br>
            while ! lxc exec "$CONTAINER" -- systemctl is-active network-online.target \<br>
                  && [ $timeout -ge 0 ]<br>
            do<br>
                timeout=$((timeout - 1))<br>
                sleep 1<br>
            done<br>
            [ $timeout -ge 0 ] || {<br>
                echo "Timed out waiting for network to come up" >&2<br>
                exit 1<br>
            }<br></blockquote><div><br></div><div>Or, invoke wait-online directly:</div><div><br></div><div> /lib/systemd/systemd-networkd-wait-online </div><div><br></div><div>lxc launch ubuntu-daily:bionic b3 && </div><div>  sleep 0.2 && </div><div>  lxc exec b3 -- /bin/bash -c 'sleep 2; echo "waiting on network"; /lib/systemd/systemd-networkd-wait-online &&  apt update'<br></div><div><br></div><div>systemd-networkd-wait-online isn't happy to start really early; it doesn't attempt to reconnect to dbus if you run it before it's up</div><div>so that's the sleep 2 in there.</div><div><br></div><div>networkd is enabled only on artful and newer, so this won't help w.r.t xenial and older.</div><div><br></div><div>Also, networkd comes up just as fast as networking in xenial  *if* you don't have IPV6 and accept-ra enabled.</div><div>networkd spends approx 10 seconds waiting for a RA solicitation on my Xenial machine;</div><div><br></div><div>If I disable dhcpv6 and accept-ra is false, then we do a v4 dhcp in less than 2 seconds.</div><div><br></div><div><div># cat /etc/netplan/50-cloud-init.yaml </div><div># This file is generated from information provided by</div><div># the datasource.  Changes to it will not persist across an instance.</div><div># To disable cloud-init's network configuration capabilities, write a file</div><div># /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:</div><div># network: {config: disabled}</div><div>network:</div><div>    version: 2</div><div>    ethernets:</div><div>        eth0:</div><div>            dhcp4: true</div><div>            dhcp6: false</div><div>            accept-ra: off</div></div><div><br></div><div><div>root@b1:~# systemd-analyze blame</div><div>           725ms systemd-networkd-wait-online.service</div></div><div><br></div><div>With RA enabled (the default in networkd)</div><div><br></div><div><div>root@b1:~# systemd-analyze blame</div><div>         13.141s systemd-networkd-wait-online.service</div></div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<span class="gmail-HOEnZb"><font color="#888888"><br>
<br>
--<br>
Steve Langasek                   Give me a lever long enough and a Free OS<br>
Debian Developer                   to set it on, and I can move the world.<br>
Ubuntu Developer                                    <a href="http://www.debian.org/" rel="noreferrer" target="_blank">http://www.debian.org/</a><br>
<a href="mailto:slangasek@ubuntu.com">slangasek@ubuntu.com</a>                                     <a href="mailto:vorlon@debian.org">vorlon@debian.org</a><br>
</font></span><br>--<br>
ubuntu-devel mailing list<br>
<a href="mailto:ubuntu-devel@lists.ubuntu.com">ubuntu-devel@lists.ubuntu.com</a><br>
Modify settings or unsubscribe at: <a href="https://lists.ubuntu.com/mailman/listinfo/ubuntu-devel" rel="noreferrer" target="_blank">https://lists.ubuntu.com/<wbr>mailman/listinfo/ubuntu-devel</a><br>
<br></blockquote></div><br></div></div>