Bug 984481 - Counter-intuitive error message when app creation fails due to incorrect custom cartridge manifest URL
Summary: Counter-intuitive error message when app creation fails due to incorrect cust...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: OpenShift Online
Classification: Red Hat
Component: Pod
Version: 1.x
Hardware: All
OS: All
unspecified
medium
Target Milestone: ---
: ---
Assignee: Rajat Chopra
QA Contact: libra bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-07-15 11:09 UTC by Mikko Karjalainen
Modified: 2013-08-26 06:27 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-08-07 22:55:17 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Mikko Karjalainen 2013-07-15 11:09:43 UTC
Description of problem:

During app creation, when the custom cartridge manifest file fails to download
correctly, OpenShift doesn't always give a clear error message. I
got the following error message from "rch app-create" CLI when
pointing to non-existent manifest URL:

 Creating application 'foobar01' ... 
 Unable to complete the requested operation due to: undefined method `has_key?' for
 #<String:0x00000005e52d88>.
 Reference ID: cbc0f8d12d35b93173b36c5482bd122d

Which is not very helpful. Backtrace points to:

Checking to see if user limit for number of apps has been reached
Reference ID: 32cc9a2d148156f22526e5a1231d0b52 - undefined method `has_key?' for #<String:0x000000063d3460>
  /opt/rh/ruby193/root/usr/share/gems/gems/openshift-origin-common-1.10.3/lib/openshift-origin-common/models/manifest.rb:204:in `initialize'
  /opt/rh/ruby193/root/usr/share/gems/gems/openshift-origin-controller-1.10.4/app/helpers/cartridge_cache.rb:179:in `new'
  /opt/rh/ruby193/root/usr/share/gems/gems/openshift-origin-controller-1.10.4/app/helpers/cartridge_cache.rb:179:in `block in fetch_community_carts'
  /opt/rh/ruby193/root/usr/share/gems/gems/openshift-origin-controller-1.10.4/app/helpers/cartridge_cache.rb:174:in `each'
  /opt/rh/ruby193/root/usr/share/gems/gems/openshift-origin-controller-1.10.4/app/helpers/cartridge_cache.rb:174:in `fetch_community_carts'
  /opt/rh/ruby193/root/usr/share/gems/gems/openshift-origin-controller-1.10.4/app/models/application.rb:147:in `create_app'
  /opt/rh/ruby193/root/usr/share/gems/gems/openshift-origin-controller-1.10.4/app/controllers/applications_controller.rb:103:in `create'
  /opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
  /opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/abstract_controller/base.rb:167:in `process_action'
  /opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/action_controller/metal/rendering.rb:10:in `process_action'
  /opt/rh/ruby193/root/usr/share/gems/gems/actionpack-3.2.8/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
  /opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:481:in `block in _run__1457013512728853074__process_action__150559221371486784__callbacks'
  /opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:215:in `block in _conditional_callback_around_354'
  /opt/rh/ruby193/root/usr/share/gems/gems/openshift-origin-controller-1.10.4/lib/openshift/controller/action_log.rb:34:in `set_logged_request'
  /opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:214:in `_conditional_callback_around_354'
  /opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:403:in `_run__1457013512728853074__process_action__150559221371486784__callbacks'
  /opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:405:in `__run_callback'
  /opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
  /opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:81:in `run_callbacks'
 

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

   Name        : openshift-origin-broker
   Arch        : noarch
   Version     : 1.10.2
   Release     : 1.git.100.a41cebb.el6



How reproducible:

Steps to Reproduce:

$ rhc app-create testapp https://s3-eu-west-1.amazonaws.com/cpg.openshift.cartridges/bugrepro/diy-cart/manifffest.yml

Note: we have our custom installation of OpenShift Origin.


Actual results:

Got following output, which is not very helpful:

The cartridge
'https://s3-eu-west-1.amazonaws.com/cpg.openshift.cartridges/bugrepro/diy-cart/manifffest.yml' will be
downloaded and installed

Application Options
-------------------
  Namespace:  mikko02
  Cartridges: https://s3-eu-west-1.amazonaws.com/cpg.openshift.cartridges/bugrepro/diy-cart/manifffest.yml
  Gear Size:  default
  Scaling:    no

Creating application 'testapp' ... 
Unable to complete the requested operation due to: undefined method `has_key?' for
#<String:0x000000045e5c00>.
Reference ID: a09a4786976f6ba127889a5266a3a8e5


Expected results:

OpenShift should display an error message saying it cannot fetch
the manifest.yml file from the given URL.


Additional info:

I attempt to fetch the manifest file from AWS S3 bucket. Let's
look at the response from AWS:

$ curl https://s3-eu-west-1.amazonaws.com/cpg.openshift.cartridges/bugrepro/diy-cart/manifffest.yml
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId>DB3C707B1F9661DC</RequestId><HostId>f3P1aFLThsAqLYRtFulDbvRx3RptFVTWWsqSn1SlBrGej1e4/RhUy/LdETwdQ+ka</HostId></Error>


Looking at Ruby files, I suspect the response from AWS passes
validate_yaml() function in cartridge_cache.rb. Therefore this
response is taken as manifest.yml text and passed into
initialize() in manifest.rb:

      def initialize(manifest, version=nil, repository_base_path='', check_names=true)

        if File.exist? manifest
          @manifest      = YAML.load_file(manifest)
          @manifest_path = manifest
        else
          @manifest      = YAML.load(manifest)
          @manifest_path = :url
        end

        # Validate and use the provided version, defaulting to the manifest Version key
        raise MissingElementError.new(nil, 'Version') unless @manifest.has_key?('Version')

I suspect YAML.load(manifest) then, as a result of containing
non-conforming YAML string, returns a plain String object, which
don't have .has_key? method.

Comment 1 Rajat Chopra 2013-07-26 21:33:29 UTC
Fixed with rev#2ff4a83dc2fa1d0b6c61223d5d548e8e90f68cec in origin-server.repo!

Comment 2 zhaozhanqi 2013-07-29 06:33:20 UTC
Tested this bug on devenv_3572, when creating one app use the manifest file is not correct.  will show "Invalid manifest file "


[root@dhcp-10-143 openshift]# rhc app-create testapp https://s3-eu-west-1.amazonaws.com/cpg.openshift.cartridges/bugrepro/diy-cart/manifffest.yml
The cartridge 'https://s3-eu-west-1.amazonaws.com/cpg.openshift.cartridges/bugrepro/diy-cart/manifffest.yml' will be downloaded and installed

Application Options
-------------------
  Namespace:  zqd
  Cartridges: https://s3-eu-west-1.amazonaws.com/cpg.openshift.cartridges/bugrepro/diy-cart/manifffest.yml
  Gear Size:  default
  Scaling:    no

Creating application 'testapp' ... Invalid manifest file from url 'https://s3-eu-west-1.amazonaws.com/cpg.openshift.cartridges/bugrepro/diy-cart/manifffest.yml'


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