lxc updates
cover lxc updates
Before doing an uprev of lxc I wanted to do some housekeeping on the current version, the result of some runtime testing with sysvinit and systemd along with some feedback from users. There were some inconsistencies between the packaging and handling of the two init systems which these change address, making the runtime experience match more closely. This also addresses some of the bugs we have recieved due to the -setup package which had (d)evolved from its initial intent. There is nothing groundbreaking here, and the end result should just be that there is less confusion when one wants to get lxc up and running in an image. These changes were tested thoroughly with 'cgroup-lite', 'lxc' and optionally 'lxc-networking' packages added to core-image-minimal when either sysvinit or systemd is in use.
Mark Asselstine
PATCH 1/4 lxc: drop the -setup package
For some packages we include a -setup package which can be installed as part of an image to complete a more comprehensive setup of the main package. This is common for example in meta-cloud-services since many OpenStack packages have extensive setup.
The -setup package for lxc did at one point do comprehensive setup but over time this has been moved to the -networking package. Now the -setup package is only being used as a container for the systemd service files or sysvinit scripts. This can better be accomplished by setting appropriate runlevels for the initscripts or disabling or masking the systemd services (via SYSTEMD_AUTO_ENABLE).
This also fixes some confusion or what might be considered a bug around -setup and -networking packages as the -setup package was mopping up the lxc-net.service file, instead of it being included in the -networking package.
--- recipes-containers/lxc/lxc_2.0.8.bb | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-)
recipes-containers/lxc/lxc_2.0.8.bb +15 -18
@@ -81,13 +81,17 @@ export STAGING_LIBDIR inherit autotools pkgconfig ptest update-rc.d systemd python3native -SYSTEMD_PACKAGES = "${PN}-setup" -SYSTEMD_SERVICE_${PN}-setup = "lxc.service" -SYSTEMD_AUTO_ENABLE_${PN}-setup = "disable" - -INITSCRIPT_PACKAGES = "${PN}-setup" -INITSCRIPT_NAME_{PN}-setup = "lxc" -INITSCRIPT_PARAMS_${PN}-setup = "defaults" +SYSTEMD_PACKAGES = "${PN} ${PN}-networking" +SYSTEMD_SERVICE_${PN} = "lxc.service" +SYSTEMD_AUTO_ENABLE_${PN} = "disable" +SYSTEMD_SERVICE_${PN}-networking = "lxc-net.service" +SYSTEMD_AUTO_ENABLE_${PN}-networking = "enable" + +INITSCRIPT_PACKAGES = "${PN} ${PN}-networking" +INITSCRIPT_NAME_${PN} = "lxc" +INITSCRIPT_PARAMS_${PN} = "defaults" +INITSCRIPT_NAME_${PN}-networking = "lxc-net" +INITSCRIPT_PARAMS_${PN}-networking = "defaults" FILES_${PN}-doc = "${mandir} ${infodir}" # For LXC the docdir only contains example configuration files and should be included in the lxc package
@@ -96,18 +100,13 @@ FILES_${PN} += "${libdir}/python3*" FILES_${PN} += "${datadir}/bash-completion" FILES_${PN}-dbg += "${libexecdir}/lxc/.debug" FILES_${PN}-dbg += "${libexecdir}/lxc/hooks/.debug" -PACKAGES =+ "${PN}-templates ${PN}-setup ${PN}-networking ${PN}-lua" +PACKAGES =+ "${PN}-templates ${PN}-networking ${PN}-lua" FILES_lua-${PN} = "${datadir}/lua ${libdir}/lua" FILES_lua-${PN}-dbg += "${libdir}/lua/lxc/.debug" FILES_${PN}-templates += "${datadir}/lxc/templates" RDEPENDS_${PN}-templates += "bash" -ALLOW_EMPTY_${PN}-networking = "1" - -FILES_${PN}-setup += "/etc/tmpfiles.d" -FILES_${PN}-setup += "/lib/systemd/system" -FILES_${PN}-setup += "/usr/lib/systemd/system" -FILES_${PN}-setup += "/etc/init.d" +FILES_${PN}-networking += "${sysconfdir}/init.d/lxc-net" PRIVATE_LIBS_${PN}-ptest = "liblxc.so.1"
@@ -128,10 +127,8 @@ do_install_append() { for i in `grep -l "#! */bin/bash" ${D}${datadir}/lxc/hooks/*`; do \ sed -e 's|#! */bin/bash|#!/bin/sh|' -i $i; done - if ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'true', 'false', d)}; then - install -d ${D}${sysconfdir}/init.d - install -m 755 config/init/sysvinit/lxc* ${D}${sysconfdir}/init.d - fi + install -d ${D}${sysconfdir}/init.d + install -m 755 config/init/sysvinit/lxc* ${D}${sysconfdir}/init.d # since python3-native is used for install location this will not be # suitable for the target and we will have to correct the package install
Signature · 1 line
2.7.4
PATCH 2/4 lxc: rename the lxc 'autostart' sysvinit script matching upstream
In reply to Mark AsselstineThis was renamed back in v1.1.0 but I suppose most folks have been buiding for systemd or were not using this functionality and it went unnoticed.
--- recipes-containers/lxc/lxc_2.0.8.bb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
recipes-containers/lxc/lxc_2.0.8.bb +1 -1
@@ -88,7 +88,7 @@ SYSTEMD_SERVICE_${PN}-networking = "lxc-net.service" SYSTEMD_AUTO_ENABLE_${PN}-networking = "enable" INITSCRIPT_PACKAGES = "${PN} ${PN}-networking" -INITSCRIPT_NAME_${PN} = "lxc" +INITSCRIPT_NAME_${PN} = "lxc-containers" INITSCRIPT_PARAMS_${PN} = "defaults" INITSCRIPT_NAME_${PN}-networking = "lxc-net" INITSCRIPT_PARAMS_${PN}-networking = "defaults"
Signature · 1 line
2.7.4
PATCH 3/4 lxc: add wget as an RDEPENDS needed for the download template
In reply to Mark AsselstineWithout this we get:
ERROR: Missing required tool: wget
When attempting to do something like:
lxc-create -n ubu -t download -- --no-validate -d ubuntu -r xenial
--- recipes-containers/lxc/lxc_2.0.8.bb | 1 + 1 file changed, 1 insertion(+)
recipes-containers/lxc/lxc_2.0.8.bb +1 -0
@@ -8,6 +8,7 @@ RDEPENDS_${PN} = " \ gzip \ xz \ tar \ + wget \ libcap-bin \ bridge-utils \ dnsmasq \
Signature · 1 line
2.7.4
PATCH 4/4 lxc: cleanup the lxc-networking package
In reply to Mark AsselstineAdding missing RDEPENDS on iptables, the lxc-net service will fail without this. Use the new 'pkg_postinst_ontarget_' instead of failing out to signal runtime postinst scripts, this conforms with the latest expectation for bitbake. The interfaces file is specific to sysvinit and unneeded for systemd so block the creation of these files only when building for sysvinit.
Lastly add a default 'lxc-net' file. Since we have a separate lxc-networking package we can complete it with this configuration which is sourced by '/etc/default/lxc' (which is part of the core lxc package). In doing this we are like Debian when the lxc-networking package is not installed in the image, and like Ubuntu when it is.
--- recipes-containers/lxc/files/lxc-net | 9 +++++++++ recipes-containers/lxc/lxc_2.0.8.bb | 24 +++++++++++++++--------- 2 files changed, 24 insertions(+), 9 deletions(-) create mode 100644 recipes-containers/lxc/files/lxc-net
recipes-containers/lxc/files/lxc-net new file +9 -0
@@ -0,0 +1,9 @@ +USE_LXC_BRIDGE="true" +LXC_BRIDGE="lxcbr0" +LXC_ADDR="10.0.3.1" +LXC_NETMASK="255.255.255.0" +LXC_NETWORK="10.0.3.0/24" +LXC_DHCP_RANGE="10.0.3.2,10.0.3.254" +LXC_DHCP_MAX="253" +LXC_DHCP_CONFILE="" +LXC_DOMAIN=""
recipes-containers/lxc/lxc_2.0.8.bb +15 -9
@@ -30,6 +30,8 @@ RDEPENDS_${PN}_append_libc-glibc = " glibc-utils" RDEPENDS_${PN}-ptest += "file make gmp nettle gnutls bash" +RDEPENDS_${PN}-networking += "iptables" + SRC_URI = "http://linuxcontainers.org/downloads/${BPN}-${PV}.tar.gz \ file://lxc-1.0.0-disable-udhcp-from-busybox-template.patch \ file://runtest.patch \
@@ -40,6 +42,7 @@ SRC_URI = "http://linuxcontainers.org/downloads/${BPN}-${PV}.tar.gz \ file://logs-optionally-use-base-filenames-to-report-src-fil.patch \ file://cgroups-work-around-issue-in-gcc-7.patch \ file://dnsmasq.conf \ + file://lxc-net \ " SRC_URI[md5sum] = "7bfd95280522d7936c0979dfea92cdb5"
@@ -107,7 +110,10 @@ FILES_lua-${PN}-dbg += "${libdir}/lua/lxc/.debug" FILES_${PN}-templates += "${datadir}/lxc/templates" RDEPENDS_${PN}-templates += "bash" -FILES_${PN}-networking += "${sysconfdir}/init.d/lxc-net" +FILES_${PN}-networking += " \ + ${sysconfdir}/init.d/lxc-net \ + ${sysconfdir}/default/lxc-net \ +" PRIVATE_LIBS_${PN}-ptest = "liblxc.so.1"
@@ -138,6 +144,11 @@ do_install_append() { rmdir --ignore-fail-on-non-empty ${D}${exec_prefix}/lib fi + # /etc/default/lxc sources lxc-net, this allows lxc bridge when lxc-networking + # is not installed this results in no lxcbr0, but when lxc-networking is installed + # lxcbr0 will be fully configured. + install -m 644 ${WORKDIR}/lxc-net ${D}${sysconfdir}/default/ + # Force the main dnsmasq instance to bind only to specified interfaces and # to not bind to virbr0. Libvirt will run its own instance on this interface. install -d ${D}/${sysconfdir}/dnsmasq.d
@@ -156,14 +167,8 @@ pkg_postinst_${PN}() { fi } -pkg_postinst_${PN}-networking() { - if [ "x$D" != "x" ]; then - exit 1 - fi - - # setup for our bridge - echo "lxc.network.link=lxcbr0" >> ${sysconfdir}/lxc/default.conf - +pkg_postinst_ontarget_${PN}-networking() { +if ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'true', 'false', d)}; then cat >> /etc/network/interfaces << EOF auto lxcbr0
@@ -187,4 +192,5 @@ if test "x\$IFACE" = xlxcbr0 ; then fi EOF chmod 755 /etc/network/if-pre-up.d/lxcbr0 +fi }
Signature · 1 line
2.7.4
They all look good to me.
Thanks for the cleanup, these are now merged.
Bruce
Quoted 22 lines · Mark Asselstine
Before doing an uprev of lxc I wanted to do some housekeeping on the current version, the result of some runtime testing with sysvinit and systemd along with some feedback from users. There were some inconsistencies between the packaging and handling of the two init systems which these change address, making the runtime experience match more closely. This also addresses some of the bugs we have recieved due to the -setup package which had (d)evolved from its initial intent. There is nothing groundbreaking here, and the end result should just be that there is less confusion when one wants to get lxc up and running in an image. These changes were tested thoroughly with 'cgroup-lite', 'lxc' and optionally 'lxc-networking' packages added to core-image-minimal when either sysvinit or systemd is in use.
Mark Asselstine
--
_______________________________________________
meta-virtualization mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/meta-virtualization
Signature · 2 lines
"Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end"