ziomon_util: Unexpected return code

Bug #1616596 reported by John George
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ubuntu on IBM z Systems
Fix Released
Low
bugproxy
s390-tools (Ubuntu)
Fix Released
Low
Dimitri John Ledkov

Bug Description

$ lsb_release -rd
Description: Ubuntu 16.04 LTS
Release: 16.04

$ apt-cache policy s390-tools
s390-tools:
  Installed: 1.34.0-0ubuntu8.1
  Candidate: 1.34.0-0ubuntu8.1

When benign options such as --help or --version are passed to ziomon_util the expected output is printed but the return code is non-zero. The unexpected return code is shown here:
    ubuntu@s5lp1-gen01:~$ ziomon_util --help
    Usage: ziomon_util [-h] [-v] [-V] [-i n] [-s n] [-Q <msgq_path> -q <msgq_id>
                       -m <msg_id>] -d n -a <n> -l <lun>

    Start the monitor for the host adapter utilization.
    Example: ziomon_util -d 60 -i 4 -a 0

    -h, --help Print usage information and exit.
    -v, --version Print version information and exit.
    -V, --verbose Be verbose.
    -s, --sample-length Duration between each sample in seconds.
                          Defaults to 2 seconds.
    -i, --interval-length Aggregate samples over this duration (in seconds).
                          Defaults to 'duration'.
    -d, --duration Overall duration in seconds.
    -a, --adapter Host adapter no. to watch. Specify each host adapter
                          separately.
    -l, --lun watch I/O error count of LUN. Specify each LUN
                          separately in h:b:t:l format.
    -Q, --msg-queue-name Specify the message queue path name.
    -q, --msg-queue-id Specify the message queue id.
    -m, --msg-id Specify the message id to use.
    -L, --msg-id-ioerr Specify the message id for I/O error count messages.
    ubuntu@s5lp1-gen01:~$ echo $?
    255

    ubuntu@s5lp1-gen01:~$ ziomon_util --version
    ziomon_util: ziomon utilization monitor, version 1.34.0-build-20160609
    Copyright IBM Corp. 2008
    ubuntu@s5lp1-gen01:~$ echo $?
    255

Frank Heimes (fheimes)
tags: added: s390x
Frank Heimes (fheimes)
Changed in s390-tools (Ubuntu):
status: New → Confirmed
Frank Heimes (fheimes)
Changed in ubuntu-z-systems:
status: New → Confirmed
importance: Undecided → Medium
assignee: nobody → bugproxy (bugproxy)
bugproxy (bugproxy)
tags: added: architecture-s39064 bugnameltc-145884 severity-medium targetmilestone-inin16041
Revision history for this message
bugproxy (bugproxy) wrote : Comment bridged from LTC Bugzilla

------- Comment From <email address hidden> 2016-09-05 10:21 EDT-------
Why is the return code of --help or --version a problem?

If anything this would be of utmost low prio on my list.
The important thing is that the tool does work; I've been using it successfully a lot recently.

tags: added: severity-low
removed: severity-medium
Revision history for this message
bugproxy (bugproxy) wrote :

------- Comment From <email address hidden> 2016-09-06 08:39 EDT-------
(In reply to comment #5)
> Why is the return code of --help or --version a problem?
>
> If anything this would be of utmost low prio on my list.

Hi Steffen, please have a look at the attached patch.

Thanks
Michael

Revision history for this message
bugproxy (bugproxy) wrote : 0001-ziomon-Use-exit-code-0-for-version-and-help.patch

------- Comment on attachment From <email address hidden> 2016-09-06 08:39 EDT-------

[PATCH] ziomon: Use exit code 0 for --version and --help

Besides of this also unify the exit codes for help in case of wrong
number of parameters:

 # /usr/sbin/ziomon_util
 Usage: ziomon_util [-h] [-v] [-V] [-i n] [-s n] [-Q <msgq_path> ...
 # echo $?
 255

 # /usr/sbin/ziomon_mgr
   Usage: ziomon_util [-h] [-v] [-V] [-i n] [-s n] [-Q <msgq_path> ...
 # echo $?
 0

With this patch we use exit code 1 (EXIT_FAILURE) in this case:

 # ./ziomon_util
 Usage: ziomon_util [-h] [-v] [-V] [-i n] [-s n] [-Q <msgq_path> ...
 # echo $?
 1

Signed-off-by: Michael Holzheu <email address hidden>

Changed in s390-tools (Ubuntu):
status: Confirmed → In Progress
assignee: nobody → Dimitri John Ledkov (xnox)
Changed in s390-tools (Ubuntu):
status: In Progress → Fix Committed
Revision history for this message
bugproxy (bugproxy) wrote :

------- Comment on attachment From <email address hidden> 2016-09-06 08:39 EDT-------

[PATCH] ziomon: Use exit code 0 for --version and --help

Besides of this also unify the exit codes for help in case of wrong
number of parameters:

 # /usr/sbin/ziomon_util
 Usage: ziomon_util [-h] [-v] [-V] [-i n] [-s n] [-Q <msgq_path> ...
 # echo $?
 255

 # /usr/sbin/ziomon_mgr
   Usage: ziomon_util [-h] [-v] [-V] [-i n] [-s n] [-Q <msgq_path> ...
 # echo $?
 0

With this patch we use exit code 1 (EXIT_FAILURE) in this case:

 # ./ziomon_util
 Usage: ziomon_util [-h] [-v] [-V] [-i n] [-s n] [-Q <msgq_path> ...
 # echo $?
 1

Signed-off-by: Michael Holzheu <email address hidden>

Frank Heimes (fheimes)
Changed in ubuntu-z-systems:
status: Confirmed → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package s390-tools - 1.36.1-0ubuntu2

---------------
s390-tools (1.36.1-0ubuntu2) yakkety; urgency=medium

  * Fix exit codes. LP: #1616596

 -- Dimitri John Ledkov <email address hidden> Thu, 15 Sep 2016 13:05:09 +0100

Changed in s390-tools (Ubuntu):
status: Fix Committed → Fix Released
Revision history for this message
bugproxy (bugproxy) wrote : Comment bridged from LTC Bugzilla

------- Comment From <email address hidden> 2016-09-15 09:48 EDT-------
FYI: The patch in attachment 111971 has neither been reviewed nor accepted so far, so no guarantees this will ever go upstream like that.

I'm still interested in an answer to my question:
Why is the return code of --help or --version a problem?

Frank Heimes (fheimes)
Changed in ubuntu-z-systems:
status: Fix Committed → Fix Released
Revision history for this message
Dimitri John Ledkov (xnox) wrote :

@ maier

Is code review for s390-tools public? E.g. on github?

Revision history for this message
Frank Heimes (fheimes) wrote :

It's not a problem per-se, but the tool should behave like other tools.
That makes basic tests and automated test (for example in CI environments) much more straight-forward ...

Revision history for this message
bugproxy (bugproxy) wrote :

------- Comment From <email address hidden> 2016-09-15 10:24 EDT-------
Why are (automated) tests of unimportant tool options important?
What matters is that it properly reports performance data and that is what we should focus on IMO.

------- Comment From <email address hidden> 2016-09-15 10:25 EDT-------
s390-tools code review is IBM internal.

Revision history for this message
bugproxy (bugproxy) wrote :

------- Comment From <email address hidden> 2016-09-15 10:30 EDT-------
(In reply to comment #9)
> FYI: The patch in attachment 111971 [details] has neither been reviewed nor
> accepted so far, so no guarantees this will ever go upstream like that.
>
> I'm still interested in an answer to my question:
> Why is the return code of --help or --version a problem?

An error code != 0 signals that the operation failed.

One (perhaps not very realistic?) example:

If a script parses the version string of the tool to find out which features are supported and checks if the --version option worked or not.

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

These types of tests originate from the uptick of DEP-8 autopkgtests.

Whilst trivial in their nature they have been catching over time:
- miss compilation
- shared libary ABI breaks
- executables segfaulting before they get to showing version/help
- getting unexpected sigbus
- and similar.

Whilst highly unlikely to catch serious bugs, these tests are cheap enough that when they do catch trivial bugs, they usually prevent the OMG the whole distro is on fire. Thus the rewards are well worth the trivial effort / CI cost. Infamous anecdote is upload of libgcc1 in devel series that did not ship libgcc_s.so.1...

A similar test for pkg-config files is that installing -dev package, and linking with a pkg-config generated includes for an empty file with just includes should work. In practice it didn't, as hundreds of -dev packages lacked the right dependencies on other -dev packages.

References:
http://autopkgtest.ubuntu.com/statistics

http://packaging.ubuntu.com/html/auto-pkg-test.html

Frank Heimes (fheimes)
Changed in ubuntu-z-systems:
importance: Medium → Low
Revision history for this message
bugproxy (bugproxy) wrote :

------- Comment From <email address hidden> 2017-11-07 12:08 EDT-------
We have provided a new solution for this bug. Please, find it in master branch of s390-tools with this link:
https://github.com/ibm-s390-tools/s390-tools/commit/69199219bc89d28d06df4f6b3b0d0ca8279efada

Mathew Hodson (mhodson)
Changed in s390-tools (Ubuntu):
importance: Undecided → Low
bugproxy (bugproxy)
tags: added: targetmilestone-inin1804
removed: targetmilestone-inin16041
Revision history for this message
bugproxy (bugproxy) wrote :

------- Comment From <email address hidden> 2018-01-25 07:03 EDT-------
IBM Bugzilla status -> closed, verified with bionic s390tools-2.2.0.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.