chef-boneyard / chef-provisioning-docker

Docker provisioner for chef-provisioning
Apache License 2.0
92 stars 40 forks source link

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

Closed marc- closed 9 years ago

marc- commented 9 years ago

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 _databags/images_/webserver.json)

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

After (cat _databags/machine_image_/webserver.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- commented 9 years ago

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