salt icon indicating copy to clipboard operation
salt copied to clipboard

mount.mount not working if fstype is no used

Open monofumado opened this issue 7 years ago • 1 comments

Description of Issue

When the function mount.mount is called without specifying an fstype it will always return an error in the form of: mount: : can't find in /etc/fstab.

Steps to Reproduce Issue

just call the function mount without specifying the fstype: salt 'minion' mount.mount /mnt /dev/sda2

Versions Report

Salt Version: Salt: 2019.2.0

Dependency Versions: cffi: 1.11.5 cherrypy: Not Installed dateutil: 2.8.0 docker-py: Not Installed gitdb: Not Installed gitpython: Not Installed ioflo: Not Installed Jinja2: 2.10 libgit2: Not Installed libnacl: Not Installed M2Crypto: 0.30.1 Mako: Not Installed msgpack-pure: Not Installed msgpack-python: 0.6.1 mysql-python: Not Installed pycparser: 2.19 pycrypto: 2.6.1 pycryptodome: Not Installed pygit2: Not Installed Python: 3.5.3 (default, Sep 27 2018, 17:25:39) python-gnupg: Not Installed PyYAML: 3.13 PyZMQ: 18.0.2 RAET: Not Installed smmap: Not Installed timelib: Not Installed Tornado: 4.5.3 ZMQ: 4.3.1

System Versions: dist: debian 9.9 locale: UTF-8 machine: x86_64 release: 4.9.0-9-amd64 system: Linux version: debian 9.9

Checking the code both in git and in the version downloaded via pip3 I see the error in the indentation in the version downloaded but not in git Version downloaded mount.py (line 1207)

     args = ''
     if opts is not None:
         lopts = ','.join(opts)
         args = '-o {0}'.format(lopts)
 
     # use of fstype on AIX differs from typical Linux use of -t functionality
     # AIX uses -v vfsname, -t fstype mounts all with fstype in /etc/filesystems
     if 'AIX' in __grains__['os']:
         if fstype:
             args += ' -v {0}'.format(fstype)
     else:
         args += ' -t {0}'.format(fstype)
     cmd = 'mount {0} {1} {2} '.format(args, device, name)

Version in git mount.py (line 1210):

   args = ''
   if opts is not None:
       lopts = ','.join(opts)
       args = '-o {0}'.format(lopts)
     
   if fstype:
       # use of fstype on AIX differs from typical Linux use of -t
       # functionality AIX uses -v vfsname, -t fstype mounts all with
       # fstype in /etc/filesystems
       if 'AIX' in __grains__['os']:
           args += ' -v {0}'.format(fstype)
       else:
           args += ' -t {0}'.format(fstype)
 
   cmd = 'mount {0} {1} {2} '.format(args, device, name)

As you can see the if's are quite different, but the one in the version downloaded is not working because the indentation is wrong and it enters the -t option even if fstype is empty

monofumado avatar Sep 09 '19 13:09 monofumado

@monofumado you're right. This bug is fixed by #51905 and is already in 2019.2.1 branch which will be released soon.

DmitryKuzmenko avatar Sep 10 '19 17:09 DmitryKuzmenko