salt icon indicating copy to clipboard operation
salt copied to clipboard

partition.mkpart doesn't work without fstype making it useless to create partitions without filesystem

Open monofumado opened this issue 7 years ago • 4 comments

Description of Issue

The module partition.mkpart doesn't work without fstype making it useless to create partitions without filesystem (needed for example for LVM)

Steps to Reproduce Issue

call partition.mkpart without giving a fstype always return the error "Invalid fs_type passed to partition.mkpart"

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

In the code fstype is initialized to None, but then is checked against _is_fstype before checking if it's not None, which results in returning always and error

if not _is_fstype(fs_type):
        raise CommandExecutionError(
            'Invalid fs_type passed to partition.mkpart'
        )

monofumado avatar Sep 11 '19 10:09 monofumado

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.

stale[bot] avatar Jan 07 '20 22:01 stale[bot]

Thank you for updating this issue. It is no longer marked as stale.

stale[bot] avatar Jan 08 '20 13:01 stale[bot]

Bumped today into this as well. saltstack version 3000.1 The problem is where bug reporter showed.

I think condition should read:

if fs_type and not _is_fstype(fs_type):

as to reflect also the condition further down in the code.

Note that the documentation also gives an example without a fs_type parameter.

cr1st1p avatar Apr 06 '20 10:04 cr1st1p

Yeah, looking at the code for this in 2018.3 (https://github.com/saltstack/salt/blob/v2018.3.3/salt/modules/parted.py#L443) and here in 3000.1, whoever made the changes, they removed to test to see if fs_type is even defined.

It should be updated to how @cr1st1p stated in the comment above. I tested the change locally. So should be a very simple fix for someone to add back in fs_type and to this module.

robertpenberthy avatar Apr 14 '20 00:04 robertpenberthy