Bug #4414
open500 error when image cannot be found during host creation
Description
When you define an image in a compute resource, and at the moment of host creation (submit), the image cannot be found on the compute resource, it will just show a 500 error screen "string is not nil", instead of telling you what actually happened.
```
Started POST "/hosts" for 127.0.0.1 at 2014-02-23 08:29:16 +0100
Processing by HostsController#create as */*
Parameters: {"utf8"=>"✓", "authenticity_token"=>"+3dyCyDKUGpJIEtENaYlkhgbVU2bdlg0M+XqY2a8/08=", "host"=>{"name"=>"dlobatog", "hostgroup_id"=>"", "compute_resource_id"=>"24", "environment_id"=>"16", "puppet_proxy_id"=>"", "puppetclass_ids"=>[""], "managed"=>"true", "progress_report_id"=>"[FILTERED]", "type"=>"Host::Managed", "compute_attributes"=>{"flavor_ref"=>"1", "tenant_id"=>"a6a7d70a8b5e4e16ac5e6a158fa53b1b", "security_group"=>"", "network"=>"", "image_ref"=>"dd7454fd-fe16-477f-8d24-590b22011d77"}, "mac"=>"", "domain_id"=>"2", "ip"=>"", "interfaces_attributes"=>{"new_interfaces"=>{"_destroy"=>"false", "type"=>"Nic::Managed", "mac"=>"", "name"=>"", "domain_id"=>"", "ip"=>"", "provider"=>"IPMI"}}, "architecture_id"=>"1", "operatingsystem_id"=>"22", "provision_method"=>"image", "build"=>"1", "medium_id"=>"2", "ptable_id"=>"", "disk"=>"", "root_pass"=>"[FILTERED]", "is_owned_by"=>"", "enabled"=>"1", "model_id"=>"", "comment"=>"", "overwrite"=>"false"}, "capabilities"=>"image"}
Rendering UserData template for dlobatog.localdomain
Revoked old certificates and enabled autosign for UserData
Adding Compute instance for dlobatog.localdomain
failed to create vm: Can not find requested image
Failed to create a compute openstackhome (OpenStack) instance dlobatog.localdomain: Can not find requested image
/home/daniel/workspace/foreman/cleanforeman/app/models/compute_resources/foreman/model/openstack.rb:64:in `rescue in create_vm'
/home/daniel/workspace/foreman/cleanforeman/app/models/compute_resources/foreman/model/openstack.rb:53:in `create_vm'
/home/daniel/workspace/foreman/cleanforeman/app/models/concerns/orchestration/compute.rb:62:in `setCompute'
/home/daniel/workspace/foreman/cleanforeman/app/models/concerns/orchestration.rb:148:in `execute'
/home/daniel/workspace/foreman/cleanforeman/app/models/concerns/orchestration.rb:88:in `block in process'
/home/daniel/workspace/foreman/cleanforeman/app/models/concerns/orchestration.rb:80:in `each'
/home/daniel/workspace/foreman/cleanforeman/app/models/concerns/orchestration.rb:80:in `process'
/home/daniel/workspace/foreman/cleanforeman/app/models/concerns/orchestration.rb:18:in `on_save'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:638:in `_run__2230364410368124623__save__2120439120557390228__callbacks'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:405:in `__run_callback'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:385:in `_run_save_callbacks'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:81:in `run_callbacks'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.16/lib/active_record/callbacks.rb:264:in `create_or_update'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.16/lib/active_record/persistence.rb:84:in `save'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.16/lib/active_record/validations.rb:50:in `save'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.16/lib/active_record/attribute_methods/dirty.rb:22:in `save'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.16/lib/active_record/transactions.rb:259:in `block (2 levels) in save'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.16/lib/active_record/transactions.rb:313:in `block in with_transaction_returning_status'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.16/lib/active_record/transactions.rb:208:in `transaction'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.16/lib/active_record/transactions.rb:311:in `with_transaction_returning_status'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.16/lib/active_record/transactions.rb:259:in `block in save'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.16/lib/active_record/transactions.rb:270:in `rollback_active_record_state!'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.16/lib/active_record/transactions.rb:258:in `save'
/home/daniel/workspace/foreman/cleanforeman/app/models/concerns/foreman/sti.rb:29:in `save_with_type'
/home/daniel/workspace/foreman/cleanforeman/app/controllers/hosts_controller.rb:95:in `create'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/actionpack-3.2.16/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/actionpack-3.2.16/lib/abstract_controller/base.rb:167:in `process_action'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/actionpack-3.2.16/lib/action_controller/metal/rendering.rb:10:in `process_action'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/actionpack-3.2.16/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:527:in `block (3 levels) in run_2880236789093410755__process_action__840605431410591841__callbacks'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:215:in `block in conditional_callback_around_5690'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:326:in `around'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:310:in `_callback_around_837'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:214:in `_conditional_callback_around_5690'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:526:in `block (2 levels) in _run_2880236789093410755__process_action__840605431410591841__callbacks'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:215:in `block in conditional_callback_around_5689'
/home/daniel/workspace/foreman/cleanforeman/app/models/concerns/foreman/thread_session.rb:33:in `clear_thread'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:214:in `_conditional_callback_around_5689'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:415:in `block in _run_2880236789093410755__process_action__840605431410591841__callbacks'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:215:in `block in conditional_callback_around_5688'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:326:in `around'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:310:in `_callback_around_13'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:214:in `_conditional_callback_around_5688'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:414:in `_run_2880236789093410755__process_action__840605431410591841__callbacks'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:405:in `__run_callback'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:81:in `run_callbacks'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/actionpack-3.2.16/lib/abstract_controller/callbacks.rb:17:in `process_action'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/actionpack-3.2.16/lib/action_controller/metal/rescue.rb:29:in `process_action'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/actionpack-3.2.16/lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.16/lib/active_support/notifications.rb:123:in `block in instrument'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.16/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.16/lib/active_support/notifications.rb:123:in `instrument'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/actionpack-3.2.16/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/actionpack-3.2.16/lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.16/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/actionpack-3.2.16/lib/abstract_controller/base.rb:121:in `process'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/actionpack-3.2.16/lib/abstract_controller/rendering.rb:45:in `process'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/actionpack-3.2.16/lib/action_controller/metal.rb:203:in `dispatch'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/actionpack-3.2.16/lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/actionpack-3.2.16/lib/action_controller/metal.rb:246:in `block in action'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/actionpack-3.2.16/lib/action_dispatch/routing/route_set.rb:73:in `call'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/actionpack-3.2.16/lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/actionpack-3.2.16/lib/action_dispatch/routing/route_set.rb:36:in `call'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/journey-1.0.4/lib/journey/router.rb:68:in `block in call'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/journey-1.0.4/lib/journey/router.rb:56:in `each'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/journey-1.0.4/lib/journey/router.rb:56:in `call'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/actionpack-3.2.16/lib/action_dispatch/routing/route_set.rb:608:in `call'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/apipie-rails-0.0.24/lib/apipie/static_dispatcher.rb:65:in `call'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/rack-openid-1.4.2/lib/rack/openid.rb:98:in `call'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/actionpack-3.2.16/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/rack-1.4.5/lib/rack/etag.rb:23:in `call'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/rack-1.4.5/lib/rack/conditionalget.rb:35:in `call'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/actionpack-3.2.16/lib/action_dispatch/middleware/head.rb:14:in `call'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/actionpack-3.2.16/lib/action_dispatch/middleware/params_parser.rb:21:in `call'
/home/daniel/workspace/foreman/cleanforeman/lib/middleware/catch_json_parse_errors.rb:9:in `call'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/actionpack-3.2.16/lib/action_dispatch/middleware/flash.rb:242:in `call'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/rack-1.4.5/lib/rack/session/abstract/id.rb:210:in `context'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/rack-1.4.5/lib/rack/session/abstract/id.rb:205:in `call'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/actionpack-3.2.16/lib/action_dispatch/middleware/cookies.rb:341:in `call'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.16/lib/active_record/query_cache.rb:64:in `call'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/activerecord-3.2.16/lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/actionpack-3.2.16/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:405:in `_run__2653290797337772252__call__2120439120557390228__callbacks'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:405:in `__run_callback'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:81:in `run_callbacks'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/actionpack-3.2.16/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/actionpack-3.2.16/lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/actionpack-3.2.16/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/actionpack-3.2.16/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.16/lib/rails/rack/logger.rb:32:in `call_app'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.16/lib/rails/rack/logger.rb:16:in `block in call'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.16/lib/active_support/tagged_logging.rb:22:in `tagged'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.16/lib/rails/rack/logger.rb:16:in `call'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/actionpack-3.2.16/lib/action_dispatch/middleware/request_id.rb:22:in `call'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/rack-1.4.5/lib/rack/methodoverride.rb:21:in `call'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/rack-1.4.5/lib/rack/runtime.rb:17:in `call'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.16/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/rack-1.4.5/lib/rack/lock.rb:15:in `call'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/actionpack-3.2.16/lib/action_dispatch/middleware/static.rb:63:in `call'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/rack-cache-1.2/lib/rack/cache/context.rb:136:in `forward'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/rack-cache-1.2/lib/rack/cache/context.rb:143:in `pass'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/rack-cache-1.2/lib/rack/cache/context.rb:155:in `invalidate'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/rack-cache-1.2/lib/rack/cache/context.rb:71:in `call!'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/rack-cache-1.2/lib/rack/cache/context.rb:51:in `call'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.16/lib/rails/engine.rb:484:in `call'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.16/lib/rails/application.rb:231:in `call'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.16/lib/rails/railtie/configurable.rb:30:in `method_missing'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/rack-1.4.5/lib/rack/builder.rb:134:in `call'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/rack-1.4.5/lib/rack/urlmap.rb:64:in `block in call'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/rack-1.4.5/lib/rack/urlmap.rb:49:in `each'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/rack-1.4.5/lib/rack/urlmap.rb:49:in `call'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/rack-1.4.5/lib/rack/content_length.rb:14:in `call'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.16/lib/rails/rack/debugger.rb:20:in `call'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/railties-3.2.16/lib/rails/rack/log_tailer.rb:17:in `call'
/home/daniel/.rvm/gems/ruby-1.9.3-p327/gems/rack-1.4.5/lib/rack/handler/webrick.rb:59:in `service'
/home/daniel/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
/home/daniel/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
/home/daniel/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
Rolling back due to a problem: [Set up compute instance dlobatog.localdomain 2 failed [#<Host::Managed id: nil, name: "dlobatog.localdomain", ip: nil, last_compile: nil, last_freshcheck: nil, last_report: nil, updated_at: nil, source_file_id: nil, created_at: nil, mac: nil, root_pass: "$1$ePR+FZ8q$F7Un6ycZ5MuRD.970NFKa0", serial: nil, puppet_status: 0, domain_id: 2, architecture_id: 1, operatingsystem_id: 22, environment_id: 16, subnet_id: nil, ptable_id: nil, medium_id: 2, build: true, comment: "", disk: "", installed_at: nil, model_id: nil, hostgroup_id: nil, owner_id: nil, owner_type: nil, enabled: true, puppet_ca_proxy_id: nil, managed: true, use_image: nil, image_file: nil, uuid: nil, compute_resource_id: 24, puppet_proxy_id: nil, certname: nil, image_id: 3, organization_id: nil, location_id: nil, type: "Host::Managed", compute_profile_id: nil>, :setCompute]]
Failed to save: Failed to create a compute openstackhome (OpenStack) instance dlobatog.localdomain: Can not find requested image
Rendered hosts/_progress.html.erb (0.5ms)
Rendered puppetclasses/_selectedClasses.html.erb (0.0ms)
Rendered puppetclasses/_classes.html.erb (5.3ms)
Rendered puppetclasses/_class_selection.html.erb (12.8ms)
Rendered hosts/_compute.html.erb (7.5ms)
Rendered hosts/_unattended.html.erb (8.4ms)
Rendered hosts/_form.html.erb (830.9ms)
Rendered hosts/new.html.erb within layouts/application (831.9ms)
Operation FAILED: can't convert nil into String
Rendered common/500.html.erb (13.5ms)
Completed 500 Internal Server Error in 2074.3ms (Views: 14.8ms | ActiveRecord: 2.1ms)
Started GET "/tasks/33da3a89-1d86-4779-bd08-472725e097b2" for 127.0.0.1 at 2014-02-23 08:29:18 +0100
```