nfs-server.service needs name resolution and network online
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
nfs-utils (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned | ||
Bionic |
Confirmed
|
Undecided
|
Unassigned | ||
Focal |
Confirmed
|
Undecided
|
Unassigned | ||
Groovy |
Won't Fix
|
Undecided
|
Unassigned | ||
Hirsute |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
[ Impact ]
nfs-server.service (part of the nfs-utils package) has insufficient dependencies to start correctly in a setting where the NFS exports list contains DNS hostnames (not in local hosts file) or netgroups served via network (for example sssd).
This issue can negatively impact users that, for example, cannot easily resort to using IP addresses directly in the /etc/exports file, and need to use hostnames instead in order to be able to mount NFS shares over the network.
[ Test Case ]
You can reproduce the issue by following the instructions below. Adjust the Ubuntu release on "images:
$ lxc launch images:
$ lxc shell nfs-utils-bug1918141
# apt update
# apt install -y nfs-kernel-server
# mkdir /testshare
# cat >> /etc/exports << EOF
/testshare ubuntu.
EOF
# systemctl edit --full systemd-
You will have to:
- Comment out the "Wants=" line.
- Remove "network.target" from the "Before=" line.
- Add a new "After=
- Add a new "Wants=
- Add the following line in the "[Service]" section:
ExecStartPre=
# systemctl edit --force --full fakenet.service
This new service file will contain:
[Unit]
Description=Fake network.target
DefaultDependen
After=systemd-
Before=
Conflicts=
Wants=network.
[Service]
Type=oneshot
ExecStart=/bin/true
[Install]
WantedBy=
# systemctl enable fakenet.service
# systemctl disable systemd-resolved
# systemctl mask systemd-resolved
# rm /etc/resolv.conf
# cat > /etc/resolv.conf << EOF
nameserver 8.8.8.8
EOF
# reboot
After a few seconds, you can enter the VM again:
$ lxc shell nfs-utils-bug1918141
# sleep 20 && systemctl status nfs-server.service
● nfs-server.service - NFS server and services
Loaded: loaded (/lib/systemd/
Active: active (exited) since Tue 2021-03-16 20:51:42 UTC; 39s ago
Process: 310 ExecStartPre=
Process: 311 ExecStart=
Main PID: 311 (code=exited, status=0/SUCCESS)
Mar 16 20:51:41 nfs-utils-bug1918141 systemd[1]: Starting NFS server and services...
Mar 16 20:51:41 nfs-utils-bug1918141 exportfs[310]: exportfs: Failed to resolve ubuntu.com
Mar 16 20:51:41 nfs-utils-bug1918141 exportfs[310]: exportfs: Failed to resolve ubuntu.com
Mar 16 20:51:42 nfs-utils-bug1918141 systemd[1]: Finished NFS server and services.
As you can see, the service was started but exportfs failed to resolve the hostname.
[Where problems could occur]
This fix has been applied upstream for quite a while now, and is even part of a release, so it has been extensively tested by users and other distributions that have more recent nfs-utils. I cannot easily envision problems with the proposed changes but:
* If the user has manually modified the nfs-server.service file without taking proper precautions (i.e., editin the file directly on /lib/systemd/
[ Original Description ]
nfs-server.service has insufficient dependencies to start correctly in a setting where the nfs exports list contains DNS host names (not in local hosts file) or netgroups served via network (for example sssd).
Typical failures listed by systemctl status nfs-server.service are:
Mar 08 14:16:52 server.example.com exportfs[844]: exportfs: Failed to resolve client1.example.com
Mar 08 14:16:52 server.example.com exportfs[844]: exportfs: Failed to resolve client2.example.com
Our workaround is to add the appropriate dependecies in /etc/systemd/
-------
[Unit]
# nfs-server.service runs exportfs on startup, thus we need to be able to
# do host and netgroup lookups which requires network to be online.
After=network-
-------
While nfs-server.service do depend on network.target, that only means that the network has been configured. On physical hardware it can take significantly longer for the network to come online (8+ seconds for our 10G NICs). Also note that we configure static IP:s via systemd-networkd, things might behave differently when using DHCP, network-manager etc. In any case, depending on network.target is almost always wrong, and network-
nss-lookup.target is needed to ensure that DNS resolution works, and nss-user-
It should be noted that this seems to once have been fixed in Ubuntu, but has been lost along the way for quite some time. When googling I find for example https:/
Related branches
- Utkarsh Gupta (community): Approve
- Canonical Server Core Reviewers: Pending requested
-
Diff: 198 lines (+170/-0)4 files modifieddebian/changelog (+11/-0)
debian/patches/lp1918141-use-network-online-target-01.patch (+82/-0)
debian/patches/lp1918141-use-network-online-target-02.patch (+75/-0)
debian/patches/series (+2/-0)
- Utkarsh Gupta (community): Approve
- Canonical Server Core Reviewers: Pending requested
-
Diff: 198 lines (+170/-0)4 files modifieddebian/changelog (+11/-0)
debian/patches/lp1918141-use-network-online-target-01.patch (+82/-0)
debian/patches/lp1918141-use-network-online-target-02.patch (+75/-0)
debian/patches/series (+2/-0)
- Utkarsh Gupta (community): Approve
- Canonical Server Core Reviewers: Pending requested
-
Diff: 198 lines (+170/-0)4 files modifieddebian/changelog (+11/-0)
debian/patches/lp1918141-use-network-online-target-01.patch (+82/-0)
debian/patches/lp1918141-use-network-online-target-02.patch (+75/-0)
debian/patches/series (+2/-0)
- Christian Ehrhardt (community): Needs Information
- Canonical Server: Pending requested
-
Diff: 198 lines (+170/-0)4 files modifieddebian/changelog (+11/-0)
debian/patches/lp1918141-use-network-online-target-01.patch (+82/-0)
debian/patches/lp1918141-use-network-online-target-02.patch (+75/-0)
debian/patches/series (+2/-0)
tags: | added: rls-hh-incoming |
Changed in nfs-utils (Ubuntu): | |
assignee: | nobody → Sergio Durigan Junior (sergiodj) |
description: | updated |
Changed in nfs-utils (Ubuntu Bionic): | |
status: | New → Confirmed |
Changed in nfs-utils (Ubuntu Focal): | |
status: | New → Confirmed |
Changed in nfs-utils (Ubuntu Groovy): | |
status: | New → Confirmed |
Changed in nfs-utils (Ubuntu Bionic): | |
assignee: | nobody → Sergio Durigan Junior (sergiodj) |
Changed in nfs-utils (Ubuntu Groovy): | |
assignee: | nobody → Sergio Durigan Junior (sergiodj) |
Changed in nfs-utils (Ubuntu Focal): | |
assignee: | nobody → Sergio Durigan Junior (sergiodj) |
tags: | added: network-online-ordering |
Changed in nfs-utils (Ubuntu): | |
assignee: | Sergio Durigan Junior (sergiodj) → nobody |
Changed in nfs-utils (Ubuntu Bionic): | |
assignee: | Sergio Durigan Junior (sergiodj) → nobody |
Changed in nfs-utils (Ubuntu Focal): | |
assignee: | Sergio Durigan Junior (sergiodj) → nobody |
Changed in nfs-utils (Ubuntu Groovy): | |
assignee: | Sergio Durigan Junior (sergiodj) → nobody |
Changed in nfs-utils (Ubuntu Hirsute): | |
assignee: | Sergio Durigan Junior (sergiodj) → nobody |
Status changed to 'Confirmed' because the bug affects multiple users.