Bug 1031973 - mount.glusterfs exits with code 0 even after failure.
mount.glusterfs exits with code 0 even after failure.
Status: CLOSED CURRENTRELEASE
Product: GlusterFS
Classification: Community
Component: scripts (Show other bugs)
3.2.7
All All
high Severity high
: ---
: ---
Assigned To: Niels de Vos
http://lists.gnu.org/archive/html/glu...
:
Depends On:
Blocks: 1086421
  Show dependency treegraph
 
Reported: 2013-11-19 04:35 EST by badpazzword
Modified: 2014-11-11 03:24 EST (History)
7 users (show)

See Also:
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 03:24:43 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description badpazzword 2013-11-19 04:35:23 EST
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 07:19:01 EDT
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 12:37:10 EDT
This also exists in RHS, tested on the latest 3.5 build.
Comment 5 Niels de Vos 2014-04-10 16:47:25 EDT
(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 16:51:31 EDT
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@redhat.com)
Comment 7 Anand Avati 2014-04-11 20:59:06 EDT
COMMIT: http://review.gluster.org/7441 committed in master by Vijay Bellur (vbellur@redhat.com) 
------
commit e73af16885f6d11ebcb225edb4d12214ceeba74c
Author: Niels de Vos <ndevos@redhat.com>
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@redhat.com>
    Reviewed-on: http://review.gluster.org/7441
    Reviewed-by: Harshavardhana <harsha@harshavardhana.net>
    Tested-by: Gluster Build System <jenkins@build.gluster.com>
    Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Comment 8 Deepak C Shetty 2014-04-14 05:40:37 EDT
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 06:15:24 EDT
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 06:41:59 EDT
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@redhat.com)
Comment 11 Anand Avati 2014-04-17 14:28:41 EDT
COMMIT: http://review.gluster.org/7469 committed in master by Vijay Bellur (vbellur@redhat.com) 
------
commit 36ae3edd207bf173ba4d106024368df4c0d18c7e
Author: Niels de Vos <ndevos@redhat.com>
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@redhat.com>
    Signed-off-by: Niels de Vos <ndevos@redhat.com>
    Reviewed-on: http://review.gluster.org/7469
    Tested-by: Gluster Build System <jenkins@build.gluster.com>
    Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Comment 12 Niels de Vos 2014-09-22 08:32:50 EDT
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 03:24:43 EST
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

Note You need to log in before you can comment on or make changes to this bug.