Bug 1230137

Summary: pool-build a nfs pool will prompt unclear error when target dir exists
Product: Red Hat Enterprise Linux 7 Reporter: yisun
Component: libvirtAssignee: Erik Skultety <eskultet>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.2CC: dyuan, eskultet, pzhang, rbalakri, yanyang, zhwang
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-1.2.17-1.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-11-19 06:41:14 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 yisun 2015-06-10 10:40:59 UTC
Description:
nfs pool-build prompts unclear error when target dir exists


versions:
libvirt-1.2.16-1.el7.x86_64
qemu-kvm-rhev-2.3.0-2.el7.x86_64
kernel-3.10.0-254.el7.x86_64

How reproducible:
100%


Steps:

1.#mkdir /a
2.# cat nfs_pool.xml
<pool type='netfs'>
  <name>nfs_pool</name>
  <capacity unit='bytes'>322122547200</capacity>
  <allocation unit='bytes'>161484570624</allocation>
  <available unit='bytes'>160637976576</available>
  <source>
    <host name='nfs.server.name'/>
    <dir path='/path/to/dir'/>
    <format type='nfs'/>
  </source>
  <target>
    <path>/a</path>
    <permissions>
      <owner>0</owner>
      <group>0</group>
    </permissions>
  </target>
</pool>

3.# virsh pool-define nfs_pool.xml
Pool nfs_pool defined from nfs_pool.xml

4. # virsh pool-build nfs_pool
error: Failed to build pool nfs_pool
error: An error occurred, but the cause is unknown

Expected result:
In step 4:# virsh pool-build nfs_pool
error: Failed to build pool nfs_pool
error: failed to create directory '/a': File exists

Actual result:
message is unclear in step 4


Additional info:
If remove following xml segment,  clear error message will be generated.
<permissions>
      <owner>0</owner>
      <group>0</group>
 </permissions>

Comment 1 Erik Skultety 2015-06-16 14:32:27 UTC
fixed upstream:

commit e9478d9a8b8ab2e4ffe1d7ed06395dd721647d55
Author: Erik Skultety <eskultet>
Date:   Thu Jun 11 10:51:23 2015 +0200

    util: virfile: Fix 'unknown cause' error if NFS mount point creation fails
    
    This happens if user requires creation of a directory with specified
    UID/GID permissions. To accomplish this, we use fork approach and
    set particular UID/GID permissions in child process. However, child
    process doesn't have a valid descriptor to a logfile (this is prohibited
    explicitly) and since parent process doesn't handle negative exit codes from
    child in any way, 'uknown cause' error is returned to the user.
    
    Commit 92d9114e tweaked the way we handle child errors when using fork
    approach to set specific permissions (features originally introduced
    by 98f6f381). The same logic should be used to create directories with
    specified permissions as well.

v1.2.16-189-ge9478d9

Comment 3 Yang Yang 2015-07-07 06:05:54 UTC
I can reproduce it.
Verified with libvirt-1.2.17-1.el7.x86_64

steps
1.# virsh pool-dumpxml netfs
<pool type='netfs'>
  <name>netfs</name>
  <uuid>6bdbf24a-0c5a-4631-b7be-9733dc39f785</uuid>
  <capacity unit='bytes'>0</capacity>
  <allocation unit='bytes'>0</allocation>
  <available unit='bytes'>0</available>
  <source>
    <host name='10.66.4.164'/>
    <dir path='/var/lib/libvirt/images'/>
    <format type='auto'/>
  </source>
  <target>
    <path>/tmp/nfs</path>
    <permissions>
      <mode>0711</mode>
      <owner>0</owner>
      <group>0</group>
      <label>system_u:object_r:nfs_t:s0</label>
    </permissions>
  </target>
</pool>

2. # ll /tmp/nfs
total 0

3. # virsh pool-build netfs
error: Failed to build pool netfs
error: internal error: child failed to create '/tmp/nfs': exit status 17

Comment 5 errata-xmlrpc 2015-11-19 06:41:14 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, 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://rhn.redhat.com/errata/RHBA-2015-2202.html