Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Better error message on invalid AMI ID #230

Closed
DamianZaremba opened this issue Feb 24, 2016 · 6 comments · Fixed by #547
Closed

Better error message on invalid AMI ID #230

DamianZaremba opened this issue Feb 24, 2016 · 6 comments · Fixed by #547

Comments

@DamianZaremba
Copy link

If you specify an invalid image_id within the config, running kitchen create results in a stack trace with no useful information as to what the problem is.

It would be useful to have a more meaning message/pre-check to aid in debugging the issue when it arises.

Versions:

  • kitchen-ec2 (0.10.0)
  • kitchen-inspec (0.9.0)
  • kitchen-puppet (1.0.35)
  • kitchen-sync (2.1.0)
  • kitchen-vagrant (0.19.0)
  • test-kitchen (1.4.2)

Log:

~
I, [2016-02-23T20:10:58.347889 #42315] INFO -- Kitchen: -----> Starting Kitchen (v1.4.2)
I, [2016-02-23T20:10:58.416955 #42315] INFO -- Kitchen: -----> Creating ...
E, [2016-02-23T20:11:00.216354 #42315] ERROR -- Kitchen: ------Exception-------
E, [2016-02-23T20:11:00.216386 #42315] ERROR -- Kitchen: Class: Kitchen::ActionFailed
E, [2016-02-23T20:11:00.216401 #42315] ERROR -- Kitchen: Message: Failed to complete #create action: [undefined method []' for nil:NilClass] E, [2016-02-23T20:11:00.216413 #42315] ERROR -- Kitchen: ---Nested Exception--- E, [2016-02-23T20:11:00.216424 #42315] ERROR -- Kitchen: Class: NoMethodError E, [2016-02-23T20:11:00.216434 #42315] ERROR -- Kitchen: Message: undefined method[]' for nil:NilClass
E, [2016-02-23T20:11:00.216445 #42315] ERROR -- Kitchen: ------Backtrace-------
E, [2016-02-23T20:11:00.216455 #42315] ERROR -- Kitchen: /Users/damian/.chefdk/gem/ruby/2.1.0/gems/aws-sdk-resources-2.2.18/lib/aws-sdk-resources/resource.rb:223:in block in add_data_attribute' E, [2016-02-23T20:11:00.216466 #42315] ERROR -- Kitchen: /Users/damian/.chefdk/gem/ruby/2.1.0/gems/kitchen-ec2-0.10.0/lib/kitchen/driver/aws/instance_generator.rb:131:indebug_if_root_device'
E, [2016-02-23T20:11:00.216505 #42315] ERROR -- Kitchen: /Users/damian/.chefdk/gem/ruby/2.1.0/gems/kitchen-ec2-0.10.0/lib/kitchen/driver/aws/instance_generator.rb:119:in block_device_mappings' E, [2016-02-23T20:11:00.216515 #42315] ERROR -- Kitchen: /Users/damian/.chefdk/gem/ruby/2.1.0/gems/kitchen-ec2-0.10.0/lib/kitchen/driver/aws/instance_generator.rb:54:inec2_instance_data'
E, [2016-02-23T20:11:00.216526 #42315] ERROR -- Kitchen: /Users/damian/.chefdk/gem/ruby/2.1.0/gems/kitchen-ec2-0.10.0/lib/kitchen/driver/ec2.rb:288:in submit_server' E, [2016-02-23T20:11:00.216537 #42315] ERROR -- Kitchen: /Users/damian/.chefdk/gem/ruby/2.1.0/gems/kitchen-ec2-0.10.0/lib/kitchen/driver/ec2.rb:192:increate'
E, [2016-02-23T20:11:00.216548 #42315] ERROR -- Kitchen: /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.4.2/lib/kitchen/instance.rb:424:in public_send' E, [2016-02-23T20:11:00.216558 #42315] ERROR -- Kitchen: /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.4.2/lib/kitchen/instance.rb:424:inblock in perform_action'
E, [2016-02-23T20:11:00.216569 #42315] ERROR -- Kitchen: /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.4.2/lib/kitchen/instance.rb:488:in call' E, [2016-02-23T20:11:00.216579 #42315] ERROR -- Kitchen: /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.4.2/lib/kitchen/instance.rb:488:insynchronize_or_call'
E, [2016-02-23T20:11:00.216590 #42315] ERROR -- Kitchen: /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.4.2/lib/kitchen/instance.rb:453:in block in action' E, [2016-02-23T20:11:00.216601 #42315] ERROR -- Kitchen: /opt/chefdk/embedded/lib/ruby/2.1.0/benchmark.rb:279:inmeasure'
E, [2016-02-23T20:11:00.216611 #42315] ERROR -- Kitchen: /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.4.2/lib/kitchen/instance.rb:452:in action' E, [2016-02-23T20:11:00.216622 #42315] ERROR -- Kitchen: /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.4.2/lib/kitchen/instance.rb:424:inperform_action'
E, [2016-02-23T20:11:00.216632 #42315] ERROR -- Kitchen: /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.4.2/lib/kitchen/instance.rb:352:in create_action' E, [2016-02-23T20:11:00.216660 #42315] ERROR -- Kitchen: /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.4.2/lib/kitchen/instance.rb:341:inblock in transition_to'
E, [2016-02-23T20:11:00.216672 #42315] ERROR -- Kitchen: /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.4.2/lib/kitchen/instance.rb:340:in each' E, [2016-02-23T20:11:00.216682 #42315] ERROR -- Kitchen: /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.4.2/lib/kitchen/instance.rb:340:intransition_to'
E, [2016-02-23T20:11:00.216693 #42315] ERROR -- Kitchen: /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.4.2/lib/kitchen/instance.rb:127:in create' E, [2016-02-23T20:11:00.216703 #42315] ERROR -- Kitchen: /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.4.2/lib/kitchen/command.rb:176:inpublic_send'
E, [2016-02-23T20:11:00.216722 #42315] ERROR -- Kitchen: /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.4.2/lib/kitchen/command.rb:176:in `block (2 levels) in run_action'
E, [2016-02-23T20:11:00.216735 #42315] ERROR -- Kitchen: ----------------------

@cheeseprocedure
Copy link

I ran into this when an old trusty64 AMI ami-810f20eb stopped being publicly accessible on ~Feb 16-17.

This issue appears to be reproducible by specifying an AMI which exists, but is inaccessible to your IAM credentials.

Specifying a non-existent AMI or a badly-formatted AMI results in helpful feedback, e.g.:

>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: Failed to complete #create action: [The image id '[ami-aaaaaaaa]' does not exist]
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: Failed to complete #create action: [Invalid id: "ami-415f6d2x"]
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration

@grv87
Copy link

grv87 commented Mar 16, 2018

Now all errors during instance launch give a message about wrong image_id.
My case:

...
       Waited 185/1800s for instance <i-0b9ccf35fec67d555> to become ready.                                                     
       Waited 0/1800s for instance <i-0b9ccf35fec67d555> to fetch windows admin password.                                       
       Retrieved Windows password for instance <i-0b9ccf35fec67d555>.                                                           
       EC2 instance <i-0b9ccf35fec67d555> ready (hostname: ec2-34-245-116-97.eu-west-1.compute.amazonaws.com).                  
>>>>>> ------Exception-------                                                                                                   
>>>>>> Class: Kitchen::ActionFailed                                                                                             
>>>>>> Message: 2 actions failed.                                                                                               
>>>>>>     Failed to complete #create action: [Neither image_id nor an image_search specified for instance BuildToolset-UbuntuServer-16044+amd64-amazon! Please specify one or the other.] on BuildToolset-UbuntuServer-16044+amd64-amazon
>>>>>>     Failed to complete #create action: [SSL_connect returned=1 errno=0 state=error: bad signature] on BuildToolset-WindowsServer-2016+amd64-amazon
>>>>>> ----------------------                                                                                                   
>>>>>> Please see .kitchen/logs/kitchen.log for more details                                                                    
>>>>>> Also try running `kitchen diagnose --all` for configuration                                                              

Note that AMI was actually found and even launched. Kitchen wrongfully says that Neither image_id nor an image_search specified for instance ...! Please specify one or the other. But the actual problem in my configuration is somewhere else.

Would be good if error messages were consistent.

@cheeseplus
Copy link
Contributor

cheeseplus commented Mar 16, 2018

@grv87 without your kitchen.yml or versions (any more detail) it's hard to say if that's a bad error message or a mis-configuration.

@tas50
Copy link
Member

tas50 commented Aug 11, 2018

I just ran into this one. If you give a bogus AMI in your region you get a pretty useless error. We should figure out how to catch that and return a friendly message:

This is with an invalid AMI for the region I specified:

-----> Cleaning up any prior instances of <default-debian-92>
-----> Destroying <default-debian-92>...
       Finished destroying <default-debian-92> (0m0.00s).
-----> Testing <default-debian-92>
-----> Creating <default-debian-92>...

@tas50
Copy link
Member

tas50 commented Apr 12, 2021

We should improve this with a message like this:

"The AMI ABCXYZ specified cannot be found in the specified region XYZ. Please check this AMI is available in this region."

@nikhil2611
Copy link
Contributor

Hey I debug in this and found out if we are giving any false or invalid AMI, it already pops out the below exception:

-----> Starting Test Kitchen (v2.12.0)
-----> Cleaning up any prior instances of <default-centos-7>
-----> Destroying <default-centos-7>...
       Finished destroying <default-centos-7> (0m0.00s).
-----> Testing <default-centos-7>
-----> Creating <default-centos-7>...
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: 1 actions failed.
>>>>>>     Failed to complete #create action: [Invalid id: "ami-0affd4508a5d2482b"] on default-centos-7
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration

Also, If the AMI does not exist it is throwing below exception.

-----> Starting Test Kitchen (v2.12.0)
-----> Cleaning up any prior instances of <default-centos-7>
-----> Destroying <default-centos-7>...
       Finished destroying <default-centos-7> (0m0.00s).
-----> Testing <default-centos-7>
-----> Creating <default-centos-7>...
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: 1 actions failed.
>>>>>>     Failed to complete #create action: [The image id '[ami-0000aaaa]' does not exist] on default-centos-7
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration

So, Just need to confirm do we need to update this error message(Invalid id: "ami-0affd4508a5d2482b") when the invalid AMI is given to like

"The AMI ABCXYZ specified cannot be found in the specified region XYZ. Please check this AMI is available in this region."

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants