Bug 1343243 - lxc-net.service is not started during boot because of missing /etc/resolv.conf
Summary: lxc-net.service is not started during boot because of missing /etc/resolv.conf
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: lxc
Version: 24
Hardware: x86_64
OS: Linux
unspecified
unspecified
Target Milestone: ---
Assignee: Thomas Moschny
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-06-06 22:28 UTC by Andrej
Modified: 2016-12-14 00:51 UTC (History)
4 users (show)

Fixed In Version: lxc-2.0.6-2.fc25 lxc-2.0.6-2.fc24 lxc-2.0.6-2.fc23
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-12-13 20:27:19 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Andrej 2016-06-06 22:28:35 UTC
Description of problem:
lxc-net.service should provide a bridge device and a dhcp server for linux containers but it fails to start during the boot process thus blocking containers to start.

Version-Release number of selected component (if applicable):
lxc-2.0.0-1.fc24.x86_64
lxc-libs-2.0.0-1.fc24.x86_64
lxc-templates-2.0.0-1.fc24.x86_64

Steps to Reproduce:
1. Install lxc and set-up one container inside of the fresh installation of Fedora 24 (beta/KDE/x64_86);
2. enable lxc-net service (systemctl enable lxc-net.service);
3. make the container starts on boot:
lxc.start.auto = 1
lxc.group = onboot
4. reboot

Actual results:
Jun 06 23:52:35 localhost lxc-net[1082]: dnsmasq: directory /etc/resolv.conf for resolv-file is missing, cannot poll
Jun 06 23:52:35 localhost dnsmasq[1194]: directory /etc/resolv.conf for resolv-file is missing, cannot poll
Jun 06 23:52:35 localhost dnsmasq[1194]: FAILED to start up

Container didn't start because lxc-net.service failed to start up.

Expected results:
To have containers up and running after booting Fedora.

Additional info:
/etc/resolv.conf is created by NetworkManager during the boot sequence (/etc/resolv.conf -> /var/run/NetworkManager/resolv.conf), hence I assume that this is an issue of service ordering in systemd, but I don't see how exactly.
lxc-net.service is waiting for network-online.target and network-online.target
is depending on NetworkManager-wait-online.service, i.e. when NetworkManager is ready.

Comment 1 Andrej 2016-06-06 22:47:02 UTC
I would also note that the machine where I encounter this issue is a laptop which usually acquire network connection after I log in.

Working workaround is to put "NetworkManager.service" as a dependency in lxc-net.service:
[Unit]
After=network-online.target NetworkManager.service

Then it works as expected.

Comment 2 Thomas Moschny 2016-11-29 19:49:41 UTC
In theory, having

  After=network-online.target

should already be enough, to ensure (as the name says) that the network is online.

But (afaict) network-online.target currently only works reliably if systemd-networkd is used.

On the other hand, depending on NetworkManager as you proposed is also not an option, as not everyone is using NM.

So, this is something we cannot fix in lxc. Someone has to repair the network-online.target for NM.

Comment 3 Andrej 2016-12-04 13:01:03 UTC
Can you please explain more what would be expected behaviour of network-online for this case so that I can open a new bug report?

Comment 4 Thomas Moschny 2016-12-04 17:46:19 UTC
So, network-online depends on, and is scheduled after NetworkManager-wait-online (reversely, by setting Before in NM-wait-online). The NM-wait-online service calls /usr/bin/nm-online -s --timeout 30, and the man page says for -s: "Wait for NetworkManager startup to complete, rather than waiting for network connectivity specifically."

To me, this looks reasonable. However, there must be a reason it doesn't work for you. Is NetworkManager-wait-online enabled?

Comment 5 Thomas Moschny 2016-12-04 19:13:14 UTC
Wait, I've read some of the systemd docs again. For network-online to have effect, we might need to add a Wants= dependency to lxc-net.

Also, ignore my comment about NetworkManager-wait-online being enabled, that shouldn't be necessary.

Could you try and see if adding Wants=network-online.target to the [Unit] section of lxc-net helps?

Comment 6 Andrej 2016-12-04 20:15:18 UTC
Yep, that works. Thanks.

Thus, this is my lxc-net.service:

[Unit]
Description=LXC network bridge setup
Wants=network-online.target
Before=lxc.service

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/libexec/lxc/lxc-net start
ExecStop=/usr/libexec/lxc/lxc-net stop

[Install]
WantedBy=multi-user.targe

Comment 7 Fedora Update System 2016-12-05 11:45:31 UTC
lxc-2.0.6-2.fc24 has been submitted as an update to Fedora 24. https://bodhi.fedoraproject.org/updates/FEDORA-2016-b4dd1db1e7

Comment 8 Fedora Update System 2016-12-05 11:45:39 UTC
lxc-2.0.6-2.fc24 has been submitted as an update to Fedora 24. https://bodhi.fedoraproject.org/updates/FEDORA-2016-b4dd1db1e7

Comment 9 Fedora Update System 2016-12-05 11:48:49 UTC
lxc-2.0.6-2.fc25 has been submitted as an update to Fedora 25. https://bodhi.fedoraproject.org/updates/FEDORA-2016-868350fe5a

Comment 10 Fedora Update System 2016-12-05 11:48:55 UTC
lxc-2.0.6-2.fc25 has been submitted as an update to Fedora 25. https://bodhi.fedoraproject.org/updates/FEDORA-2016-868350fe5a

Comment 11 Fedora Update System 2016-12-05 11:51:02 UTC
lxc-2.0.6-2.fc23 has been submitted as an update to Fedora 23. https://bodhi.fedoraproject.org/updates/FEDORA-2016-e5ff0ed40c

Comment 12 Fedora Update System 2016-12-05 11:51:07 UTC
lxc-2.0.6-2.fc23 has been submitted as an update to Fedora 23. https://bodhi.fedoraproject.org/updates/FEDORA-2016-e5ff0ed40c

Comment 13 Fedora Update System 2016-12-06 03:24:15 UTC
lxc-2.0.6-2.fc25 has been pushed to the Fedora 25 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-868350fe5a

Comment 14 Fedora Update System 2016-12-06 03:56:41 UTC
lxc-2.0.6-2.fc23 has been pushed to the Fedora 23 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-e5ff0ed40c

Comment 15 Fedora Update System 2016-12-06 03:59:22 UTC
lxc-2.0.6-2.fc24 has been pushed to the Fedora 24 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-b4dd1db1e7

Comment 16 Fedora Update System 2016-12-13 20:27:19 UTC
lxc-2.0.6-2.fc25 has been pushed to the Fedora 25 stable repository. If problems still persist, please make note of it in this bug report.

Comment 17 Fedora Update System 2016-12-13 22:53:27 UTC
lxc-2.0.6-2.fc24 has been pushed to the Fedora 24 stable repository. If problems still persist, please make note of it in this bug report.

Comment 18 Fedora Update System 2016-12-14 00:51:25 UTC
lxc-2.0.6-2.fc23 has been pushed to the Fedora 23 stable repository. If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.