Bug 860980 - [US2816][fork] Exception is shown while using rhc tail with invalid options
[US2816][fork] Exception is shown while using rhc tail with invalid options
Status: CLOSED CURRENTRELEASE
Product: OpenShift Origin
Classification: Red Hat
Component: Command Line Interface (Show other bugs)
2.x
Unspecified Unspecified
low Severity low
: ---
: ---
Assigned To: chris alfonso
libra bugs
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-09-27 05:10 EDT by joycezhang
Modified: 2016-01-31 21:35 EST (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2012-11-06 13:50:09 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description joycezhang 2012-09-27 05:10:37 EDT
Description of problem:
Exception is shown as below while using rhc tail with an invalid option.
#rhc tail php1 -o '-test'
/usr/local/share/gems/gems/commander-4.1.2/lib/commander/command.rb:169:in `parse_options_and_call_procs': missing argument: -o (OptionParser::MissingArgument)
    from /usr/local/share/gems/gems/commander-4.1.2/lib/commander/command.rb:155:in `run'
    from /usr/local/share/gems/gems/commander-4.1.2/lib/commander/runner.rb:402:in `run_active_command'
    from /usr/local/share/gems/gems/rhc-0.99.2/lib/rhc/command_runner.rb:55:in `run!'
    from /usr/local/share/gems/gems/commander-4.1.2/lib/commander/delegates.rb:11:in `run!'
    from /usr/local/share/gems/gems/rhc-0.99.2/lib/rhc/cli.rb:40:in `start'
    from /usr/local/share/gems/gems/rhc-0.99.2/bin/rhc:57:in `<top (required)>'
    from /usr/local/bin/rhc:23:in `load'
    from /usr/local/bin/rhc:23:in `<main>'

Version-Release number of selected component (if applicable):
fork_ami_openshift_US2814_US22816_160

How reproducible:
always

Steps to Reproduce:
1.Create an app
2.Tail app log with invalid option
#rhc tail php1 -o '-test'
  
Actual results:
Exception as pasted in description is shown.

Expected results:
Noexception shown, but error message "Invalid option" pops up with rhc tail help content shown.
Additional info:
Comment 1 chris alfonso 2012-09-27 09:40:08 EDT
I'm trying to reproduce this and I see different results:

I am testing on RHEL6 with rhc-0.99.3 installed.

[root@domU-12-31-39-16-55-DB ~]# rhc tail test -o '-test'
missing argument: -o

Usage: rhc tail <application>

Tail the logs of an application

Options for tail
  -n, --namespace namespace Namespace of your application
  -o, --opts options        Options to pass to the server-side (linux based) tail command (applicable to tail command only) (-f is implicit.  See the linux tail man page full list of options.) (Ex: --opts
'-n 100')
  -f, --files files         File glob relative to app (default <application_name>/logs/*) (optional)

Global Options
  -l, --rhlogin login       OpenShift login
  -p, --password password   OpenShift password
  -d, --debug               Turn on debugging
  --noprompt                Do not ask for input
  --config FILE             Path of a different config file
  -h, --help                Display help documentation
  -v, --version             Display version information
  -t, --trace               Display backtrace when an error occurs
Comment 2 Xiaoli Tian 2012-09-27 10:22:14 EDT
QE's result may be tested on Fedora17&ruby-1.9 and MacOS&ruby-1.9 and Ubuntu12&ruby-1.8
Comment 3 chris alfonso 2012-09-27 11:01:52 EDT
Okay, I'm able to reproduce the error when I upgrade to version 4.1.2 of the commander gem.
Comment 4 chris alfonso 2012-09-27 13:02:42 EDT
This is a conflict between the registered '-t' trace option and the '-test'.  Option parser sees the (-t)set and stops parsing the option, then thinks the '-o' is missing a value and causes the exception: 

/usr/lib/ruby/1.8/optparse.rb:453:in `parse': missing argument: -o (OptionParser::MissingArgument)
Comment 5 chris alfonso 2012-09-27 16:17:10 EDT
https://github.com/J5/rhc/pull/12

This code is currently in my master and commands-merge-master branch
https://github.com/calfonso/rhc

Once the pull request is processed, J5's fork will have my changes.  Feel free to test the fixes from my fork as well.
Comment 6 Wei Sun 2012-09-28 05:29:35 EDT
verified on devenv_2248, and building  rhc package using repo git@github.com:calfonso/rhc.git

step:
1.Create an app
2.Tail app log with invalid option
rhc tail php1 -o '-x'

Result :

OpenShiftmatoMacBook-Pro:client OpenShift$ rhc tail php1 -o '-x'
Password: *****

/usr/bin/tail: invalid option -- 'x'
Try `/usr/bin/tail --help' for more information.

Note You need to log in before you can comment on or make changes to this bug.