Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 638326

Summary: [Core]: With no available images, ec2 driver throws a stack trace
Product: [Retired] CloudForms Cloud Engine Reporter: Chris Lalancette <clalance>
Component: deltacloud-coreAssignee: Michal Fojtik <mfojtik>
Status: CLOSED CURRENTRELEASE QA Contact: wes hayutin <whayutin>
Severity: medium Docs Contact:
Priority: low    
Version: 0.3.1CC: cpelland, deltacloud-maint, mmorsi, rananda, sseago, whayutin
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Chris Lalancette 2010-09-28 19:19:55 UTC
Description of problem:
When a user with no available images does a GET /api/images against the ec2 driver, a stack trace is thrown:

NoMethodError - undefined method `item' for nil:NilClass:
 ./lib/deltacloud/drivers/ec2/ec2_driver.rb:132:in `images'
 ./lib/deltacloud/base_driver/base_driver.rb:244:in `call'
 ./lib/deltacloud/base_driver/base_driver.rb:244:in `safely'
 ./lib/deltacloud/drivers/ec2/ec2_driver.rb:131:in `images'
 ./lib/deltacloud/helpers/application_helper.rb:72:in `send'
 ./lib/deltacloud/helpers/application_helper.rb:72:in `filter_all'
 ./server.rb:109
 ./lib/sinatra/rabbit.rb:62:in `instance_eval'
 ./lib/sinatra/rabbit.rb:62:in `GET /api/images'
 /usr/lib/ruby/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:863:in `call'
 /usr/lib/ruby/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:863:in `route'
 /usr/lib/ruby/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:521:in `instance_eval'
 /usr/lib/ruby/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:521:in `route_eval'
 /usr/lib/ruby/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:500:in `route!'
 /usr/lib/ruby/gems/1.8/gems/sinatra-1.0/lib/sinatra/base.rb:497:in `catch'

This is the line of code in the ec2 driver, in the images method:

ec2.describe_images(config).imagesSet.item.each do |image|

I have not confirmed, but my suspicion is that imagesSet returns nil when there are no images defined, and thus we get the stack trace.  We should handle this gracefully and not throw an error, but instead just return 0 images.

Comment 1 Mo Morsi 2010-10-18 17:20:01 UTC
I confirmed that imageSet being null was the problem and sent a patch to the core mailing list.

That being said the only way I could reproduce this through the standard core deployment was to change the default 'owner_id' used in the images query in the ec2 driver to an account which had no images (my ec2 account after I deleted all my images). AFAIK the core REST interface doesn't allow 'user_id' to be passed in via the client and setting 'id' to something invalid yields another error:
 
'Deltacloud::BackendError - Invalid id: "ami-foo"'

Comment 2 Mo Morsi 2011-03-31 19:49:02 UTC
Reassigning to Michal as this is a core issue and i'm not sure if this is valid anymore

Comment 3 Michal Fojtik 2011-04-01 11:39:32 UTC
This one is fixed AFAIK in upcoming deltacloud-core-0.2.0. Stay tuned :)

Comment 4 Chris Lalancette 2011-06-13 21:12:10 UTC
Michal, is this fixed?  I'm fairly certain it is, I just wanted to check with you before closing it.

Chris Lalancette

Comment 5 wes hayutin 2011-06-14 15:39:43 UTC
moving to on_qa for review

Comment 6 wes hayutin 2011-07-08 21:49:27 UTC
hrm.. I suppose I would need an account that has access to no images in ec2.  Any other ways to test this?

Comment 7 Michal Fojtik 2011-07-11 12:04:51 UTC
Hmm I think you should be able to see 'no images' using ?owner_id=0 or something similar.

Comment 8 Michal Fojtik 2011-07-11 12:14:48 UTC
OK I have tried this:

http://localhost:3001/api/images?owner_id=293787749884

I don't have any images registered in Amazon. The result was empty images set in XML. No explosions, errors anything.

Comment 9 Shveta 2011-07-13 09:41:51 UTC
Verified from Michal Fojtik's account

http://localhost:3001/api/images?owner_id=293787749884 

It shows a blank page when no ec2 images are there.

Comment 10 wes hayutin 2011-08-01 20:00:36 UTC
release pending...

Comment 11 wes hayutin 2011-08-01 20:00:45 UTC
release pending...

Comment 12 wes hayutin 2011-08-01 20:00:55 UTC
release pending.. 2

Comment 14 wes hayutin 2011-12-08 13:59:32 UTC
perm close

Comment 15 wes hayutin 2011-12-08 14:02:12 UTC
closing out old bugs