Bug 1019246

Summary: oo-admin-ctl-app got broken when a cartridge that does not belong to this app is passed in to --cartridge option
Product: OpenShift Online Reporter: Jianwei Hou <jhou>
Component: PodAssignee: Ravi Sankar <rpenta>
Status: CLOSED CURRENTRELEASE QA Contact: libra bugs <libra-bugs>
Severity: low Docs Contact:
Priority: medium    
Version: 2.xCC: rpenta
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:24:08 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 Jianwei Hou 2013-10-15 11:16:12 UTC
Description of problem:
When a cartridge that does not belong to an application is passed in to --cartridge option of oo-admin-ctl-app, the program got broken, the exception is handled by mongoid

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

How reproducible:
Always

Steps to Reproduce:
1. Create a scalable php application
2. Set the multiplier of the application, pass in 'diy-0.1' to the --cartridge option
oo-admin-ctl-app -l jhou -a php1s -c set-multiplier --cartridge diy-0.1 --multiplier 2


Actual results:
The program is broken
[root@ip-10-182-168-224 ~]# oo-admin-ctl-app -l jhou -a php1s -c set-multiplier --cartridge diy-0.1 --multiplier 2
/opt/rh/ruby193/root/usr/share/gems/gems/mongoid-3.0.21/lib/mongoid/finders.rb:96:in `find_by':  (Mongoid::Errors::DocumentNotFound)
Problem:
  Document not found for class ComponentInstance with attributes {:cartridge_name=>"diy-0.1"}.
Summary:
  When calling ComponentInstance.find_by with a hash of attributes, all attributes provided must match a document in the database or this error will be raised.
Resolution:
  Search for attributes that are in the database or set the Mongoid.raise_not_found_error configuration option to false, which will cause a nil to be returned instead of raising this error.
	from /opt/rh/ruby193/root/usr/share/gems/gems/mongoid-3.0.21/lib/mongoid/criteria.rb:731:in `block in method_missing'
	from /opt/rh/ruby193/root/usr/share/gems/gems/mongoid-3.0.21/lib/mongoid/scoping.rb:190:in `with_scope'
	from /opt/rh/ruby193/root/usr/share/gems/gems/mongoid-3.0.21/lib/mongoid/criteria.rb:730:in `method_missing'
	from /opt/rh/ruby193/root/usr/share/gems/gems/mongoid-3.0.21/lib/mongoid/relations/embedded/many.rb:398:in `block in method_missing'
	from /opt/rh/ruby193/root/usr/share/gems/gems/mongoid-3.0.21/lib/mongoid/scoping.rb:190:in `with_scope'
	from /opt/rh/ruby193/root/usr/share/gems/gems/mongoid-3.0.21/lib/mongoid/relations/embedded/many.rb:397:in `method_missing'
	from /usr/sbin/oo-admin-ctl-app:195:in `<main>'


Expected results:
Maybe we should properly handle this exception when a cartridge is not in the component_instances of the application

Additional info:
This is also reproducible when doing start/create and such commands.

Comment 1 Ravi Sankar 2013-11-09 01:42:57 UTC
Fixed in https://github.com/openshift/origin-server/pull/4144

Comment 2 openshift-github-bot 2013-11-09 03:59:10 UTC
Commits pushed to master at https://github.com/openshift/origin-server

https://github.com/openshift/origin-server/commit/313678bb4abaa3c099b716f1804164dc1ca11b60
Bug 1019246 - Handle errors in setting multiplier for the cartridge

https://github.com/openshift/origin-server/commit/2bfe6bb847fe344a6c4f78a834e1d378564dcce2
Merge pull request #4144 from pravisankar/dev/ravi/bug1019246

Merged by openshift-bot

Comment 3 Jianwei Hou 2013-11-11 02:25:32 UTC
Verified on devenv_4016, the exception is handled now.

[root@ip-10-158-73-211 ~]# oo-admin-ctl-app  -l jhou -a php1s -c set-multiplier --cartridge php-5.3 --multiplier 3
Cannot set multiplier factor. Cartridge php-5.3 needs to be a sparse cart.