Bug 1868828 - "nfsdclnts --hostname | head" creates Traceback
Summary: "nfsdclnts --hostname | head" creates Traceback
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: nfs-utils
Version: 32
Hardware: x86_64
OS: Linux
unspecified
low
Target Milestone: ---
Assignee: Steve Dickson
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-08-13 22:44 UTC by Edgar Hoch
Modified: 2021-04-01 01:54 UTC (History)
3 users (show)

Fixed In Version: nfs-utils-2.5.3-1.fc33 nfs-utils-2.5.3-2.rc1.fc34 nfs-utils-2.5.3-1.fc32
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-03-22 01:04:03 UTC
Type: Bug


Attachments (Terms of Use)
nfsdclnts: Ignore SIGPIPE signal (732 bytes, patch)
2021-03-08 11:51 UTC, Kenneth Dsouza
no flags Details | Diff

Description Edgar Hoch 2020-08-13 22:44:29 UTC
Description of problem:
There is an error in parsing arguments of command nfsdclnts.

# nfsdclnts --hostname | head
Inode number | Type   | Access | Deny | Hostname              | Filename
6996086      | open   | r-     | --   | myhostname            | N/A
6996086      | deleg  | r      |      | myhostname            | N/A
8417871      | deleg  | r      |      | myhostname            | N/A
8417903      | deleg  | r      |      | myhostname            | N/A
8417870      | deleg  | r      |      | myhostname            | N/A
8417882      | deleg  | r      |      | myhostname            | N/A
8417889      | deleg  | r      |      | myhostname            | N/A
8417883      | deleg  | r      |      | myhostname            | N/A
7136342      | deleg  | r      |      | myhostname            | N/A
Traceback (most recent call last):
  File "/usr/sbin/nfsdclnts", line 254, in <module>
    nfsd4_show()
  File "/usr/sbin/nfsdclnts", line 246, in nfsd4_show
    printer(item, args)
  File "/usr/sbin/nfsdclnts", line 150, in printer
    print('%-22s' %hostname, end='| ')
BrokenPipeError: [Errno 32] Broken pipe


Version-Release number of selected component (if applicable):
nfs-utils-2.5.1-2.rc3.fc32.x86_64

How reproducible:
Always

Steps to Reproduce:
1. nfsdclnts --hostname | head


Actual results:
Normal output, and Traceback

Expected results:
Normal output

Comment 1 Steve Dickson 2020-11-09 19:07:24 UTC
I'm not seeing this happening in later releases...
Could you please verify?

Comment 2 Edgar Hoch 2020-11-09 19:18:06 UTC
I have tested it on a server with nfs-utils-2.5.1-4.rc4.fc32.x86_64 installed.
The error (with slightly changed line numbers) still occurs.
The server currently runs with kernel 5.8.10-200.fc32.x86_64, I can reboot to a newer kernel and retest if you think it matters.


# nfsdclnts --hostname | head
Inode number | Type   | Access | Deny | Hostname              | Filename
17828777     | open   | rw     | --   | myhostname            | e5c00bcb8e064227a528a9fb14707571-device-volumes.tdb
17828979     | open   | rw     | --   | myhostname            | e5c00bcb8e064227a528a9fb14707571-stream-volumes.tdb
17828981     | open   | rw     | --   | myhostname            | e5c00bcb8e064227a528a9fb14707571-card-database.tdb
17956871     | open   | rw     | --   | myhostname            | index
17825840     | open   | r-     | --   | myhostname            | .nfs00000000011000300000013b
17826013     | open   | rw     | --   | myhostname            | contacts.db
17833398     | open   | r-     | --   | myhostname            | cert9.db
17833398     | deleg  | r      |      | myhostname            | cert9.db
17833402     | open   | r-     | --   | myhostname            | key4.db
Traceback (most recent call last):
  File "/usr/sbin/nfsdclnts", line 254, in <module>
    nfsd4_show()
  File "/usr/sbin/nfsdclnts", line 246, in nfsd4_show
    printer(item, args)
  File "/usr/sbin/nfsdclnts", line 156, in printer
    print(fname)
BrokenPipeError: [Errno 32] Broken pipe

Comment 3 Kenneth Dsouza 2021-03-08 11:43:35 UTC
I am able to reproduce the issue by passing a large states file which would take considerable amount of time to process.
The head binary will close the pipe as soon it has received 10 lines or enough data to process, which would case this issue.

# nfsdclnts -f `pwd`/states --hostname | head
Inode number | Type   | Access | Deny | Hostname              | Filename
201352297    | open   | rw     | --   | linux22passion        | nfstest
201352297    | lock   |        |      | linux22passion        | nfstest
201352297    | open   | rw     | --   | linux22passion        | nfstest
201352297    | lock   |        |      | linux22passion        | nfstest
201352297    | open   | rw     | --   | linux22passion        | nfstest
201352297    | lock   |        |      | linux22passion        | nfstest
201352297    | open   | rw     | --   | linux22passion        | nfstest
201352297    | lock   |        |      | linux22passion        | nfstest
201352297    | open   | rw     | --   | linux22passion        | nfstest
Traceback (most recent call last):
  File "/usr/sbin/nfsdclnts", line 254, in <module>
    nfsd4_show()
  File "/usr/sbin/nfsdclnts", line 246, in nfsd4_show
    printer(item, args)
  File "/usr/sbin/nfsdclnts", line 150, in printer
    print('%-22s' %hostname, end='| ')
BrokenPipeError: [Errno 32] Broken pipe

The below patch should fix the issue, as most python binaries follow similar approach, example dnf.
With this patch we ignore SIGPIPE signal.

# git diff
diff --git a/tools/nfsdclnts/nfsdclnts.py b/tools/nfsdclnts/nfsdclnts.py
index 5e7e03c2..b7280f2c 100755
--- a/tools/nfsdclnts/nfsdclnts.py
+++ b/tools/nfsdclnts/nfsdclnts.py
@@ -223,6 +223,7 @@ def nfsd4_show():
 
     global verbose
     verbose = False
+    signal.signal(signal.SIGPIPE, signal.SIG_DFL)
     if args.verbose:
         verbose = True

With patch:


# ./nfsdclnts.py -f `pwd`/states --hostname | head
Inode number | Type   | Access | Deny | Hostname              | Filename
201352297    | open   | rw     | --   | linux22passion        | nfstest
201352297    | lock   |        |      | linux22passion        | nfstest
201352297    | open   | rw     | --   | linux22passion        | nfstest
201352297    | lock   |        |      | linux22passion        | nfstest
201352297    | open   | rw     | --   | linux22passion        | nfstest
201352297    | lock   |        |      | linux22passion        | nfstest
201352297    | open   | rw     | --   | linux22passion        | nfstest
201352297    | lock   |        |      | linux22passion        | nfstest
201352297    | open   | rw     | --   | linux22passion        | nfstest

Will soon send the patch upstream for review.

Comment 4 Kenneth Dsouza 2021-03-08 11:51:17 UTC
Created attachment 1761584 [details]
nfsdclnts: Ignore SIGPIPE signal

Comment 5 Fedora Update System 2021-03-16 17:30:51 UTC
FEDORA-2021-d191e54a3c has been submitted as an update to Fedora 32. https://bodhi.fedoraproject.org/updates/FEDORA-2021-d191e54a3c

Comment 6 Fedora Update System 2021-03-16 18:05:24 UTC
FEDORA-2021-e31a53a752 has been submitted as an update to Fedora 34. https://bodhi.fedoraproject.org/updates/FEDORA-2021-e31a53a752

Comment 7 Fedora Update System 2021-03-16 23:30:34 UTC
FEDORA-2021-e31a53a752 has been pushed to the Fedora 34 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2021-e31a53a752`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2021-e31a53a752

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 8 Fedora Update System 2021-03-17 01:41:46 UTC
FEDORA-2021-304625fe43 has been pushed to the Fedora 33 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2021-304625fe43`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2021-304625fe43

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 9 Fedora Update System 2021-03-17 01:50:06 UTC
FEDORA-2021-d191e54a3c has been pushed to the Fedora 32 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2021-d191e54a3c`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2021-d191e54a3c

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 10 Fedora Update System 2021-03-22 01:04:03 UTC
FEDORA-2021-304625fe43 has been pushed to the Fedora 33 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 11 Fedora Update System 2021-03-31 00:15:25 UTC
FEDORA-2021-e31a53a752 has been pushed to the Fedora 34 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 12 Edgar Hoch 2021-03-31 00:23:57 UTC
Thanks for the update. It fixes the bug.

Comment 13 Fedora Update System 2021-04-01 01:54:11 UTC
FEDORA-2021-d191e54a3c has been pushed to the Fedora 32 stable repository.
If problem still persists, 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.