I've uploaded this to xenial-proposed , the version with fix is 0.7.8-1-g3705bb5-0ubuntu1~16.04.3
https://launchpad.net/ubuntu/xenial/+queue?queue_state=1&queue_text =cloud-init We need an SRU team member to replace 0.7.8-1-g3705bb5-0ubuntu1~16.04.2 in xenial-proposed with 0.7.8-1-g3705bb5-0ubuntu1~16.04.3 ** Description changed: + == Begin SRU Template == + [Impact] + When told to configure ntp, and the ntp package is not installed + in an image, cloud-init will attempt to install the package. + + The problem here is that it currently tries to install the package before + it configures apt. As a result, no apt proxy or mirror configuration is + setup, and the stock image apt config is used. + + [Test Case] + ## Failure can be shown like this: + $ cat > user-data <<END + #cloud-config + ntp: + servers: ['ntp.ubuntu.com'] + + apt: + primary: + - arches: [default] + uri: http://us.archive.ubuntu.com/ubuntu/ + END + + $ release=xenial + $ name=x1 + $ lxc init ubuntu-daily:$release $name "--config=user.user-data=$(cat user-data)" + + # simulate a mirror that can't be reached by changing + # /etc/apt/sources.list to have a bogus mirror. + # what should happen is that cloud-init should apply apt config changes + # and render /etc/apt/sources.list from /etc/cloud/templates/ + # and do the mirror substitution first. + # + # The bug is that cloud-init does not render apply the apt + # config before ntp runs and requests the package installation. + + $ lxc file push - $name/etc/apt/sources.list <<EOF + deb http://bogus.example.com/ubuntu/ $release main restricted universe + EOF + + $ lxc start $name + + # wait for it to boot + $ while ! lxc exec $name -- [ -e /run/cloud-init/result.json ]; do sleep 1; done + + $ lxc file pull $name/var/log/cloud-init-output.log - | egrep "^[EW]:" + W: Failed to fetch http://bogus.example.com/ubuntu/dists/xenial/InRelease Could not resolve 'bogus.example.com' + W: Some index files failed to download. They have been ignored, or old ones used instead. + E: Unable to locate package ntp + EOF + + + [Regression Potential] + The 'ntp' function is fairly new, and is only used if a user specifies + an ntp configuration as shown above. Regression chance is low then + and should be restricted to scenarios where users are providing + the ntp configuration. + == End SRU Template == + cloud-init tries to install NTP package before it actually configures /etc/apt/sources.list. In a closed MAAS environment where MAAS is limited to access to us.archive.ubuntu.com , cloud-init is trying to access to archive.ubuntu.com. In commissioning, however, cloud-init is doing this: - 1. cloud-init gets metadata from MAAS 2. cloud-init tries to install NTP from archive.ubuntu.com 3. cloud-init configures /etc/apt/sources.list with us.archive.ubuntu.com 4. cloud-init installs other packages. ** Description changed: == Begin SRU Template == [Impact] When told to configure ntp, and the ntp package is not installed in an image, cloud-init will attempt to install the package. The problem here is that it currently tries to install the package before it configures apt. As a result, no apt proxy or mirror configuration is setup, and the stock image apt config is used. [Test Case] ## Failure can be shown like this: $ cat > user-data <<END #cloud-config ntp: - servers: ['ntp.ubuntu.com'] + servers: ['ntp.ubuntu.com'] apt: - primary: - - arches: [default] - uri: http://us.archive.ubuntu.com/ubuntu/ + primary: + - arches: [default] + uri: http://us.archive.ubuntu.com/ubuntu/ END $ release=xenial $ name=x1 $ lxc init ubuntu-daily:$release $name "--config=user.user-data=$(cat user-data)" # simulate a mirror that can't be reached by changing # /etc/apt/sources.list to have a bogus mirror. # what should happen is that cloud-init should apply apt config changes # and render /etc/apt/sources.list from /etc/cloud/templates/ # and do the mirror substitution first. - # + # # The bug is that cloud-init does not render apply the apt # config before ntp runs and requests the package installation. $ lxc file push - $name/etc/apt/sources.list <<EOF deb http://bogus.example.com/ubuntu/ $release main restricted universe EOF $ lxc start $name # wait for it to boot $ while ! lxc exec $name -- [ -e /run/cloud-init/result.json ]; do sleep 1; done $ lxc file pull $name/var/log/cloud-init-output.log - | egrep "^[EW]:" W: Failed to fetch http://bogus.example.com/ubuntu/dists/xenial/InRelease Could not resolve 'bogus.example.com' W: Some index files failed to download. They have been ignored, or old ones used instead. E: Unable to locate package ntp EOF + + ## The fix can be shown applied by subsequently + # push the broken sources.list back into image. + + $ lxc file push - $name/etc/apt/sources.list <<EOF + deb http://bogus.example.com/ubuntu/ $release main restricted universe + EOF + + ## Now update container, clean and reboot to show first boot + $ lxc exec $name -- sh -c ' + p=/etc/apt/sources.list.d/proposed.list + echo deb http://archive.ubuntu.com/ubuntu xenial-proposed main > "$p" && + apt-get update -q && apt-get -qy install cloud-init' + $ lxc exec $name -- sh -c ' + cd /var/lib/cloud && for d in *; do [ "$d" = "seed" ] || rm -Rf "$d"; done + rm -Rf /var/log/cloud-init*' + + $ lxc file pull $name/var/log/cloud-init-output.log - | egrep "^[EW]:" || + echo "FIX WORKED." [Regression Potential] The 'ntp' function is fairly new, and is only used if a user specifies an ntp configuration as shown above. Regression chance is low then and should be restricted to scenarios where users are providing the ntp configuration. == End SRU Template == cloud-init tries to install NTP package before it actually configures /etc/apt/sources.list. In a closed MAAS environment where MAAS is limited to access to us.archive.ubuntu.com , cloud-init is trying to access to archive.ubuntu.com. In commissioning, however, cloud-init is doing this: 1. cloud-init gets metadata from MAAS 2. cloud-init tries to install NTP from archive.ubuntu.com 3. cloud-init configures /etc/apt/sources.list with us.archive.ubuntu.com 4. cloud-init installs other packages. -- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/1628337 Title: cloud-init tries to install NTP before even configuring the archives To manage notifications about this bug go to: https://bugs.launchpad.net/cloud-init/+bug/1628337/+subscriptions -- ubuntu-bugs mailing list [email protected] https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs
