Bug 860980 - [US2816][fork] Exception is shown while using rhc tail with invalid options
Summary: [US2816][fork] Exception is shown while using rhc tail with invalid options
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: OKD
Classification: Red Hat
Component: oc
Version: 2.x
Hardware: Unspecified
OS: Unspecified
low
low
Target Milestone: ---
: ---
Assignee: chris alfonso
QA Contact: libra bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-09-27 09:10 UTC by joycezhang
Modified: 2016-02-01 02:35 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-11-06 18:50:09 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description joycezhang 2012-09-27 09:10:37 UTC
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 13:40:08 UTC
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 14:22:14 UTC
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 15:01:52 UTC
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 17:02:42 UTC
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 20:17:10 UTC
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 09:29:35 UTC
verified on devenv_2248, and building  rhc package using repo git: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.