Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Chef fails with a fatal error when building an image #31

Closed
ghost opened this issue Dec 10, 2013 · 4 comments
Closed

Chef fails with a fatal error when building an image #31

ghost opened this issue Dec 10, 2013 · 4 comments

Comments

@ghost
Copy link

ghost commented Dec 10, 2013

Hi, I am experiencing a weird error on my Vagrant (Ubuntu 12.04) installation.
I am using latest chef configured with config.omnibus.chef_version = :latest

The recipe looks like:

  docker_image node.buildstep.image_name do
    tag 'buildstep'
    image_url node.buildstep.stack_url
    action :build
  end

It seems that it trying to run the right command which is docker build -t buildstep:buildstep github.com/progrium/buildstep.
When I run this command manually as root in my vagrant installation it works nicely and it returns code 0. While chef fails:

STDERR: 
---- End output of docker build -t buildstep:buildstep github.com/progrium/buildstep ----

[2013-12-10T05:21:36+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

Nothing more, no backtrace. Thank you for a help

@ghost
Copy link
Author

ghost commented Dec 10, 2013

Maybe it's happened by image_cmd_timeout. If so, it would be good to raise a descriptive error anyway.

@jayofdoom
Copy link
Contributor

Yeah; when I got this error, I increased cmd_timeout on my resource and it was fixed. I think the timeout is something setup in Chef's shell_out mixin, so keying a better error might be something more suited for upstream?

@bflad
Copy link
Contributor

bflad commented Dec 30, 2013

At least when I'm running, it has the descriptive "command timed out" error a few lines up.

[2013-12-30T08:39:42+00:00] FATAL: Stacktrace dumped to /tmp/kitchen-chef-solo/cache/chef-stacktrace.out
Chef Client failed. 17 resources updated
[2013-12-30T08:39:42+00:00] ERROR: docker_image[base] (docker_test::image_lwrp line 1) had an error: Mixlib::ShellOut::CommandTimeout: command timed out:
---- Begin output of docker pull base  ----
STDOUT: Pulling repository base
STDERR:
---- End output of docker pull base  ----

[2013-12-30T08:39:42+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

Here's the generator:
https://github.com/opscode/mixlib-shellout/blob/master/lib/mixlib/shellout/unix.rb#L78

I can probably begin/rescue it and return a more helpful message saying to change container_cmd_timeout / image_cmd_timeout or LWRP cmd_timeout. I'll fiddle shortly.

If this works, I'll leave it at FATAL because I'm not sure how useful it would be to continue the Chef run should one of these fail, it would likely be much more of a headache for other resources/behavior later in the run.

@bflad
Copy link
Contributor

bflad commented Dec 30, 2013

Got this worked out so it prints a helpful error message and is also catchable should you want rescue logic (for retries, etc) in wrapping cookbooks. I'll document and release this feature in a few minutes as 0.21.0 of the cookbook.

Compiled Resource:
------------------
# Declared in /tmp/kitchen-chef-solo/cookbooks/docker_test/recipes/image_lwrp.rb:1:in `from_file'

docker_image("base") do
  action :pull
  retries 0
  retry_delay 2
  cookbook_name :docker_test
  recipe_name "image_lwrp"
  cmd_timeout 5
  image_name "base"
end

[2013-12-30T09:21:05+00:00] INFO: Running queued delayed notifications before re-raising exception
[2013-12-30T09:21:05+00:00] ERROR: Running exception handlers
[2013-12-30T09:21:05+00:00] ERROR: Exception handlers complete
[2013-12-30T09:21:05+00:00] FATAL: Stacktrace dumped to /tmp/kitchen-chef-solo/cache/chef-stacktrace.out
Chef Client failed. 17 resources updated
[2013-12-30T09:21:05+00:00] ERROR: docker_image[base] (docker_test::image_lwrp line 1) had an error: #<Class:0x000000022ab460>::CommandTimeout: Docker command timed out:
docker pull base

Please adjust node image_cmd_timeout attribute or this docker_image cmd_timeout attribute if necessary.

[2013-12-30T09:21:05+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

@bflad bflad closed this as completed in e2944fa Dec 30, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants