Bug 1018077

Summary: Fail to show correct match messages when add special character cartridge like "*##" to an exist app
Product: OpenShift Online Reporter: Nan Wei <nwei>
Component: ocAssignee: Jordan Liggitt <jliggitt>
Status: CLOSED CURRENTRELEASE QA Contact: libra bugs <libra-bugs>
Severity: low Docs Contact:
Priority: medium    
Version: 2.xCC: jforrest, jliggitt, nwei, wjiang, wsun, xtian
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-01-24 03:33:42 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Nan Wei 2013-10-11 07:12:46 UTC
Description of problem:
When add invalid cartridge like "*##" to a exist app with the rhc 1.16.0, it reveals some error messages as follow: 
/usr/lib/ruby/gems/1.8/gems/rhc-1.16.0/lib/rhc/cartridge_helpers.rb:54:in `match_cart': invalid regular expression; there's no previous pattern, to which '*' would define cardinality at 3: /\b*##\b/ (RegexpError)
    from /usr/lib/ruby/gems/1.8/gems/rhc-1.16.0/lib/rhc/rest/application.rb:64:in `any?'
    from /usr/lib/ruby/gems/1.8/gems/rhc-1.16.0/lib/rhc/cartridge_helpers.rb:53:in `each'
    from /usr/lib/ruby/gems/1.8/gems/rhc-1.16.0/lib/rhc/cartridge_helpers.rb:53:in `any?'
    from /usr/lib/ruby/gems/1.8/gems/rhc-1.16.0/lib/rhc/cartridge_helpers.rb:53:in `match_cart'
    from /usr/lib/ruby/gems/1.8/gems/rhc-1.16.0/lib/rhc/cartridge_helpers.rb:15:in `check_cartridges'
    from /usr/lib/ruby/gems/1.8/gems/rhc-1.16.0/lib/rhc/cartridge_helpers.rb:15:in `select'
    from /usr/lib/ruby/gems/1.8/gems/rhc-1.16.0/lib/rhc/cartridge_helpers.rb:15:in `check_cartridges'
    from /usr/lib/ruby/gems/1.8/gems/rhc-1.16.0/lib/rhc/cartridge_helpers.rb:9:in `map'
    from /usr/lib/ruby/gems/1.8/gems/rhc-1.16.0/lib/rhc/cartridge_helpers.rb:9:in `check_cartridges'
    from /usr/lib/ruby/gems/1.8/gems/rhc-1.16.0/lib/rhc/commands/cartridge.rb:310:in `cartridge_action'
    from /usr/lib/ruby/gems/1.8/gems/rhc-1.16.0/lib/rhc/commands/cartridge.rb:153:in `stop'
    from /usr/lib/ruby/gems/1.8/gems/rhc-1.16.0/lib/rhc/commands.rb:285:in `send'
    from /usr/lib/ruby/gems/1.8/gems/rhc-1.16.0/lib/rhc/commands.rb:285:in `execute'
    from /usr/lib/ruby/gems/1.8/gems/rhc-1.16.0/lib/rhc/commands.rb:276:in `to_commander'
    from /usr/lib/ruby/gems/1.8/gems/commander-4.0.3/lib/commander/command.rb:180:in `call'
    from /usr/lib/ruby/gems/1.8/gems/commander-4.0.3/lib/commander/command.rb:180:in `call'
    from /usr/lib/ruby/gems/1.8/gems/commander-4.0.3/lib/commander/command.rb:155:in `run'
    from /usr/lib/ruby/gems/1.8/gems/commander-4.0.3/lib/commander/runner.rb:383:in `run_active_command'
    from /usr/lib/ruby/gems/1.8/gems/rhc-1.16.0/lib/rhc/command_runner.rb:73:in `run!'
    from /usr/lib/ruby/gems/1.8/gems/commander-4.0.3/lib/commander/delegates.rb:7:in `run!'
    from /usr/lib/ruby/gems/1.8/gems/rhc-1.16.0/lib/rhc/cli.rb:37:in `start'
    from /usr/lib/ruby/gems/1.8/gems/rhc-1.16.0/bin/rhc:20
    from /usr/bin/rhc:23:in `load'
    from /usr/bin/rhc:23 
But if the Client is  "rhc 1.15.6", it reveals "There are no cartridges that match '*##'".

Version-Release number of selected component (if applicable):
devenv_3885
rhc 1.16.0

How reproducible:
always

Steps to Reproduce:
1. Create a app 
#rhc app create app2 jbossews-1.0.
2. Try to add/stop/reload/start/restart an invalid cartridge to the app
#rhc cartridge add *## -a app2

Actual results:
/usr/lib/ruby/gems/1.8/gems/rhc-1.16.0/lib/rhc/cartridge_helpers.rb:54:in `match_cart': invalid regular expression; there's no previous pattern, to which '*' would define cardinality at 3: /\b*##\b/ (RegexpError)
    from /usr/lib/ruby/gems/1.8/gems/rhc-1.16.0/lib/rhc/rest/application.rb:64:in `any?'
    from /usr/lib/ruby/gems/1.8/gems/rhc-1.16.0/lib/rhc/cartridge_helpers.rb:53:in `each'
    from /usr/lib/ruby/gems/1.8/gems/rhc-1.16.0/lib/rhc/cartridge_helpers.rb:53:in `any?'
    from /usr/lib/ruby/gems/1.8/gems/rhc-1.16.0/lib/rhc/cartridge_helpers.rb:53:in `match_cart'
    from /usr/lib/ruby/gems/1.8/gems/rhc-1.16.0/lib/rhc/cartridge_helpers.rb:15:in `check_cartridges'
    from /usr/lib/ruby/gems/1.8/gems/rhc-1.16.0/lib/rhc/cartridge_helpers.rb:15:in `select'
    from /usr/lib/ruby/gems/1.8/gems/rhc-1.16.0/lib/rhc/cartridge_helpers.rb:15:in `check_cartridges'
    from /usr/lib/ruby/gems/1.8/gems/rhc-1.16.0/lib/rhc/cartridge_helpers.rb:9:in `map'
    from /usr/lib/ruby/gems/1.8/gems/rhc-1.16.0/lib/rhc/cartridge_helpers.rb:9:in `check_cartridges'
    from /usr/lib/ruby/gems/1.8/gems/rhc-1.16.0/lib/rhc/commands/cartridge.rb:310:in `cartridge_action'
    from /usr/lib/ruby/gems/1.8/gems/rhc-1.16.0/lib/rhc/commands/cartridge.rb:153:in `stop'
    from /usr/lib/ruby/gems/1.8/gems/rhc-1.16.0/lib/rhc/commands.rb:285:in `send'
    from /usr/lib/ruby/gems/1.8/gems/rhc-1.16.0/lib/rhc/commands.rb:285:in `execute'
    from /usr/lib/ruby/gems/1.8/gems/rhc-1.16.0/lib/rhc/commands.rb:276:in `to_commander'
    from /usr/lib/ruby/gems/1.8/gems/commander-4.0.3/lib/commander/command.rb:180:in `call'
    from /usr/lib/ruby/gems/1.8/gems/commander-4.0.3/lib/commander/command.rb:180:in `call'
    from /usr/lib/ruby/gems/1.8/gems/commander-4.0.3/lib/commander/command.rb:155:in `run'
    from /usr/lib/ruby/gems/1.8/gems/commander-4.0.3/lib/commander/runner.rb:383:in `run_active_command'
    from /usr/lib/ruby/gems/1.8/gems/rhc-1.16.0/lib/rhc/command_runner.rb:73:in `run!'
    from /usr/lib/ruby/gems/1.8/gems/commander-4.0.3/lib/commander/delegates.rb:7:in `run!'
    from /usr/lib/ruby/gems/1.8/gems/rhc-1.16.0/lib/rhc/cli.rb:37:in `start'
    from /usr/lib/ruby/gems/1.8/gems/rhc-1.16.0/bin/rhc:20
    from /usr/bin/rhc:23:in `load'
    from /usr/bin/rhc:23 

Expected results:
There are no cartridges that match '*##'

Additional info:

Comment 1 Jessica Forrester 2013-11-12 22:05:29 UTC
I can't reproduce this on rhc version 1.16.9, can you re-test and see if you are still able to recreate it.

Comment 2 Nan Wei 2013-11-13 02:36:28 UTC
[weinan@dhcp-65-25 test]$ rhc --version
rhc 1.17.0
[weinan@dhcp-65-25 test]$ rhc app show pl
pl @ http://pl-nweidomain.ose-1107.com.cn/ (uuid: 5282045e37df70e4c2000464)
---------------------------------------------------------------------------
  Domain:     nweidomain
  Created:    Nov 12  6:35 PM
  Gears:      1 (defaults to small)
  Git URL:    ssh://5282045e37df70e4c2000464.com.cn/~/git/pl.git/
  SSH:        5282045e37df70e4c2000464.com.cn
  Deployment: auto (on git push)

  perl-5.10 (Perl 5.10)
  ---------------------
    Gears: Located with jenkins-client-1

  jenkins-client-1 (Jenkins Client)
  ---------------------------------
    Gears:   Located with perl-5.10
    Job URL: https://jk-nweidomain.ose-1107.com.cn/job/pl-build/
[weinan@dhcp-65-25 test]$ rhc cartridge add *## -a pl
/usr/lib/ruby/gems/1.8/gems/rhc-1.17.0/lib/rhc/cartridge_helpers.rb:54:in `match_cart': invalid regular expression; there's no previous pattern, to which '*' would define cardinality at 3: /\b*##\b/ (RegexpError)
	from /usr/lib/ruby/gems/1.8/gems/rhc-1.17.0/lib/rhc/rest/client.rb:506:in `any?'
	from /usr/lib/ruby/gems/1.8/gems/rhc-1.17.0/lib/rhc/cartridge_helpers.rb:53:in `each'
	from /usr/lib/ruby/gems/1.8/gems/rhc-1.17.0/lib/rhc/cartridge_helpers.rb:53:in `any?'
	from /usr/lib/ruby/gems/1.8/gems/rhc-1.17.0/lib/rhc/cartridge_helpers.rb:53:in `match_cart'
	from /usr/lib/ruby/gems/1.8/gems/rhc-1.17.0/lib/rhc/cartridge_helpers.rb:15:in `check_cartridges'
	from /usr/lib/ruby/gems/1.8/gems/rhc-1.17.0/lib/rhc/cartridge_helpers.rb:15:in `select'
	from /usr/lib/ruby/gems/1.8/gems/rhc-1.17.0/lib/rhc/cartridge_helpers.rb:15:in `check_cartridges'
	from /usr/lib/ruby/gems/1.8/gems/rhc-1.17.0/lib/rhc/cartridge_helpers.rb:9:in `map'
	from /usr/lib/ruby/gems/1.8/gems/rhc-1.17.0/lib/rhc/cartridge_helpers.rb:9:in `check_cartridges'
	from /usr/lib/ruby/gems/1.8/gems/rhc-1.17.0/lib/rhc/commands/cartridge.rb:78:in `add'
	from /usr/lib/ruby/gems/1.8/gems/rhc-1.17.0/lib/rhc/commands.rb:285:in `send'
	from /usr/lib/ruby/gems/1.8/gems/rhc-1.17.0/lib/rhc/commands.rb:285:in `execute'
	from /usr/lib/ruby/gems/1.8/gems/rhc-1.17.0/lib/rhc/commands.rb:276:in `to_commander'
	from /usr/lib/ruby/gems/1.8/gems/commander-4.0.3/lib/commander/command.rb:180:in `call'
	from /usr/lib/ruby/gems/1.8/gems/commander-4.0.3/lib/commander/command.rb:180:in `call'
	from /usr/lib/ruby/gems/1.8/gems/commander-4.0.3/lib/commander/command.rb:155:in `run'
	from /usr/lib/ruby/gems/1.8/gems/commander-4.0.3/lib/commander/runner.rb:383:in `run_active_command'
	from /usr/lib/ruby/gems/1.8/gems/rhc-1.17.0/lib/rhc/command_runner.rb:73:in `run!'
	from /usr/lib/ruby/gems/1.8/gems/commander-4.0.3/lib/commander/delegates.rb:7:in `run!'
	from /usr/lib/ruby/gems/1.8/gems/rhc-1.17.0/lib/rhc/cli.rb:37:in `start'
	from /usr/lib/ruby/gems/1.8/gems/rhc-1.17.0/bin/rhc:20
	from /usr/bin/rhc:19:in `load'
	from /usr/bin/rhc:19

It can reproduce this on rhc version 1.17.0.

Comment 3 Nan Wei 2013-11-13 03:06:56 UTC
[weinan@dhcp-65-25 test]$ rhc --version
rhc 1.17.4
[weinan@dhcp-65-25 test]$ rhc cartridge add *## -a pl
/usr/lib/ruby/gems/1.8/gems/rhc-1.17.4/lib/rhc/cartridge_helpers.rb:54:in `match_cart': invalid regular expression; there's no previous pattern, to which '*' would define cardinality at 3: /\b*##\b/ (RegexpError)
	from /usr/lib/ruby/gems/1.8/gems/rhc-1.17.4/lib/rhc/rest/client.rb:506:in `any?'
	from /usr/lib/ruby/gems/1.8/gems/rhc-1.17.4/lib/rhc/cartridge_helpers.rb:53:in `each'
	from /usr/lib/ruby/gems/1.8/gems/rhc-1.17.4/lib/rhc/cartridge_helpers.rb:53:in `any?'
	from /usr/lib/ruby/gems/1.8/gems/rhc-1.17.4/lib/rhc/cartridge_helpers.rb:53:in `match_cart'
	from /usr/lib/ruby/gems/1.8/gems/rhc-1.17.4/lib/rhc/cartridge_helpers.rb:15:in `check_cartridges'
	from /usr/lib/ruby/gems/1.8/gems/rhc-1.17.4/lib/rhc/cartridge_helpers.rb:15:in `select'
	from /usr/lib/ruby/gems/1.8/gems/rhc-1.17.4/lib/rhc/cartridge_helpers.rb:15:in `check_cartridges'
	from /usr/lib/ruby/gems/1.8/gems/rhc-1.17.4/lib/rhc/cartridge_helpers.rb:9:in `map'
	from /usr/lib/ruby/gems/1.8/gems/rhc-1.17.4/lib/rhc/cartridge_helpers.rb:9:in `check_cartridges'
	from /usr/lib/ruby/gems/1.8/gems/rhc-1.17.4/lib/rhc/commands/cartridge.rb:79:in `add'
	from /usr/lib/ruby/gems/1.8/gems/rhc-1.17.4/lib/rhc/commands.rb:285:in `send'
	from /usr/lib/ruby/gems/1.8/gems/rhc-1.17.4/lib/rhc/commands.rb:285:in `execute'
	from /usr/lib/ruby/gems/1.8/gems/rhc-1.17.4/lib/rhc/commands.rb:276:in `to_commander'
	from /usr/lib/ruby/gems/1.8/gems/commander-4.0.3/lib/commander/command.rb:180:in `call'
	from /usr/lib/ruby/gems/1.8/gems/commander-4.0.3/lib/commander/command.rb:180:in `call'
	from /usr/lib/ruby/gems/1.8/gems/commander-4.0.3/lib/commander/command.rb:155:in `run'
	from /usr/lib/ruby/gems/1.8/gems/commander-4.0.3/lib/commander/runner.rb:383:in `run_active_command'
	from /usr/lib/ruby/gems/1.8/gems/rhc-1.17.4/lib/rhc/command_runner.rb:73:in `run!'
	from /usr/lib/ruby/gems/1.8/gems/commander-4.0.3/lib/commander/delegates.rb:7:in `run!'
	from /usr/lib/ruby/gems/1.8/gems/rhc-1.17.4/lib/rhc/cli.rb:37:in `start'
	from /usr/lib/ruby/gems/1.8/gems/rhc-1.17.4/bin/rhc:20
	from /usr/bin/rhc:19:in `load'
	from /usr/bin/rhc:19

Comment 4 Jordan Liggitt 2013-11-13 14:40:16 UTC
Specific to ruby 1.8, will add test and fix

Comment 5 Jordan Liggitt 2013-11-13 16:36:42 UTC
Will merge in https://github.com/openshift/rhc/pull/511

Comment 6 openshift-github-bot 2013-11-13 18:04:33 UTC
Commit pushed to master at https://github.com/openshift/rhc

https://github.com/openshift/rhc/commit/557c8d0e4c71782cab99b7614909fd47d5d3ca95
Fix bug 1018077: Regex-breaking cartridge name search

Comment 7 Nan Wei 2013-11-14 03:00:03 UTC
Version-Release number of selected component (if applicable):
int.openshift.redhat.com
rhc 1.17.5

[weinan@dhcp-65-25 test]$ rhc app create ruby18 ruby-1.8

[weinan@dhcp-65-25 test]$ rhc cartridge add *## -a ruby18
Short Name       Full name
==========       =========
cron-1.4         Cron 1.4
jenkins-client-1 Jenkins Client
mysql-5.1        MySQL 5.1
postgresql-8.4   PostgreSQL 8.4
postgresql-9.2   PostgreSQL 9.2
haproxy-1.4      Web Load Balancer

There are no cartridges that match '*##'.

[weinan@dhcp-65-25 test]$ rhc cartridge add @##~*#####$~~~% -a ruby18
Short Name       Full name
==========       =========
cron-1.4         Cron 1.4
jenkins-client-1 Jenkins Client
mysql-5.1        MySQL 5.1
postgresql-8.4   PostgreSQL 8.4
postgresql-9.2   PostgreSQL 9.2
haproxy-1.4      Web Load Balancer

There are no cartridges that match '@##~*#####$~~~%'.