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

--zpool-status fails to handle the spares section of zpool status #569

Open
macourteau opened this issue May 10, 2024 · 2 comments
Open
Labels
bug Something isn't working ready-to-ship

Comments

@macourteau
Copy link

This zpool status output can't be parsed by jc:

  pool: tank
 state: ONLINE
  scan: scrub repaired 0B in <snip>
config:

	NAME        STATE     READ WRITE CKSUM
	tank        ONLINE       0     0     0
	  mirror-0  ONLINE       0     0     0
	    sdh     ONLINE       0     0     0
	    sdk     ONLINE       0     0     0
	  mirror-1  ONLINE       0     0     0
	    sdl     ONLINE       0     0     0
	    sdj     ONLINE       0     0     0
	  mirror-2  ONLINE       0     0     0
	    sdn     ONLINE       0     0     0
	    sdm     ONLINE       0     0     0
	  mirror-3  ONLINE       0     0     0
	    sdg     ONLINE       0     0     0
	    sdi     ONLINE       0     0     0
	spares
	  sdf       AVAIL

errors: No known data errors

If I remove the spares section, however, jc is able to parse it correctly.

Specifically, this is the error I'm getting:

Traceback (most recent call last):
  File "/opt/homebrew/bin/jc", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/jc/cli.py", line 965, in main
    JcCli().run()
  File "/opt/homebrew/lib/python3.11/site-packages/jc/cli.py", line 947, in run
    self._run()
  File "/opt/homebrew/lib/python3.11/site-packages/jc/cli.py", line 911, in _run
    self.standard_parse_and_print()
  File "/opt/homebrew/lib/python3.11/site-packages/jc/cli.py", line 803, in standard_parse_and_print
    self.create_normal_output()
  File "/opt/homebrew/lib/python3.11/site-packages/jc/cli.py", line 755, in create_normal_output
    self.data_out = self.parser_module.parse(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/jc/parsers/zpool_status.py", line 251, in parse
    pool_obj['config'] = _build_config_list(pool_obj['config'])
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/jc/parsers/zpool_status.py", line 186, in _build_config_list
    config_obj['state'] = line_list[1]
                          ~~~~~~~~~^^^
IndexError: list index out of range
@kellyjonbrazil
Copy link
Owner

Thank you for reporting this! It looks like an easy fix - I'll just make the columnar data optional. I'll get this into the dev branch this weekend.

@kellyjonbrazil kellyjonbrazil added the bug Something isn't working label May 10, 2024
@kellyjonbrazil
Copy link
Owner

This is fixed in the dev branch and will make it into the next release.

https://github.com/kellyjonbrazil/jc/blob/dev/jc/parsers/zpool_status.py

You can test by copying the parser file above into your parser plugin folder:

  • Linux/unix: $HOME/.local/share/jc/jcparsers
  • macOS: $HOME/Library/Application Support/jc/jcparsers
  • Windows: $LOCALAPPDATA\jc\jc\jcparsers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ready-to-ship
Projects
None yet
Development

No branches or pull requests

2 participants