Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix xfs.py module that can no longer parse output from mkfs.xfs. #60853

Merged
merged 3 commits into from
Sep 27, 2022

Conversation

snichol123
Copy link

@snichol123 snichol123 commented Sep 8, 2021

What does this PR do?

When calling the function 'mkfs' from the xfs.py execution module on rhel 8 this is failing with the following stack trace being returned:

2021-09-08 05:06:19,245 [salt.loaded.int.module.cmdmod:409 ][INFO    ][89296] Executing command 'mkfs.xfs' in directory '/root'
2021-09-08 05:06:21,176 [salt.log.setup   :900 ][ERROR   ][89296] An un-handled exception was caught by salt's global exception handler:
IndexError: tuple index out of range
Traceback (most recent call last):
  File "/usr/bin/salt-call", line 8, in <module>
    sys.exit(salt_call())
  File "/opt/salt/3.7.3/lib64/python3.7/site-packages/salt/scripts.py", line 431, in salt_call
    client.run()
  File "/opt/salt/3.7.3/lib64/python3.7/site-packages/salt/cli/call.py", line 57, in run
    caller.run()
  File "/opt/salt/3.7.3/lib64/python3.7/site-packages/salt/cli/caller.py", line 136, in run
    ret = self.call()
  File "/opt/salt/3.7.3/lib64/python3.7/site-packages/salt/cli/caller.py", line 222, in call
    ret["return"] = func(*args, **kwargs)
  File "<boltons.funcutils.FunctionBuilder-4>", line 2, in mkfs
  File "/opt/salt/3.7.3/lib64/python3.7/site-packages/salt/utils/decorators/acl.py", line 64, in wrapper
    return f(*args, **kwargs)
  File "/opt/salt/3.7.3/lib/python3.7/site-packages/salt/modules/xfs.py", line 492, in mkfs
    return _parse_xfs_info(out["stdout"])
  File "/opt/salt/3.7.3/lib/python3.7/site-packages/salt/modules/xfs.py", line 107, in _parse_xfs_info
    ret[entry[0]] = {"section": entry[(entry[1] != "***" and 1 or 0)]}
IndexError: tuple index out of range

The above stack trace is raised due to the mkfs.xfs command now returning an additional string (Discarding blocks...Done.) which causes the parsing done in _parse_xfs_info to fail

meta-data=/dev/vg00/altvar       isize=512    agcount=4, agsize=1310720 blks
         =                       sectsz=4096  attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=1, rmapbt=0
         =                       reflink=1
data     =                       bsize=4096   blocks=5242880, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
log      =internal log           bsize=4096   blocks=2560, version=2
         =                       sectsz=4096  sunit=1 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
Discarding blocks...Done.

What issues does this PR fix or reference?

Fixes:

Fixes the issue I have described above.

Previous Behavior

2021-09-08 05:06:19,245 [salt.loaded.int.module.cmdmod:409 ][INFO    ][89296] Executing command 'mkfs.xfs' in directory '/root'
2021-09-08 05:06:21,176 [salt.log.setup   :900 ][ERROR   ][89296] An un-handled exception was caught by salt's global exception handler:
IndexError: tuple index out of range
Traceback (most recent call last):
  File "/usr/bin/salt-call", line 8, in <module>
    sys.exit(salt_call())
  File "/opt/salt/3.7.3/lib64/python3.7/site-packages/salt/scripts.py", line 431, in salt_call
    client.run()
  File "/opt/salt/3.7.3/lib64/python3.7/site-packages/salt/cli/call.py", line 57, in run
    caller.run()
  File "/opt/salt/3.7.3/lib64/python3.7/site-packages/salt/cli/caller.py", line 136, in run
    ret = self.call()
  File "/opt/salt/3.7.3/lib64/python3.7/site-packages/salt/cli/caller.py", line 222, in call
    ret["return"] = func(*args, **kwargs)
  File "<boltons.funcutils.FunctionBuilder-4>", line 2, in mkfs
  File "/opt/salt/3.7.3/lib64/python3.7/site-packages/salt/utils/decorators/acl.py", line 64, in wrapper
    return f(*args, **kwargs)
  File "/opt/salt/3.7.3/lib/python3.7/site-packages/salt/modules/xfs.py", line 492, in mkfs
    return _parse_xfs_info(out["stdout"])
  File "/opt/salt/3.7.3/lib/python3.7/site-packages/salt/modules/xfs.py", line 107, in _parse_xfs_info
    ret[entry[0]] = {"section": entry[(entry[1] != "***" and 1 or 0)]}
IndexError: tuple index out of range

New Behavior

/root # salt-call xfs.mkfs device=/dev/vg00/testvol
local:
    ----------
    data:
        ----------
        blocks:
            5242880
        bsize:
            4096
        imaxpct:
            25
        section:
            data
        sunit:
            0
        swidth:
            0 blks
    log:
        ----------
        blocks:
            2560
        bsize:
            4096
        lazy-count:
            1
        section:
            internal log
        sectsz:
            4096
        sunit:
            1 blks
        version:
            2
    meta-data:
        ----------
        agcount:
            4
        agsize:
            1310720 blks
        attr:
            2
        crc:
            1
        finobt:
            1
        isize:
            512
        projid32bit:
            1
        reflink:
            1
        rmapbt:
            0
        section:
            /dev/vg00/testvol
        sectsz:
            4096
        sparse:
            1
    naming:
        ----------
        ascii-ci:
            0
        bsize:
            4096
        ftype:
            1
        section:
            version 2
    realtime:
        ----------
        blocks:
            0
        extsz:
            4096
        rtextents:
            0
        section:
            none
            ```

### Merge requirements satisfied?
**[NOTICE] Bug fixes or features added to Salt require tests.**
<!-- Please review the [test documentation](https://docs.saltproject.io/en/master/topics/tutorials/writing_tests.html) for details on how to implement tests into Salt's test suite. -->
- [ ] Docs
- [ ] Changelog - https://docs.saltproject.io/en/master/topics/development/changelog.html
- [ ] Tests written/updated

### Commits signed with GPG?
Yes/No

Please review [Salt's Contributing Guide](https://docs.saltproject.io/en/master/topics/development/contributing.html) for best practices.

See GitHub's [page on GPG signing](https://help.github.com/articles/signing-commits-using-gpg/) for more information about signing commits with GPG.

@snichol123 snichol123 requested a review from a team as a code owner September 8, 2021 12:50
@snichol123 snichol123 requested review from krionbsd and removed request for a team September 8, 2021 12:50
@Ch3LL Ch3LL added the P1 Priority 1 label Sep 19, 2022
@whytewolf
Copy link
Collaborator

@snichol123 Thank you for the PR, can you add a changelog file for this change?

@Ch3LL
Copy link
Contributor

Ch3LL commented Sep 22, 2022

@whytewolf I went ahead and added a changelog file. Can you review please?

@Ch3LL Ch3LL requested review from whytewolf and removed request for krionbsd September 22, 2022 19:30
@Ch3LL Ch3LL added the Sulfur v3006.0 release code name and version label Sep 22, 2022
@Ch3LL Ch3LL merged commit 740635c into saltstack:master Sep 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-changelog-file P1 Priority 1 Sulfur v3006.0 release code name and version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants