six demon bag

Wind, fire, all that kind of thing!

2017-09-29

LXD upgrade fails on Ubuntu 16.04 without Systemd

Recently I tried to install LXD (Canonical's container manager) from backports on a Ubuntu 16.04 system (running without Systemd). The version shipping with the system (2.0) doesn't suffice, because I need the new storage API that was introduced with LXD 2.15. However, upgrading to the backports package failed post-install:

invoke-rc.d: initscript lxd, action "start" failed.
dpkg: error processing package lxd (--configure):
 subprocess installed post-installation script returned error exit status 1
Processing triggers for ureadahead (0.100.0-19) ...
Errors were encountered while processing:
 lxd
E: Sub-process /usr/bin/dpkg returned an error code (1)

Which was weird, since the upgrade had worked for me before.


As it turned out the then-current version in backports had been 2.15, and someone decided to already remove the Upstart init file from the LXD 2.17 package:

$ dpkg --contents lxd_2.15-0ubuntu6~ubuntu16.04.1_amd64.deb | sort -k 6
drwxr-xr-x root/root         0 2017-07-06 07:11 ./
drwxr-xr-x root/root         0 2017-07-06 07:11 ./etc/
drwxr-xr-x root/root         0 2017-07-06 07:10 ./etc/dnsmasq.d-available/
-rw-r--r-- root/root       214 2017-07-06 07:10 ./etc/dnsmasq.d-available/lxd
drwxr-xr-x root/root         0 2017-07-06 07:11 ./etc/init/
drwxr-xr-x root/root         0 2017-07-06 07:11 ./etc/init.d/
-rwxr-xr-x root/root      2240 2017-07-06 07:11 ./etc/init.d/lxd
-rw-r--r-- root/root       590 2017-07-06 07:11 ./etc/init/lxd.conf
drwxr-xr-x root/root         0 2017-07-06 07:11 ./etc/logrotate.d/
-rw-r--r-- root/root       146 2017-07-05 20:51 ./etc/logrotate.d/lxd
drwxr-xr-x root/root         0 2017-07-06 07:10 ./etc/sysctl.d/
-rw-r--r-- root/root       153 2017-07-06 07:10 ./etc/sysctl.d/10-lxd-inotify.conf
drwxr-xr-x root/root         0 2017-07-06 07:11 ./lib/
...
$ dpkg --contents lxd_2.17-0ubuntu2~ubuntu16.04.1_amd64.deb | sort -k 6
drwxr-xr-x root/root         0 2017-08-29 07:06 ./
drwxr-xr-x root/root         0 2017-08-29 07:06 ./etc/
drwxr-xr-x root/root         0 2017-08-29 07:06 ./etc/dnsmasq.d-available/
-rw-r--r-- root/root       214 2017-08-29 07:06 ./etc/dnsmasq.d-available/lxd
drwxr-xr-x root/root         0 2017-08-29 07:06 ./etc/init.d/
-rwxr-xr-x root/root      2240 2017-08-29 07:06 ./etc/init.d/lxd
drwxr-xr-x root/root         0 2017-08-29 07:06 ./etc/logrotate.d/
-rw-r--r-- root/root       146 2017-08-26 00:35 ./etc/logrotate.d/lxd
drwxr-xr-x root/root         0 2017-08-29 07:06 ./etc/sysctl.d/
-rw-r--r-- root/root       153 2017-08-29 07:06 ./etc/sysctl.d/10-lxd-inotify.conf
drwxr-xr-x root/root         0 2017-08-29 07:06 ./lib/
...

Once identified, the problem was easily fixed by restoring the original lxd.conf and removing 2 lines for starting/stopping the LXD bridge (because the respective scripts had already been removed in earlier backports packages).

To get a working LXD 2.17 on Ubuntu 16.04 add the backports repository to your apt sources:

# /etc/apt/sources.list.d/backports.list
deb http://archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse

and pin the LXD packages from that repository:

# /etc/apt/preferences.d/lxd
Package: lxd*
Pin: release a=xenial-backports
Pin-Priority: 600

Remove or comment the offending lines in /etc/init/lxd.conf (modifying the file also prevents it from getting removed during the upgrade), then upgrade LXD:

sed -i '/lxd-bridge/ s/^/#/' /etc/init/lxd.conf
apt-get update
apt-get -y dist-upgrade

The upgrade will still terminate with an error, but now you can restore the preserved Upstart init file and simply fix the installation:

mv /etc/init/lxd.conf.dpkg-dist /etc/init/lxd.conf
apt-get install -f

Note: a better alternative to restoring and modifying the lxd.conf from LXD 2.0 might be using the lxd.conf that I scavenged from an older box still running LXD 2.15.

description "LXD - main daemon"
author "Stéphane Graber <stgraber@ubuntu.com>"

start on runlevel [2345]
stop on starting rc RUNLEVEL=[016]
limit nofile 65536 65536
kill timeout 60

respawn

pre-start exec /usr/lib/x86_64-linux-gnu/lxc/lxc-apparmor-load

script
    # To get the proxy variables
    [ -e /etc/environment ] && . /etc/environment

    exec /usr/bin/lxd --group lxd --logfile=/var/log/lxd/lxd.log
end script

post-start script
    /usr/bin/lxd waitready --timeout=600
end script

pre-stop script
    [ -n "${UPSTART_STOP_EVENTS:-}" ] && exec /usr/bin/lxd shutdown
end script

Posted 13:57 [permalink]