evertrue / zookeeper-cookbook

Chef cookbook for installing and managing Zookeeper.
https://supermarket.chef.io/cookbooks/zookeeper
Apache License 2.0
81 stars 117 forks source link

Chef cache access permission errors #42

Closed zuazo closed 11 years ago

zuazo commented 11 years ago

This cookbook gives me some access permission errors when testing it with kitchen:

Permission denied - /tmp/kitchen-chef-solo/cache (Errno::EACCES)

The complete output:

[2013-10-13T22:46:20+00:00] FATAL: Mixlib::ShellOut::ShellCommandFailed: execute[install zookeeper] (zookeeper::zookeeper line 53) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'       
---- Begin output of tar -C /opt/zookeeper -zxf zookeeper-3.4.5.tar.gz ----       
STDOUT:        
STDERR: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/mixlib-shellout-1.1.0/lib/mixlib/shellout/unix.rb:115:in `chdir': Permission denied - /tmp/kitchen-chef-solo/cache (Errno::EACCES)       
        from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/mixlib-shellout-1.1.0/lib/mixlib/shellout/unix.rb:115:in `set_cwd'       
        from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/mixlib-shellout-1.1.0/lib/mixlib/shellout/unix.rb:229:in `block in fork_subprocess'       
        from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/mixlib-shellout-1.1.0/lib/mixlib/shellout/unix.rb:222:in `fork'
        from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/mixlib-shellout-1.1.0/lib/mixlib/shellout/unix.rb:222:in `fork_subprocess'
        from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/mixlib-shellout-1.1.0/lib/mixlib/shellout/unix.rb:35:in `run_command'
        from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/mixlib-shellout-1.1.0/lib/mixlib/shellout.rb:222:in `run_command'
        from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.4/lib/chef/mixin/shell_out.rb:30:in `shell_out'
        from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.4/lib/chef/mixin/shell_out.rb:35:in `shell_out!'
        from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.4/lib/chef/provider/execute.rb:62:in `block in action_run'
        from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.4/lib/chef/mixin/why_run.rb:52:in `call'
        from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.4/lib/chef/mixin/why_run.rb:52:in `add_action'
        from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.4/lib/chef/provider.rb:151:in `converge_by'
        from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.4/lib/chef/provider/execute.rb:61:in `action_run'
        from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.4/lib/chef/provider.rb:114:in `run_action'
        from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.4/lib/chef/resource.rb:606:in `run_action'
        from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.4/lib/chef/runner.rb:50:in `run_action'
        from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.4/lib/chef/runner.rb:82:in `block (2 levels) in converge'
        from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.4/lib/chef/runner.rb:82:in `each'
        from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.4/lib/chef/runner.rb:82:in `block in converge'
        from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.4/lib/chef/resource_collection.rb:94:in `block in execute_each_resource'
        from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.4/lib/chef/resource_collection/stepable_iterator.rb:116:in `call'
        from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.4/lib/chef/resource_collection/stepable_iterator.rb:116:in `call_iterator_block'
        from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.4/lib/chef/resource_collection/stepable_iterator.rb:85:in `step'
        from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.4/lib/chef/resource_collection/stepable_iterator.rb:104:in `iterate'
        from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.4/lib/chef/resource_collection/stepable_iterator.rb:55:in `each_with_index'
        from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.4/lib/chef/resource_collection.rb:92:in `execute_each_resource'
        from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.4/lib/chef/runner.rb:81:in `converge'
        from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.4/lib/chef/client.rb:404:in `converge'
        from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.4/lib/chef/client.rb:469:in `do_run'
        from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.4/lib/chef/client.rb:200:in `run'
        from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.4/lib/chef/application.rb:190:in `run_chef_client'
        from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.4/lib/chef/application/solo.rb:239:in `block in run_application'
        from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.4/lib/chef/application/solo.rb:231:in `loop'
        from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.4/lib/chef/application/solo.rb:231:in `run_application'
        from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.4/lib/chef/application.rb:73:in `run'
        from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.4/bin/chef-solo:25:in `<top (required)>'
        from /usr/bin/chef-solo:23:in `load'
        from /usr/bin/chef-solo:23:in `<main>'
       ---- End output of tar -C /opt/zookeeper -zxf zookeeper-3.4.5.tar.gz ----
       Ran tar -C /opt/zookeeper -zxf zookeeper-3.4.5.tar.gz returned 1
>>>>>> Converge failed on instance <default-ubuntu-1204>.
>>>>>> Please see .kitchen/logs/default-ubuntu-1204.log for more details
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: SSH exited (1) for command: [sudo -E chef-solo --config /tmp/kitchen-chef-solo/solo.rb --json-attributes /tmp/kitchen-chef-solo/dna.json  --log_level info]
>>>>>> ----------------------
[2013-10-13T23:09:25+00:00] INFO: execute[build exhibitor] ran successfully
    - execute gradle jar       
  * execute[move exhibitor jar] action run[2013-10-13T23:09:25+00:00] INFO: Processing execute[move exhibitor jar] action run (zookeeper::exhibitor line 55)
================================================================================
Error executing action `run` on resource 'execute[move exhibitor jar]'       
================================================================================
Mixlib::ShellOut::ShellCommandFailed       
------------------------------------       
Expected process to exit with [0], but received '1'       
---- Begin output of cp /tmp/kitchen-chef-solo/cache/exhibitor/build/libs/exhibitor-1.5.0.jar /opt/exhibitor/1.5.0.jar ----       
STDOUT:        
STDERR: cp: cannot stat `/tmp/kitchen-chef-solo/cache/exhibitor/build/libs/exhibitor-1.5.0.jar': Permission denied       
---- End output of cp /tmp/kitchen-chef-solo/cache/exhibitor/build/libs/exhibitor-1.5.0.jar /opt/exhibitor/1.5.0.jar ----       
Ran cp /tmp/kitchen-chef-solo/cache/exhibitor/build/libs/exhibitor-1.5.0.jar /opt/exhibitor/1.5.0.jar returned 1

       Resource Declaration:
       ---------------------
       # In /tmp/kitchen-chef-solo/cookbooks/zookeeper/recipes/exhibitor.rb
        55:   execute "move exhibitor jar" do
        56:     user node[:zookeeper][:user]
        57:     command "cp #{jar_file} #{exhibitor_jar}"
        58:   end
        59: end

       Compiled Resource:
       ------------------
       # Declared in /tmp/kitchen-chef-solo/cookbooks/zookeeper/recipes/exhibitor.rb:55:in `from_file'
       execute("move exhibitor jar") do
         action "run"
         retries 0
         retry_delay 2
         command "cp /tmp/kitchen-chef-solo/cache/exhibitor/build/libs/exhibitor-1.5.0.jar /opt/exhibitor/1.5.0.jar"
         backup 5
         returns 0
         user "zookeeper"
         cookbook_name :zookeeper
         recipe_name "exhibitor"
       end

       [2013-10-13T23:09:25+00:00] INFO: Running queued delayed notifications before re-raising exception
[2013-10-13T23:09:25+00:00] ERROR: Running exception handlers       
[2013-10-13T23:09:25+00:00] ERROR: Exception handlers complete       
Chef Client failed. 12 resources updated       
[2013-10-13T23:09:25+00:00] FATAL: Stacktrace dumped to /tmp/kitchen-chef-solo/cache/chef-stacktrace.out       
[2013-10-13T23:09:25+00:00] FATAL: Mixlib::ShellOut::ShellCommandFailed: execute[move exhibitor jar] (zookeeper::exhibitor line 55) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'       
---- Begin output of cp /tmp/kitchen-chef-solo/cache/exhibitor/build/libs/exhibitor-1.5.0.jar /opt/exhibitor/1.5.0.jar ----       
STDOUT:        
STDERR: cp: cannot stat `/tmp/kitchen-chef-solo/cache/exhibitor/build/libs/exhibitor-1.5.0.jar': Permission denied       
---- End output of cp /tmp/kitchen-chef-solo/cache/exhibitor/build/libs/exhibitor-1.5.0.jar /opt/exhibitor/1.5.0.jar ----       
Ran cp /tmp/kitchen-chef-solo/cache/exhibitor/build/libs/exhibitor-1.5.0.jar /opt/exhibitor/1.5.0.jar returned 1       
>>>>>> Converge failed on instance <default-ubuntu-1204>.
>>>>>> Please see .kitchen/logs/default-ubuntu-1204.log for more details
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: SSH exited (1) for command: [sudo -E chef-solo --config /tmp/kitchen-chef-solo/solo.rb --json-attributes /tmp/kitchen-chef-solo/dna.json  --log_level info]
>>>>>> ----------------------

This two commits fix both errors.

mwhooker commented 11 years ago

weird, it seems like this shouldn't happen. I want to see why it was failing and then I'll merge this in.

Thanks!

zuazo commented 11 years ago

This is due to a restricted permissions in Chef cache directory:

Inside vagrant using kitchen

root@default-ubuntu-1204:~# chef-solo --version
Chef: 11.4.4
root@default-ubuntu-1204:~# ls -lad /tmp/kitchen-chef-solo/cache/
drwx------ 2 vagrant vagrant 4096 Oct 14 01:39 /tmp/kitchen-chef-solo/cache/

In a production machine

root@server001:~# chef-client --version
Chef: 11.4.4
root@server001:~# ls -lad /var/chef/cache
drwx------ 3 root root 4096 May 28 17:31 /var/chef/cache

For more information:

mwhooker commented 11 years ago

thanks!