summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith84@gmail.com>2020-04-13 22:21:09 -0700
committerTim Smith <tsmith84@gmail.com>2020-04-13 22:21:09 -0700
commit534ae5bbc34feed50e9319ddef94b615fe3d229c (patch)
tree492fe8334c0b374e958958c468f8860d31ae85c9
parent4bda3fd9301f00b92ea3545cfe5cb16c3e7e245b (diff)
downloadchef-534ae5bbc34feed50e9319ddef94b615fe3d229c.tar.gz
Give execute resource a proper timeout defaulttimeouts
This should just be done on the resource instead of hacking it into the provider Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/chef/provider/execute.rb8
-rw-r--r--lib/chef/resource/execute.rb3
2 files changed, 3 insertions, 8 deletions
diff --git a/lib/chef/provider/execute.rb b/lib/chef/provider/execute.rb
index 28769e15a6..e4fc1ee9ea 100644
--- a/lib/chef/provider/execute.rb
+++ b/lib/chef/provider/execute.rb
@@ -27,7 +27,7 @@ class Chef
provides :execute, target_mode: true
- def_delegators :new_resource, :command, :returns, :environment, :user, :domain, :password, :group, :cwd, :umask, :creates, :elevated, :default_env
+ def_delegators :new_resource, :command, :returns, :environment, :user, :domain, :password, :group, :cwd, :umask, :creates, :elevated, :default_env, :timeout
def load_current_resource
current_resource = Chef::Resource::Execute.new(new_resource.name)
@@ -41,12 +41,6 @@ class Chef
end
end
- def timeout
- # original implementation did not specify a timeout, but ShellOut
- # *always* times out. So, set a very long default timeout
- new_resource.timeout || 3600
- end
-
action :run do
if creates && sentinel_file.exist?
logger.debug("#{new_resource} sentinel file #{sentinel_file} exists - nothing to do")
diff --git a/lib/chef/resource/execute.rb b/lib/chef/resource/execute.rb
index 65dee04469..9195f7a4d6 100644
--- a/lib/chef/resource/execute.rb
+++ b/lib/chef/resource/execute.rb
@@ -78,7 +78,8 @@ class Chef
property :returns, [ Integer, Array ], default: 0,
description: "The return value for a command. This may be an array of accepted values. An exception is raised when the return value(s) do not match."
- property :timeout, [ Integer, Float ],
+ property :timeout, [ Integer, String, Float ],
+ default: 3600,
description: "The amount of time (in seconds) a command is to wait before timing out.",
desired_state: false