Skip to content
This repository has been archived by the owner on Jul 6, 2018. It is now read-only.

NoMethodError: undefined method `[]' while creating machine from image #31

Closed
marc- opened this issue Mar 30, 2015 · 1 comment
Closed

Comments

@marc-
Copy link
Contributor

marc- commented Mar 30, 2015

After latest (v0.20) chef-privisioning changes following code stops working:

require 'chef/provisioning/docker_driver'
machine_image 'web_server' do
  recipe 'apache'
  machine_options :docker_options => {
      :base_image => {
          :name => 'ubuntu',
          :repository => 'ubuntu',
          :tag => '14.04'
      }
  }
end
machine 'web00' do
  from_image 'web_server'
  machine_options :docker_options => {
      :command => '/usr/sbin/httpd'
  }
end

chef-provisining changed the way how machine_images_spec is stored. Following commit supposed to fix compatibility issue, but it doesn't actually saves machine_options into data:
Before v0.20 (cat data_bags/images/web_server.json)

{
  "id": "web_server",
  "machine_options": {
    "docker_options": {
      "base_image": {
        "name": "chef_web_server",
        "repository": "chef",
        "tag": "web_server"
      },
      "from_image": true
    }
  }
}

After (cat data_bags/machine_image/web_server.json)

{
  "id": "web_server",
  "driver_url": "docker:unix:///var/run/docker.sock",
  "run_list": [
    "recipe[apache]",
  ]
}

From logs:

[2015-03-30T07:53:29+00:00] WARN: Machine options are no longer stored in machine_image_spec.  Drivers that store machine_options will stop working with Provisioning 1.0.

stacktrace

NoMethodError: machine[web00] (test::default line 66) had an error: NoMethodError: undefined method `[]' for nil:NilClass
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-provisioning-docker-0.5.2/lib/chef/provisioning/docker_driver/driver.rb:100:in `build_container'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-provisioning-docker-0.5.2/lib/chef/provisioning/docker_driver/driver.rb:87:in `ready_machine'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-provisioning-0.20/lib/chef/provider/machine.rb:38:in `block in <class:Machine>'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/provider/lwrp_base.rb:60:in `instance_eval'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/provider/lwrp_base.rb:60:in `recipe_eval_with_update_check'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/provider/lwrp_base.rb:45:in `block in action'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-provisioning-0.20/lib/chef/provider/machine.rb:55:in `block in <class:Machine>'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/provider/lwrp_base.rb:60:in `instance_eval'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/provider/lwrp_base.rb:60:in `recipe_eval_with_update_check'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/provider/lwrp_base.rb:45:in `block in action'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/provider.rb:121:in `run_action'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/resource.rb:648:in `run_action'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/runner.rb:49:in `run_action'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/runner.rb:81:in `block (2 levels) in converge'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/runner.rb:81:in `each'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/runner.rb:81:in `block in converge'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/resource_collection.rb:98:in `block in execute_each_resource'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/resource_collection/stepable_iterator.rb:116:in `call'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/resource_collection/stepable_iterator.rb:116:in `call_iterator_block'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/resource_collection/stepable_iterator.rb:85:in `step'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/resource_collection/stepable_iterator.rb:104:in `iterate'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/resource_collection/stepable_iterator.rb:55:in `each_with_index'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/resource_collection.rb:96:in `execute_each_resource'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/runner.rb:80:in `converge'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/client.rb:345:in `converge'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/client.rb:431:in `do_run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/client.rb:213:in `block in run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/client.rb:207:in `fork'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/client.rb:207:in `run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/application.rb:236:in `run_chef_client'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/application/client.rb:338:in `block in run_application'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/application/client.rb:327:in `loop'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/application/client.rb:327:in `run_application'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/lib/chef/application.rb:55:in `run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.18.6/bin/chef-client:26:in `<top (required)>'
/opt/chef/bin/chef-client:23:in `load'
/opt/chef/bin/chef-client:23:in `<main>'
@marc-
Copy link
Contributor Author

marc- commented May 29, 2015

Waiting for chef-provisioning-docker to upgrade to support chef-provisioning 1.0 .

@marc- marc- closed this as completed May 29, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

1 participant