-
Notifications
You must be signed in to change notification settings - Fork 261
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
Support 'why-run' mode #118
Comments
On Chef 10.26.0, I get this: $ sudo chef-client -W -Fdoc
...
Compiling Cookbooks...
Recipe: chef_handler::default
* remote_directory[/var/chef/handlers] action createRecipe: <Dynamically Defined Resource>
* cookbook_file[/var/chef/handlers/README] action create (up to date)
(up to date)
Recipe: datadog::dd-handler
* chef_gem[chef-handler-datadog] action install (up to date)
* chef_handler[Chef::Handler::Datadog] action enable
- Would load chef/handler/datadog
- Would enable chef_handler[Chef::Handler::Datadog] as a report handler
- Would enable chef_handler[Chef::Handler::Datadog] as a exception handler
Converging 419 resources
...
Recipe: datadog::repository
* apt_repository[datadog] action add (up to date)
Recipe: <Dynamically Defined Resource>
* execute[install-key C7A7DA52] action run (skipped due to not_if)
* file[/var/lib/apt/periodic/update-success-stamp] action nothing (up to date)
* execute[apt-cache gencaches] action nothing (up to date)
* execute[apt-get update] action nothing (up to date)
* file[/etc/apt/sources.list.d/datadog.list] action create (up to date)
Recipe: datadog::dd-agent
* log[Running apt-get update to work around COOK-2171] action write (skipped due to not_if)
* package[datadog-agent] action install (up to date)
* directory[/etc/dd-agent] action create (up to date)
* template[/etc/dd-agent/datadog.conf] action create (up to date)
* service[datadog-agent] action enable (up to date)
* service[datadog-agent] action start (up to date)
Recipe: datadog::network
* datadog_monitor[network] action add (up to date)
Recipe: <Dynamically Defined Resource>
* template[/etc/dd-agent/conf.d/network.yaml] action create (up to date)
Recipe: chef_handler::default
* remote_directory[/var/chef/handlers] action nothing (up to date)
Recipe: datadog::dd-handler
* chef_gem[chef-handler-datadog] action install (up to date)
* chef_handler[Chef::Handler::Datadog] action nothing (up to date)
.... So I think we're good - we support running in why-run mode, and do not emit events/metrics during a why-run execution. |
Tested on Chef 12.2.1, the why-run execution seems to work fine (no changes to the state and no event/metrics emitted). The only case I've found that doesn't work is the
(obviously because in why-run mode the But from what I understand this case is unavoidable. |
@olivielpeau Thanks for the investigation. Regarding the final case, this was reported a while back, and claimed to have been resolved. Might be worthwhile looking into it a bit further? |
@miketheman I think the issue you're mentioning is that the I'll look more into this issue (in particular I'll look at how chef_handler loads the handler's class and if that can help us solve this). |
@olivielpeau You're right - I linked the wrong issue. Thinking about this further, there might be a better way to wrap the require that behaves differently based on whether or not we're in why-run mode, by inspecting the value of Something maybe like: if Chef::Config[:why_run]
Chef::Log.warn('Running in why-run mode, skipping dd-handler')
return
end at the top of the recipe. |
@miketheman I like the idea of skipping FYI the Apart from that I think why-run mode is fully supported. |
Running in why-run mode fails when the chef-handler-datadog gem is not installed because of the `require 'chef/handler/datadog'` line, so we skip the entire recipe in why-run mode. Upgrading chef_handler to v1.2 (Chef>=12) will allow us to remove that `require` and unskip the recipe in why-run mode. See #118
Closed via #231 |
No description provided.
The text was updated successfully, but these errors were encountered: