Bug 1031973

Summary: mount.glusterfs exits with code 0 even after failure.
Product: [Community] GlusterFS Reporter: badpazzword
Component: scriptsAssignee: Niels de Vos <ndevos>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: high Docs Contact:
Priority: high    
Version: 3.2.7CC: bturner, bugs, dshetty, gluster-bugs, ndevos, nlevinki, vbellur
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: All   
URL: http://lists.gnu.org/archive/html/gluster-devel/2014-04/msg00069.html
Whiteboard:
Fixed In Version: glusterfs-3.6.0beta1 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1086421 (view as bug list) Environment:
Last Closed: 2014-11-11 08:24:43 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:    
Bug Blocks: 1086421    

Description badpazzword 2013-11-19 09:35:23 UTC
Description of problem: mount.glusterfs does not set the exit code when the mount fails.

How reproducible: always.

Steps to Reproduce:
0. Set up gluster on localhost, volume gv0
1. `mkdir -p /mnt/gluster`
2. `mount -t glusterfs bogus:volume /mnt/gluster/`
3. `rmdir /mnt/gluster`
4. `mount -t glusterfs localhost:gv0 /mnt/gluster/`

Actual results:

The mount at step 4 exits with a generic use message instead of complaining about the non-existing mount point. Exit code is 0 although the mount failed.

The mount at step 2 exits without any error message and the error code is 0. The only way to realize that the mount failed is to check /etc/mtab.

Expected results:

Mount failures are reported to stderr and the error code is set properly on failure.

Comment 1 Deepak C Shetty 2014-04-08 11:19:01 UTC
Additional info

 [stack@devstack-vm cinder]$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 9.9G 3.7G 6.1G 38% /
devtmpfs 2.0G 0 2.0G 0% /dev
tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs 2.0G 448K 2.0G 1% /run
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
192.168.122.252:/opt/stack/nfs/brick 9.9G 3.7G 6.1G 38% /opt/stack/data/cinder/mnt/f23011fcca5ae3a8b8ebfd7e4af2e190

[stack@devstack-vm cinder]$ sudo mount -t nfs 192.168.122.252:/opt/stack/nfs/brick /opt/stack/data/cinder/mnt/f23011fcca5ae3a8b8ebfd7e4af2e190/
mount.nfs: /opt/stack/data/cinder/mnt/f23011fcca5ae3a8b8ebfd7e4af2e190 is busy or already mounted
[stack@devstack-vm cinder]$ echo $?
32
NOTE: mount.nfs exits w/ proper error code

[stack@devstack-vm ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 9.9G 3.7G 6.1G 38% /
devtmpfs 2.0G 0 2.0G 0% /dev
tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs 2.0G 448K 2.0G 1% /run
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
devstack-vm.localdomain:/gvol1 9.9G 3.7G 6.1G 38% /opt/stack/data/cinder/mnt/d45ccec4f1572f6f242b70befa3d80fe
devstack-vm.localdomain:/gvol2 9.9G 3.7G 6.1G 38% /opt/stack/data/cinder/mnt/413c1f8d14058d5b2d07f8a92814bd12

[stack@devstack-vm ~]$ sudo mount -t glusterfs devstack-vm.localdomain:/gvol1 /opt/stack/data/cinder/mnt/d45ccec4f1572f6f242b70befa3d80fe/
/sbin/mount.glusterfs: according to mtab, GlusterFS is already mounted on /opt/stack/data/cinder/mnt/d45ccec4f1572f6f242b70befa3d80fe
[stack@devstack-vm ~]$ echo $?
0
NOTE: mount.glusterfs exits with 0 (success)

More details @ http://lists.gnu.org/archive/html/gluster-devel/2014-04/msg00069.html

Comment 2 Ben Turner 2014-04-08 16:37:10 UTC
This also exists in RHS, tested on the latest 3.5 build.

Comment 5 Niels de Vos 2014-04-10 20:47:25 UTC
(In reply to Ben Turner from comment #2)
> This also exists in RHS, tested on the latest 3.5 build.

Please do not butcher community Gluster bugs and move them to other products. Changes filed to fix this in the community sources need a Gluster bug, not an RHS one. Thanks!

Comment 6 Anand Avati 2014-04-10 20:51:31 UTC
REVIEW: http://review.gluster.org/7441 (mount.glusterfs: return an error when mounting failed) posted (#1) for review on master by Niels de Vos (ndevos)

Comment 7 Anand Avati 2014-04-12 00:59:06 UTC
COMMIT: http://review.gluster.org/7441 committed in master by Vijay Bellur (vbellur) 
------
commit e73af16885f6d11ebcb225edb4d12214ceeba74c
Author: Niels de Vos <ndevos>
Date:   Thu Apr 10 22:09:53 2014 +0200

    mount.glusterfs: return an error when mounting failed
    
    When mounting fails, mount.glusterfs incorrectly returns 0 for some
    error cases, it should return 1 instead. Also make sure that error
    messages are redirected to /dev/stderr and not printed to stdout.
    
    Unfortunately it is not possible with the current test-scripts to test
    commands like 'mount -t glusterfs ...'. Any mounting of Gluster volumes
    is done directly with the 'glusterfs' command instead.
    
    Change-Id: Ica9d45b6d5ae537de869a1fa0f6c3edab47225d1
    BUG: 1031973
    Signed-off-by: Niels de Vos <ndevos>
    Reviewed-on: http://review.gluster.org/7441
    Reviewed-by: Harshavardhana <harsha>
    Tested-by: Gluster Build System <jenkins.com>
    Reviewed-by: Vijay Bellur <vbellur>

Comment 8 Deepak C Shetty 2014-04-14 09:40:37 UTC
Niels,
    I think the exit code in line 624 (as below) should more aptly be
32 (instead of 1). Per the `man mount` error codes...

  32     mount failure


<code>
warn -n "$0: according to mtab, GlusterFS is already mounted on "
warn "$mount_point"
exit 1;
</code>

thanx,
deepak

Comment 9 Niels de Vos 2014-04-14 10:15:24 UTC
After a short discussion with Deepak, it seems that mount.nfs returns 32 for this error. I'll file a patch for that later.

Comment 10 Anand Avati 2014-04-14 10:41:59 UTC
REVIEW: http://review.gluster.org/7469 (mount.glusterfs: return 32 in case of double mounting) posted (#1) for review on master by Niels de Vos (ndevos)

Comment 11 Anand Avati 2014-04-17 18:28:41 UTC
COMMIT: http://review.gluster.org/7469 committed in master by Vijay Bellur (vbellur) 
------
commit 36ae3edd207bf173ba4d106024368df4c0d18c7e
Author: Niels de Vos <ndevos>
Date:   Mon Apr 14 12:36:50 2014 +0200

    mount.glusterfs: return 32 in case of double mounting
    
    The mount.nfs helper returns 32 for this particular error case. It makes
    sense for mount.glusterfs to return the same error value.
    
    Change-Id: I628f4c93bc796bb096e91857195ffd3d296eaae9
    BUG: 1031973
    Reported-by: Deepak C Shetty <deepakcs>
    Signed-off-by: Niels de Vos <ndevos>
    Reviewed-on: http://review.gluster.org/7469
    Tested-by: Gluster Build System <jenkins.com>
    Reviewed-by: Vijay Bellur <vbellur>

Comment 12 Niels de Vos 2014-09-22 12:32:50 UTC
A beta release for GlusterFS 3.6.0 has been released. Please verify if the release solves this bug report for you. In case the glusterfs-3.6.0beta1 release does not have a resolution for this issue, leave a comment in this bug and move the status to ASSIGNED. If this release fixes the problem for you, leave a note and change the status to VERIFIED.

Packages for several distributions should become available in the near future. Keep an eye on the Gluster Users mailinglist [2] and the update (possibly an "updates-testing" repository) infrastructure for your distribution.

[1] http://supercolony.gluster.org/pipermail/gluster-users/2014-September/018836.html
[2] http://supercolony.gluster.org/pipermail/gluster-users/

Comment 13 Niels de Vos 2014-11-11 08:24:43 UTC
This bug is getting closed because a release has been made available that should address the reported issue. In case the problem is still not fixed with glusterfs-3.6.1, please reopen this bug report.

glusterfs-3.6.1 has been announced [1], packages for several distributions should become available in the near future. Keep an eye on the Gluster Users mailinglist [2] and the update infrastructure for your distribution.

[1] http://supercolony.gluster.org/pipermail/gluster-users/2014-November/019410.html
[2] http://supercolony.gluster.org/mailman/listinfo/gluster-users