Bug 1820523

Summary: exportfs fails to 'monitor' path that contains symlinks
Product: Red Hat Enterprise Linux 8 Reporter: Oyvind Albrigtsen <oalbrigt>
Component: resource-agentsAssignee: Oyvind Albrigtsen <oalbrigt>
Status: CLOSED ERRATA QA Contact: cluster-qe <cluster-qe>
Severity: medium Docs Contact:
Priority: medium    
Version: 8.2CC: agk, cfeist, cluster-maint, cluster-qe, fdinitto, jruemker, mjuricek, nwahl, ofamera, phagara
Target Milestone: rc   
Target Release: 8.3   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: resource-agents-4.1.1-54.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1601950 Environment:
Last Closed: 2020-11-04 02:19: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:
Bug Depends On: 1601950    
Bug Blocks:    

Description Oyvind Albrigtsen 2020-04-03 09:40:50 UTC
+++ This bug was initially created as a clone of Bug #1601950 +++

== Description of problem:
exportfs fails to 'monitor' exports path that contains symlinks.

== Version-Release number of selected component (if applicable):
resource-agents-3.9.5-124.el7.x86_64 (RHEL 7.5)
nfs-utils-1.3.0-0.54.el7.x86_64 (RHEL 7.5)

== How reproducible:
Always

== Steps to Reproduce:
1. Create path for export
  # mkdir -p /exports/test
2. Create symlink for the exported path
  # ln -s /exports/test /exports/something
3. Create group with 'nfsserver' resource
  # pcs resource create nfs-server nfsserver --group nfsgroup
4. Add 'exportfs' cluster resource that will export the path defined by symlink (/exports/something) to this group
  # pcs resource create nfsexport_something exportfs clientspec="*" directory=/exports/something fsid=1 --group nfsgroup

== Actual results:
nfsexport_something 'start' succeeds. First 'monitor' of nfsexport_something fails. Resource is restarted and fails in same way repeatedly.

# /var/log/cluster/corosync.log
...
Jul 17 15:39:01 [1542] fvm-rhel-52       lrmd:     info: log_execute:       executing - rsc:nfsexport_something action:start call_id:230
exportfs(nfsexport_something)[10453]:   2018/07/17_15:39:01 INFO: Directory /exports/something is not exported to * (stopped).
exportfs(nfsexport_something)[10453]:   2018/07/17_15:39:01 INFO: Exporting file system ...
exportfs(nfsexport_something)[10453]:   2018/07/17_15:39:01 INFO: exportfs: No file systems exported! exporting *:/exports/something
exportfs(nfsexport_something)[10453]:   2018/07/17_15:39:01 WARNING: rmtab backup /exports/something/.rmtab not found or not readable.
exportfs(nfsexport_something)[10453]:   2018/07/17_15:39:01 INFO: File system exported
Jul 17 15:39:01 [1542] fvm-rhel-52       lrmd:     info: log_finished:      finished - rsc:nfsexport_something action:start call_id:230 pid:10453 exit-code:0 exec-time:233ms queue-time:0ms
...
exportfs(nfsexport_something)[10529]:   2018/07/17_15:39:01 INFO: Directory /exports/something is not exported to * (stopped).
...

# exportfs
/exports/test   <world>

== Expected results:
nfsexport_something is properly started and works.

== Current workaround:
Don't use path containing symlinks for 'directory' attribute of 'exportfs' resource agent.

== Additional info:
The issue seems to be that 'exportfs' resource agent relies on the output from 'exportfs' command
that resolves all paths containing symlinks to paths without symlinks and that is provided in output of 'exportfs'.
Note: the resolved path is provided only in the 'exportfs' command when asking which paths are exported. During the
"add of the export path" the same verbatim path provided as parameter is used so we can't tell if the path got changed
during the add of the exported path.

Attached to this BZ is path with proposed fix for the 'exportfs' resource agent from resource-agents-3.9.5-124.el7.x86_64 package
that uses 'readlink' to resolve the path provided to resource agent into path that is then shown by the 'exportfs' command.

Note that this patch will not work with upstream version of 'exportfs' resource agent which has ability to export multiple
directories specified in the 'directory' attribute separated by space. Most probably the check could be implemented there
in 'forall' function where 'directory' attribute is being enumerated and it executes operations on one directory only.
https://github.com/ClusterLabs/resource-agents/blob/master/heartbeat/exportfs#L202

=== resource-agents-3.9.5-124.el7.x86_64
# pcs resource debug-start nfsexport_something
Operation start for nfsexport_something (ocf:heartbeat:exportfs) returned 0
 >  stderr: INFO: Directory /exports/something is not exported to * (stopped).
 >  stderr: INFO: Exporting file system ...
 >  stderr: INFO: exportfs: No file systems exported! exporting *:/exports/something
 >  stderr: WARNING: rmtab backup /exports/something/.rmtab not found or not readable.
 >  stderr: INFO: File system exported
# exportfs
/exports/test   <world>
# pcs resource debug-monitor nfsexport_something
Error performing operation: Argument list too long
Operation monitor for nfsexport_something (ocf:heartbeat:exportfs) returned 7
 >  stderr: INFO: Directory /exports/something is not exported to * (stopped).
# pcs resource debug-stop nfsexport_something
Operation stop for nfsexport_something (ocf:heartbeat:exportfs) returned 0
 >  stderr: INFO: Directory /exports/something is not exported to * (stopped).
 >  stderr: DEBUG: /exports/something not exported
# exportfs
/exports/test   <world>

== patched version resource-agents-3.9.5-124.el7.x86_64
[root@fvm-rhel-7-3-53 ~]# pcs resource debug-start nfsexport_something
Operation start for nfsexport_something (ocf:heartbeat:exportfs) returned 0
 >  stderr: DEBUG: Resolved path without symlinks: /exports/test
 >  stderr: INFO: Directory /exports/test is not exported to * (stopped).
 >  stderr: INFO: Exporting file system ...
 >  stderr: INFO: exportfs: No file systems exported! exporting *:/exports/test
 >  stderr: WARNING: rmtab backup /exports/test/.rmtab not found or not readable.
 >  stderr: INFO: File system exported
# exportfs
/exports/test   <world>
# pcs resource debug-monitor nfsexport_something
Operation monitor for nfsexport_something (ocf:heartbeat:exportfs) returned 0
 >  stderr: DEBUG: Resolved path without symlinks: /exports/test
# pcs resource debug-stop nfsexport_something
Operation stop for nfsexport_something (ocf:heartbeat:exportfs) returned 0
 >  stderr: DEBUG: Resolved path without symlinks: /exports/test
 >  stderr: INFO: Un-exporting file system ...
 >  stderr: INFO: unexporting *:/exports/test
 >  stderr: INFO: Un-exported file system
# exportfs
(empty output)

Comment 1 Patrik Hagara 2020-04-03 09:44:10 UTC
qa_ack+, reproducer in description

Comment 2 Oyvind Albrigtsen 2020-05-05 12:24:16 UTC
https://github.com/ClusterLabs/resource-agents/pull/1492

Comment 10 errata-xmlrpc 2020-11-04 02:19: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 (Low: resource-agents security and bug fix 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/RHSA-2020:4605