DataDog / chef-datadog

Chef cookbook for Datadog Agent & Integrations
https://www.datadoghq.com
Apache License 2.0
97 stars 261 forks source link

[go-metro]: execute[Guard resource] No such file or directory - setcap #535

Open iancward opened 6 years ago

iancward commented 6 years ago

We added the go-metro recipe in #484, but the guard resource runs during compile time. The setcap package isn't installed until run time, so if it's missing, the user will get an error like this:

Errno::ENOENT: execute[setcap go-metro] (datadog::go-metro line 73) had an error: Errno::ENOENT: execute[Guard resource] (dynamically defined) had an error: Errno::ENOENT: No such file or directory - setcap
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/mixlib-shellout-2.3.2/lib/mixlib/shellout/unix.rb:340:in `exec'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/mixlib-shellout-2.3.2/lib/mixlib/shellout/unix.rb:340:in `block in fork_subprocess'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/mixlib-shellout-2.3.2/lib/mixlib/shellout/unix.rb:318:in `fork'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/mixlib-shellout-2.3.2/lib/mixlib/shellout/unix.rb:318:in `fork_subprocess'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/mixlib-shellout-2.3.2/lib/mixlib/shellout/unix.rb:95:in `run_command'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/mixlib-shellout-2.3.2/lib/mixlib/shellout.rb:263:in `run_command'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/mixin/shell_out.rb:171:in `shell_out_command'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/mixin/shell_out.rb:125:in `shell_out_with_systems_locale'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/mixin/shell_out.rb:129:in `shell_out_with_systems_locale!'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/provider/execute.rb:58:in `block in action_run'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/mixin/why_run.rb:52:in `add_action'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/provider.rb:202:in `converge_by'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/provider/execute.rb:56:in `action_run'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/provider.rb:171:in `run_action'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/resource.rb:591:in `run_action'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/guard_interpreter/resource_guard_interpreter.rb:74:in `block in evaluate_action'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/guard_interpreter/resource_guard_interpreter.rb:74:in `each'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/guard_interpreter/resource_guard_interpreter.rb:74:in `evaluate_action'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/guard_interpreter/resource_guard_interpreter.rb:60:in `evaluate'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/resource/conditional.rb:99:in `evaluate_command'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/resource/conditional.rb:95:in `evaluate'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/resource/conditional.rb:88:in `continue?'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/resource.rb:1439:in `block in should_skip?'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/resource.rb:1438:in `each'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/resource.rb:1438:in `find'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/resource.rb:1438:in `should_skip?'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/resource.rb:590:in `run_action'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/runner.rb:70:in `run_action'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/runner.rb:98:in `block (2 levels) in converge'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/runner.rb:98:in `each'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/runner.rb:98:in `block in converge'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/resource_collection/resource_list.rb:94:in `block in execute_each_resource'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/resource_collection/stepable_iterator.rb:114:in `call_iterator_block'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/resource_collection/stepable_iterator.rb:85:in `step'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/resource_collection/stepable_iterator.rb:103:in `iterate'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/resource_collection/stepable_iterator.rb:55:in `each_with_index'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/resource_collection/resource_list.rb:92:in `execute_each_resource'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/runner.rb:97:in `converge'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/client.rb:718:in `block in converge'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/client.rb:713:in `catch'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/client.rb:713:in `converge'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/client.rb:752:in `converge_and_save'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/client.rb:286:in `run'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/application.rb:292:in `block in fork_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/application.rb:280:in `fork'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/application.rb:280:in `fork_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/application.rb:245:in `block in run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/local_mode.rb:44:in `with_server_connectivity'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/application.rb:233:in `run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/application/client.rb:469:in `sleep_then_run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/application/client.rb:458:in `block in interval_run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/application/client.rb:457:in `loop'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/application/client.rb:457:in `interval_run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/application/client.rb:441:in `run_application'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/lib/chef/application.rb:59:in `run'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.8.5/bin/chef-client:26:in `<top (required)>'
/usr/bin/chef-client:59:in `load'
/usr/bin/chef-client:59:in `<main>'

We should update the guard to make it lazy (meaning, run the guard at run time--after the package is installed): https://github.com/DataDog/chef-datadog/blob/master/recipes/go-metro.rb#L75

olivielpeau commented 6 years ago

Thanks @iancward, makes sense, adding this to the 2.17.0 milestone