Bug 2173777

Summary: nvmet.service starts too soon and fails
Product: Red Hat Enterprise Linux 8 Reporter: Stuart Anderson <anderson>
Component: nvmetcliAssignee: Maurizio Lombardi <mlombard>
Status: CLOSED ERRATA QA Contact: Zhang Yi <yizhan>
Severity: medium Docs Contact:
Priority: high    
Version: 8.7CC: yizhan
Target Milestone: rcKeywords: Triaged
Target Release: ---Flags: pm-rhel: mirror+
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: nvmetcli-0.7-5.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-11-14 15:47:19 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Stuart Anderson 2023-02-27 23:52:05 UTC
Description of problem:

nvmet.service from nvmetcli starts too soon and fails.
 
Version-Release number of selected component (if applicable):

nvmetcli-0.7-3.el8.noarch

How reproducible:

100%

Steps to Reproduce:
1. Configure an NVMe target
2. systemctl enable nvmet.service
3. /sbin/shutdown -r now

Actual results:

[root@zfs5 ~]# systemctl status nvmet
● nvmet.service - Restore NVMe kernel target configuration
   Loaded: loaded (/usr/lib/systemd/system/nvmet.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Sat 2023-02-25 17:18:30 PST; 53s ago
  Process: 2559 ExecStart=/usr/sbin/nvmetcli restore (code=exited, status=1/FAILURE)
 Main PID: 2559 (code=exited, status=1/FAILURE)
      CPU: 65ms

Feb 25 17:18:30 zfs5 nvmetcli[2559]:     Port.setup(self, t, err_func)
Feb 25 17:18:30 zfs5 nvmetcli[2559]:   File "/usr/lib/python3.6/site-packages/nvmet/nvme.py", line 719, in setup
Feb 25 17:18:30 zfs5 nvmetcli[2559]:     port.add_subsystem(s)
Feb 25 17:18:30 zfs5 nvmetcli[2559]:   File "/usr/lib/python3.6/site-packages/nvmet/nvme.py", line 658, in add_subsystem
Feb 25 17:18:30 zfs5 nvmetcli[2559]:     raise CFSError("Could not symlink %s in configFS: %s" % (nqn, e))
Feb 25 17:18:30 zfs5 nvmetcli[2559]: nvmet.nvme.CFSError: Could not symlink zfs5 in configFS: [Errno 99] Cannot assign requested address: '/sys/kernel/config/n>
Feb 25 17:18:30 zfs5 systemd[1]: nvmet.service: Main process exited, code=exited, status=1/FAILURE
Feb 25 17:18:30 zfs5 systemd[1]: nvmet.service: Failed with result 'exit-code'.
Feb 25 17:18:30 zfs5 systemd[1]: Failed to start Restore NVMe kernel target configuration.
Feb 25 17:18:30 zfs5 systemd[1]: nvmet.service: Consumed 65ms CPU time

Expected results:

[root@zfs5 ~]# systemctl status nvmet
● nvmet.service - Restore NVMe kernel target configuration
   Loaded: loaded (/usr/lib/systemd/system/nvmet.service; enabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/nvmet.service.d
           └─delayfornetwork.conf
   Active: active (exited) since Sat 2023-02-25 17:20:37 PST; 1 day 22h ago
 Main PID: 9349 (code=exited, status=0/SUCCESS)
    Tasks: 0 (limit: 1646336)
   Memory: 0B
      CPU: 0
   CGroup: /system.slice/nvmet.service

Feb 25 17:20:37 zfs5 systemd[1]: Starting Restore NVMe kernel target configuration...
Feb 25 17:20:37 zfs5 systemd[1]: Started Restore NVMe kernel target configuration.


Additional info:

Work around is to configure service to start after network-online.target and not just network.target.

The nvmetcli unit file that fails,

[root@zfs5 ~]# cat /usr/lib/systemd/system/nvmet.service
[Unit]
Description=Restore NVMe kernel target configuration
Requires=sys-kernel-config.mount
After=sys-kernel-config.mount network.target local-fs.target

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/sbin/nvmetcli restore
ExecStop=/usr/sbin/nvmetcli clear
SyslogIdentifier=nvmetcli

[Install]
WantedBy=multi-user.target

The additional constraint that works,

[root@zfs5 ~]# cat /etc/systemd/system/nvmet.service.d/delayfornetwork.conf 
[Unit]
After=network-online.target
Wants=network-online.target


Please consider updating the nvmet.service unit file from network.target to network-online.target.

Comment 9 errata-xmlrpc 2023-11-14 15:47:19 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (nvmetcli bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2023:7084