Comment 6 for bug 2054616

Revision history for this message
Mitchell Dzurick (mitchdz) wrote :

I've been playing around with noble and I've noticed that sometimes if I try to restart the service right after boot it will fail

root@n-vm:~# systemctl restart nbd@nbd0
Job for <email address hidden> failed because the control process exited with error code.
See "systemctl status <email address hidden>" and "journalctl -xeu <email address hidden>" for details.
root@n-vm:~# systemctl status nbd@nbd0
× <email address hidden> - NBD client connection for nbd0
     Loaded: loaded (/usr/lib/systemd/system/nbd@.service; enabled; preset: enabled)
     Active: failed (Result: exit-code) since Tue 2024-02-27 23:44:35 UTC; 2s ago
       Docs: man:nbd-client
    Process: 871 ExecStart=//sbin/nbd-client nbd0 (code=exited, status=1/FAILURE)
   Main PID: 871 (code=exited, status=1/FAILURE)
        CPU: 5ms

Feb 27 23:44:35 n-vm systemd[1]: Starting <email address hidden> - NBD client connection for nbd0...
Feb 27 23:44:35 n-vm nbd-client[871]: Negotiation: ..size = 1024MB
Feb 27 23:44:35 n-vm nbd_client[871]: Failed to setup device, check dmesg
Feb 27 23:44:35 n-vm nbd-client[871]: Error: Failed to setup device, check dmesg
Feb 27 23:44:35 n-vm nbd-client[871]: Exiting.
Feb 27 23:44:35 n-vm nbd_client[871]: Exiting.
Feb 27 23:44:35 n-vm systemd[1]: <email address hidden>: Main process exited, code=exited, status=1/FAILURE
Feb 27 23:44:35 n-vm systemd[1]: <email address hidden>: Failed with result 'exit-code'.
Feb 27 23:44:35 n-vm systemd[1]: Failed to start <email address hidden> - NBD client connection for nbd0.
root@n-vm:~# dmesg | tail -n 1
[ 12.032858] nbd: nbd0 already in use

But yeah, it just seems that systemd ignores the start because it doesn't want to wait for the devices:

Feb 27 23:44:31 n-vm systemd[1]: <email address hidden>: Dependency Before=dev-nbd0.device ignored (.device units cannot be delayed)

You can force a start (We should not do this, but just showing for debug) by doing something such as:

# echo "WantedBy=multi-user.target" >> /usr/lib/systemd/system/nbd@.service && systemctl enable nbd@nbd0

But then you see the client fails to start, because the devices are not available at that point.

root@n-vm:~# systemctl status nbd@nbd0
× <email address hidden> - NBD client connection for nbd0
     Loaded: loaded (/usr/lib/systemd/system/nbd@.service; enabled; preset: enabled)
     Active: failed (Result: exit-code) since Tue 2024-02-27 23:48:22 UTC; 1s ago
       Docs: man:nbd-client
    Process: 663 ExecStart=//sbin/nbd-client nbd0 (code=exited, status=1/FAILURE)
   Main PID: 663 (code=exited, status=1/FAILURE)
        CPU: 5ms

Feb 27 23:48:22 n-vm systemd[1]: Starting <email address hidden> - NBD client connection for nbd0...
Feb 27 23:48:22 n-vm nbd_client[663]: Socket failed: Connection refused

I suppose the expectation here is that when you run `systemctl enable nbd@nbd0` that the /dev/nbd* devices should be instantiated at boot and the client should run and use those devices, but the devices are not coming up at boot.

root@n-vm:~# ll /dev/nbd*
ls: cannot access '/dev/nbd*': No such file or directory

The interesting thing I am noticing is that the devices are instantiated after the first restart, so even though you see a failure the first time, restarting it a second time makes everything seem happy.

root@n-vm:~# systemctl restart nbd@nbd0
Job for <email address hidden> failed because the control process exited with error code.
See "systemctl status <email address hidden>" and "journalctl -xeu <email address hidden>" for details.
root@n-vm:~# ll /dev/nbd* | head -n 2
brw-rw---- 1 root disk 43, 0 Feb 27 23:55 /dev/nbd0
brw-rw---- 1 root disk 43, 16 Feb 27 23:54 /dev/nbd1
root@n-vm:~# systemctl restart nbd@nbd0
root@n-vm:~# systemctl status nbd@nbd0
● <email address hidden> - NBD client connection for nbd0
     Loaded: loaded (/usr/lib/systemd/system/nbd@.service; enabled; preset: enabled)
     Active: active (exited) since Tue 2024-02-27 23:55:01 UTC; 4s ago
       Docs: man:nbd-client
    Process: 933 ExecStart=//sbin/nbd-client nbd0 (code=exited, status=0/SUCCESS)
   Main PID: 933 (code=exited, status=0/SUCCESS)
        CPU: 4ms