Skip to content

Conversation

@loli10K
Copy link
Contributor

@loli10K loli10K commented Aug 17, 2018

Motivation and Context

Running arcstat.py with an unsupported option does not print the expected error and usage message:

root@linux:/usr/src/zfs# ./cmd/arcstat/arcstat.py -y
Traceback (most recent call last):
  File "./cmd/arcstat/arcstat.py", line 463, in <module>
    main()
  File "./cmd/arcstat/arcstat.py", line 436, in main
    init()
  File "./cmd/arcstat/arcstat.py", line 288, in init
    sys.stderr.write(msg)
TypeError: expected a character buffer object
root@linux:/usr/src/zfs# 

Description

This change allows the arcstat.py script to handle unsupported options gracefully and print both error and usage messages when one such option is provided:

root@linux:/usr/src/zfs# ./cmd/arcstat/arcstat.py -y
Error: option -y not recognized
Usage: arcstat.py [-hvx] [-f fields] [-o file] [-s string] [interval [count]]

	 -h : Print this help message
	 -v : List all possible field headers and definitions
	 -x : Print extended stats
	 -f : Specify specific fields to print (see -v)
	 -o : Redirect output to the specified file
	 -s : Override default field separator with custom character or string

Examples:
	arcstat.py -o /tmp/a.log 2 10
	arcstat.py -s "," -o /tmp/a.log 2 10
	arcstat.py -v
	arcstat.py -f time,hit%,dh%,ph%,mh% 1

root@linux:/usr/src/zfs# 

How Has This Been Tested?

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (a change to man pages or other documentation)

Checklist:

  • My code follows the ZFS on Linux code style requirements.
  • I have updated the documentation accordingly.
  • I have read the contributing document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • All commit messages are properly formatted and contain Signed-off-by.
  • Change has been approved by a ZFS on Linux member.

This change allows the arcstat.py script to handle unsupported options
gracefully and print both error and usage messages when one such option
is provided.

Signed-off-by: loli10K <ezomori.nozomu@gmail.com>
@codecov
Copy link

codecov bot commented Aug 18, 2018

Codecov Report

Merging #7799 into master will decrease coverage by 0.12%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #7799      +/-   ##
==========================================
- Coverage   78.32%   78.19%   -0.13%     
==========================================
  Files         373      373              
  Lines      112791   112791              
==========================================
- Hits        88341    88197     -144     
- Misses      24450    24594     +144
Flag Coverage Δ
#kernel 78.47% <ø> (-0.06%) ⬇️
#user 66.85% <ø> (-0.67%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 802715b...6acddd7. Read the comment docs.

@behlendorf behlendorf merged commit 1f87313 into openzfs:master Aug 18, 2018
@behlendorf behlendorf added the Status: Accepted Ready to integrate (reviewed, tested) label Aug 18, 2018
tonyhutter pushed a commit to tonyhutter/zfs that referenced this pull request Aug 28, 2018
This change allows the arcstat.py script to handle unsupported options
gracefully and print both error and usage messages when one such option
is provided.

Reviewed-by: Giuseppe Di Natale <guss80@gmail.com>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: loli10K <ezomori.nozomu@gmail.com>
Closes openzfs#7799
tonyhutter pushed a commit to tonyhutter/zfs that referenced this pull request Aug 30, 2018
This change allows the arcstat.py script to handle unsupported options
gracefully and print both error and usage messages when one such option
is provided.

Reviewed-by: Giuseppe Di Natale <guss80@gmail.com>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: loli10K <ezomori.nozomu@gmail.com>
Closes openzfs#7799
tonyhutter pushed a commit to tonyhutter/zfs that referenced this pull request Sep 5, 2018
This change allows the arcstat.py script to handle unsupported options
gracefully and print both error and usage messages when one such option
is provided.

Reviewed-by: Giuseppe Di Natale <guss80@gmail.com>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: loli10K <ezomori.nozomu@gmail.com>
Closes openzfs#7799
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Status: Accepted Ready to integrate (reviewed, tested)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants