diff options
author | Ranjib Dey <ranjib@pagerduty.com> | 2015-06-23 23:13:12 -0700 |
---|---|---|
committer | Ranjib Dey <ranjib@pagerduty.com> | 2015-06-24 10:12:45 -0700 |
commit | 720f3331f794a2ad31bee2b1113ac99fada85389 (patch) | |
tree | 4f03dfd86d9fb543cb2eaf1b6a4c3848d356b11f /lib/chef/event_dispatch | |
parent | 9f0ea8aa0ec05819e242dedaa85fe731dca3146c (diff) | |
parent | ab34e3cd83d545b5da19113d723eeebcab1e77e2 (diff) | |
download | chef-720f3331f794a2ad31bee2b1113ac99fada85389.tar.gz |
Merge remote-tracking branch 'origin/master' into chef_handler
Diffstat (limited to 'lib/chef/event_dispatch')
-rw-r--r-- | lib/chef/event_dispatch/base.rb | 56 | ||||
-rw-r--r-- | lib/chef/event_dispatch/dsl.rb | 13 |
2 files changed, 46 insertions, 23 deletions
diff --git a/lib/chef/event_dispatch/base.rb b/lib/chef/event_dispatch/base.rb index 73fe25ec13..50aee63450 100644 --- a/lib/chef/event_dispatch/base.rb +++ b/lib/chef/event_dispatch/base.rb @@ -269,26 +269,37 @@ class Chef # def notifications_resolved # end + # + # Resource events and ordering: + # + # 1. Start the action + # - resource_action_start + # 2. Check the guard + # - resource_skipped: (goto 7) if only_if/not_if say to skip + # 3. Load the current resource + # - resource_current_state_loaded + # - resource_current_state_load_bypassed (if not why-run safe) + # 4. Check if why-run safe + # - resource_bypassed: (goto 7) if not why-run safe + # 5. During processing: + # - resource_update_applied: For each actual change (many per action) + # 6. Processing complete status: + # - resource_failed if the resource threw an exception while running + # - resource_failed_retriable: (goto 3) if resource failed and will be retried + # - resource_updated if the resource was updated (resource_update_applied will have been called) + # - resource_up_to_date if the resource was up to date (no resource_update_applied) + # 7. Processing complete: + # - resource_completed + # + # Called before action is executed on a resource. def resource_action_start(resource, action, notification_type=nil, notifier=nil) end - # Called when a resource fails, but will retry. - def resource_failed_retriable(resource, action, retry_count, exception) - end - - # Called when a resource fails and will not be retried. - def resource_failed(resource, action, exception) - end - # Called when a resource action has been skipped b/c of a conditional def resource_skipped(resource, action, conditional) end - # Called when a resource action has been completed - def resource_completed(resource) - end - # Called after #load_current_resource has run. def resource_current_state_loaded(resource, action, current_resource) end @@ -302,21 +313,34 @@ class Chef def resource_bypassed(resource, action, current_resource) end - # Called when a resource has no converge actions, e.g., it was already correct. - def resource_up_to_date(resource, action) - end - # Called when a change has been made to a resource. May be called multiple # times per resource, e.g., a file may have its content updated, and then # its permissions updated. def resource_update_applied(resource, action, update) end + # Called when a resource fails, but will retry. + def resource_failed_retriable(resource, action, retry_count, exception) + end + + # Called when a resource fails and will not be retried. + def resource_failed(resource, action, exception) + end + # Called after a resource has been completely converged, but only if # modifications were made. def resource_updated(resource, action) end + # Called when a resource has no converge actions, e.g., it was already correct. + def resource_up_to_date(resource, action) + end + + # Called when a resource action has been completed + def resource_completed(resource) + end + + # A stream has opened. def stream_opened(stream, options = {}) end diff --git a/lib/chef/event_dispatch/dsl.rb b/lib/chef/event_dispatch/dsl.rb index 98854a4716..c6f21c9b45 100644 --- a/lib/chef/event_dispatch/dsl.rb +++ b/lib/chef/event_dispatch/dsl.rb @@ -26,15 +26,14 @@ class Chef def initialize(name) klass = Class.new(Chef::EventDispatch::Base) do - def self.name - @@name - end + attr_reader :name end - klass.class_variable_set(:@@name, name) @handler = klass.new - # Use current event.register API to add anonymous handler if - # run_context and associated event dispatcher is set, else fallback to - # Chef::Config[:hanlder]. + @handler.instance_variable_set(:@name, name) + + # Use event.register API to add anonymous handler if Chef.run_context + # and associated event dispatcher is set, else fallback to + # Chef::Config[:hanlder] if Chef.run_context && Chef.run_context.events Chef::Log.debug("Registering handler '#{name}' using events api") Chef.run_context.events.register(handler) |