[lxc-devel] [PATCH] fix systemd lxc-net vs lxc ordering

Serge Hallyn serge.hallyn at ubuntu.com
Mon Jun 29 17:16:04 UTC 2015


Quoting Serge Hallyn (serge.hallyn at ubuntu.com):
> The lxc init job must not start until lxc networking has been
> setup.  This requires lxc-net to have complete, not just
> started.  To that end,
> 
> 1. lxc-net now does its work in ExecPreStart rather than
> ExecStart
> 
> 2. lxc now specifies lxc-net in After, not Wants.  So if lxc-net
> fails, lxc won't start and try to autostart containers.  (If you
> want lxc-net to do nothing, setting USE_LXC_BRIDGE="false" in
> /etc/default/lxc is the way to do that, but lxc-net should still
> run successfully.)
> 
> Signed-off-by: Serge Hallyn <serge.hallyn at ubuntu.com>

self-nack.  From http://www.freedesktop.org/software/systemd/man/systemd.service.html:

"Note that ExecStartPre= may not be used to start long-running processes. All processes forked off by processes invoked via ExecStartPre= will be killed before the next service process is run."

So this won't suffice.

>  config/init/systemd/lxc-net.service.in | 2 +-
>  config/init/systemd/lxc.service.in     | 3 +--
>  2 files changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/config/init/systemd/lxc-net.service.in b/config/init/systemd/lxc-net.service.in
> index 0467c0f..1e3681a 100644
> --- a/config/init/systemd/lxc-net.service.in
> +++ b/config/init/systemd/lxc-net.service.in
> @@ -6,7 +6,7 @@ Before=lxc.service
>  [Service]
>  Type=oneshot
>  RemainAfterExit=yes
> -ExecStart=@LIBEXECDIR@/lxc/lxc-net start
> +ExecStartPre=@LIBEXECDIR@/lxc/lxc-net start
>  ExecStop=@LIBEXECDIR@/lxc/lxc-net stop
>  
>  [Install]
> diff --git a/config/init/systemd/lxc.service.in b/config/init/systemd/lxc.service.in
> index a256141..7d191dc 100644
> --- a/config/init/systemd/lxc.service.in
> +++ b/config/init/systemd/lxc.service.in
> @@ -1,7 +1,6 @@
>  [Unit]
>  Description=LXC Container Initialization and Autoboot Code
> -After=syslog.target network.target
> -Wants=lxc-net.service
> +After=syslog.target network.target lxc-net.service
>  
>  [Service]
>  Type=oneshot
> -- 
> 2.1.4
> 
> _______________________________________________
> lxc-devel mailing list
> lxc-devel at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel


More information about the lxc-devel mailing list