Skip to content

Commit

Permalink
Fix updated_by_last_action value of monitor provider
Browse files Browse the repository at this point in the history
`use_inline_resources` is the way to go to ensure that
`updated_by_last_action` is correct.

It makes the provider actions run in their own run context,
so we need to redefine the `datadog-agent` service in each action.

Closes #168, Closes #229

Signed-off-by: Mike Fiedler <miketheman@gmail.com>
  • Loading branch information
olivielpeau authored and miketheman committed Oct 15, 2015
1 parent b8e9ede commit 234526f
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions providers/monitor.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Creates the proper yaml file in /etc/dd-agent/conf.d/

# Defined since Chef 11
use_inline_resources if defined?(use_inline_resources)

def whyrun_supported?
true
end
Expand All @@ -16,16 +19,16 @@ def whyrun_supported?
cookbook new_resource.cookbook
notifies :restart, 'service[datadog-agent]', :delayed if node['datadog']['agent_start']
end
new_resource.updated_by_last_action(false)

service 'datadog-agent'
end

action :remove do
if ::File.exist?("/etc/dd-agent/conf.d/#{new_resource.name}.yaml")
Chef::Log.debug "Removing #{new_resource.name} from /etc/dd-agent/conf.d/"
file "/etc/dd-agent/conf.d/#{new_resource.name}.yaml" do
action :delete
notifies :restart, 'service[datadog-agent]', :delayed if node['datadog']['agent_start']
end
new_resource.updated_by_last_action(true)
Chef::Log.debug "Removing #{new_resource.name} from /etc/dd-agent/conf.d/"
file "/etc/dd-agent/conf.d/#{new_resource.name}.yaml" do
action :delete
notifies :restart, 'service[datadog-agent]', :delayed if node['datadog']['agent_start']
end

service 'datadog-agent'
end

0 comments on commit 234526f

Please sign in to comment.