summaryrefslogtreecommitdiff
path: root/lib/chef/resource.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chef/resource.rb')
-rw-r--r--lib/chef/resource.rb21
1 files changed, 15 insertions, 6 deletions
diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb
index 863d357561..4864ad8816 100644
--- a/lib/chef/resource.rb
+++ b/lib/chef/resource.rb
@@ -569,6 +569,8 @@ class Chef
#
def run_action(action, notification_type=nil, notifying_resource=nil)
# reset state in case of multiple actions on the same resource.
+ old_currently_running_action = @currently_running_action
+ @currently_running_action = action
@elapsed_time = 0
start_time = Time.now
events.resource_action_start(self, action, notification_type, notifying_resource)
@@ -608,16 +610,23 @@ class Chef
events.resource_failed(self, action, e)
raise customize_exception(e)
end
- ensure
- @elapsed_time = Time.now - start_time
- # Reporting endpoint doesn't accept a negative resource duration so set it to 0.
- # A negative value can occur when a resource changes the system time backwards
- @elapsed_time = 0 if @elapsed_time < 0
- events.resource_completed(self)
end
+ ensure
+ @currently_running_action = old_currently_running_action
+ @elapsed_time = Time.now - start_time
+ # Reporting endpoint doesn't accept a negative resource duration so set it to 0.
+ # A negative value can occur when a resource changes the system time backwards
+ @elapsed_time = 0 if @elapsed_time < 0
+ events.resource_completed(self)
end
#
+ # If we are currently running an action, this shows the action we are running.
+ # If the resource is running multiple actions at once, this will show the most recent.
+ #
+ attr_reader :currently_running_action
+
+ #
# Generic Ruby and Data Structure Stuff (for user)
#