LXC container fails to create

Full error message from creation page :

.. failed to start : lxc-start: confile.c: config_network_ipv4: 835 File exists - invalid ipv4 address: / lxc-start: parse.c: lxc_file_for_each_line: 57 Failed to parse config: lxc.network.ipv4 = / lxc-start: tools/lxc_start.c: main: 284 Failed to create lxc_container

And actually the network line looks like : lxc.network.ipv4 = /

Which is of course wrong ! Fixing it manually solves the issue and container starts properly.

The network was set to automatically assign an adress in creation page, this system runs others KVM and network is ok, IP ranges are assigned.

Status: 
Active

Comments

Unfortunately this bug is still present, reproduced it on a new Centos7 physical host I just set up :(

Any idea for a fix please ?

Ilia's picture
Submitted by Ilia on Tue, 08/25/2020 - 08:15

Assigned: Unassigned »

Unfortunately this bug is still present, reproduced it on a new Centos7 physical host I just set up :(

Do you have an IP range defined at LXC Host Systems/Edit LXC Host/IP address allocation ranges? I double checked and if those IPs are set, one of the allocated and free IPs are correctly passed to the config upon LXC container creation, at least in my case (Ubuntu 20.04 used as a host system). What if you manually define and IP address upon LXC system creation at Host and networking options tab under IP address for LXC container option?

Jamie, I ran few tests and it also fails for me with a bit different error:

Starting up new LXC container ..
.. failed to start : lxc-start: debug-dedicated-centos7-lxc.cloudmin.local: confile.c: set_config_net: 281 lxc.net must not have a value lxc-start: debug-dedicated-centos7-lxc.cloudmin.local: parse.c: lxc_file_for_each_line_mmap: 120 Failed to parse config file "/var/lib/lxc/debug-dedicated-centos7-lxc.cloudmin.local/config" at line "lxc.network.type = veth" Failed to load config for debug-dedicated-centos7-lxc.cloudmin.local lxc-start: debug-dedicated-centos7-lxc.cloudmin.local: tools/lxc_start.c: main: 242 Failed to create lxc_container

If I ran lxc-ls -l DEBUG -f it returns:

lxc-ls: confile.c: set_config_net: 281 lxc.net must not have a value
lxc-ls: parse.c: lxc_file_for_each_line_mmap: 120 Failed to parse config file "/var/lib/lxc/debug-dedicated-centos7-lxc.cloudmin.local/config" at line "lxc.network.type = veth"
Failed to load config for debug-dedicated-centos7-lxc.cloudmin.local

.. it's worth mentioning that this exact output is appended to .../console file, making it look broken, like this:

~# cat /var/lib/lxc/debug-dedicated-centos7-lxc.cloudmin.local/console
lxc-start: debug-dedicated-centos7-lxc.cloudmin.local: confile.c: set_config_net: 281 lxc.net must not have a value
lxc-start: debug-dedicated-centos7-lxc.cloudmin.local: parse.c: lxc_file_for_each_line_mmap: 120 Failed to parse config file "/var/lib/lxc/debug-dedicated-centos7-lxc.cloudmin.local/config" at line "lxc.network.type = veth"
Failed to load config for debug-dedicated-centos7-lxc.cloudmin.local
lxc-start: debug-dedicated-centos7-lxc.cloudmin.local: tools/lxc_start.c: main: 242 Failed to create lxc_container

Ilia's picture
Submitted by Ilia on Tue, 08/25/2020 - 08:43

Oh, it seems that console file is used exactly to store this kind of output..

Anyway, I think the source of the bug is a change in LXC. As of LXC 3.0 legacy config keys are not supported anymore (removed).

Looking at default config at /etc/lxc/default.conf displays:

~# cat /etc/lxc/default.conf
lxc.net.0.type = veth
lxc.net.0.link = lxcbr0
lxc.net.0.flags = up
lxc.net.0.hwaddr = 00:16:3e:xx:xx:xx

.. while we are using older lxc.network directives.

If I fix manually container's config at /var/lib/lxc/debug-dedicated-centos7-lxc.cloudmin.local/config, changing it from:

lxc.network.type = veth
lxc.network.flags = up
lxc.network.link = br0
lxc.network.name = eth0
lxc.network.ipv4 = 192.168.2.75/24
lxc.network.mtu = 1500
lxc.network.hwaddr = 4e:a9:5e:0F:8C:80
lxc.network.veth.pair = veth1
lxc.net.0.link = lxcbr0
lxc.net.0.hwaddr = 00:16:3e:cc:18:12
lxc.net.0.flags = up
lxc.utsname = debug-dedicated-centos7-lxc.cloudmin.local
#lxc.include = /usr/share/lxc/config/nesting.conf
lxc.net.0.type = veth
lxc.rootfs.path = dir:/var/lib/lxc/debug-dedicated-centos7-lxc.cloudmin.local/root

.. to:

lxc.net.0.type = veth
lxc.net.0.flags = up
lxc.net.0.link = br0
lxc.net.0.name = eth0
lxc.net.0.ipv4.address = 192.168.2.75/24
lxc.net.0.mtu = 1500
lxc.net.0.hwaddr = 4e:a9:5e:0F:8C:80
lxc.net.0.veth.pair = veth1
lxc.net.0.link = lxcbr0
lxc.net.0.hwaddr = 00:16:3e:cc:18:12
lxc.net.0.flags = up
#lxc.utsname = debug-dedicated-centos7-lxc.cloudmin.local
#lxc.include = /usr/share/lxc/config/nesting.conf
lxc.net.0.type = veth
lxc.rootfs.path = dir:/var/lib/lxc/debug-dedicated-centos7-lxc.cloudmin.local/root

.. then I could start it from Cloudmin with no problem and command lxc-ls -l DEBUG -f returns no error and prints as expected:

NAME                                       STATE   AUTOSTART GROUPS IPV4         IPV6 UNPRIVILEGED 
debug-dedicated-centos7-lxc.cloudmin.local RUNNING 0         -      192.168.2.75 -    false

I assume the fix could be straight forward, unless there were no older versions of LXC to support?

@lorelin You can easily use lxc-update-config -c mylxcconfig command to update an old config to a new one.

Lovely Illia, thanks a lot ! will the latest Cloudmin/Virtualmin version able to handle the new LXC 3.0 config directives ?

For now it I read you correctly the path to get a functional LXC container on a LXC3.0 host is a run a normal guest deployment and then run lxc-update-config -c mylxcconfig is it right ?

Ilia's picture
Submitted by Ilia on Thu, 08/27/2020 - 11:06

is it right ?

Yes, it will update old style LXC configs, generated by current version of Cloudmin, to something LXC 3.0 can deal with.

Ok, now we have a workaround for LXC 3.0, which is great, but my initial issue is still here : On LXC 2 hosts, the network configuration is broken and ends up with a / instead of any IP address which breaks lxc.

Starting up new LXC container ..
.. failed to start : lxc-start: confile.c: config_network_ipv4: 838 File exists - invalid ipv4 address: / lxc-start: parse.c: lxc_file_for_each_line: 57 Failed to parse config: lxc.network.ipv4 = / lxc-start: tools/lxc_start.c: main: 284 Failed to create lxc_container 
<blockcode>
And yes triple-checked and I have a network range assigned to each host on which I tried this.
Another issue is it keeps using br0 as LXC bridge, whatever setting I use on default or at LXC creation time. Even if br0 does not exist on the host !
 
This is quite nasty since most Cloudmin-supported host OSes runs LXC2 :(
 
Manually fixing the network config allows the container to run but this is not the point of using an automated provisionning tool ;)
Any fix please ?
Ilia's picture
Submitted by Ilia on Tue, 09/01/2020 - 07:14

Which distro does it happen on?

Latest try I had was on CentOS 7 with the LXC 2 upgrade but it does the same with Devuan ASCII (Debian 9).

Ilia's picture
Submitted by Ilia on Tue, 09/01/2020 - 09:07

I will deploy more physical installs with for Cloudmin testing. It will take some time though.