Skip to content

Commit 1fca4c4

Browse files
(MODULES-10722) Inherit pipe_timeout from timeout
Prior to this commit there was no way to modify the pipe_timeout parameter when instantiating a PowerShell Manager instance, users were stuck with the default defined in ruby-pwsh (30s). If this time is insufficient to start the host process, the exec failed with no way to extend it short of modifying the provider. This commit updates the definition of the ps_manager by checking to see if the timeout parameter is specified on the resource and, if so, inheriting that to re-use for the pipe timeout.
1 parent a0ca7f5 commit 1fca4c4

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

lib/puppet/provider/exec/powershell.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ def self.upgrade_message
4545
@upgrade_warning_issued = true
4646
end
4747

48-
def ps_manager
48+
def ps_manager(pipe_timeout)
4949
debug_output = Puppet::Util::Log.level == :debug
50-
Pwsh::Manager.instance(Pwsh::Manager.powershell_path, Pwsh::Manager.powershell_args, debug: debug_output)
50+
Pwsh::Manager.instance(Pwsh::Manager.powershell_path, Pwsh::Manager.powershell_args, debug: debug_output, pipe_timeout: pipe_timeout)
5151
end
5252

5353
def run(command, check = false)
@@ -77,7 +77,7 @@ def execute_resource(powershell_code, resource)
7777
timeout_ms = resource[:timeout].nil? ? nil : resource[:timeout] * 1000
7878
environment_variables = resource[:environment].nil? ? [] : resource[:environment]
7979

80-
result = ps_manager.execute(powershell_code, timeout_ms, working_dir, environment_variables)
80+
result = ps_manager(resource[:timeout]).execute(powershell_code, timeout_ms, working_dir, environment_variables)
8181
stdout = result[:stdout]
8282
native_out = result[:native_stdout]
8383
stderr = result[:stderr]

lib/puppet/provider/exec/pwsh.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ def pwsh_args
6868
#
6969
# @api private
7070
# @return [Pwsh::Manager] The PowerShell manager for this resource
71-
def ps_manager
71+
def ps_manager(pipe_timeout)
7272
debug_output = Puppet::Util::Log.level == :debug
73-
Pwsh::Manager.instance(@pwsh, pwsh_args, debug: debug_output)
73+
Pwsh::Manager.instance(@pwsh, pwsh_args, debug: debug_output, pipe_timeout: pipe_timeout)
7474
end
7575

7676
def execute_resource(powershell_code, resource)
@@ -81,7 +81,7 @@ def execute_resource(powershell_code, resource)
8181
timeout_ms = resource[:timeout].nil? ? nil : resource[:timeout] * 1000
8282
environment_variables = resource[:environment].nil? ? [] : resource[:environment]
8383

84-
result = ps_manager.execute(powershell_code, timeout_ms, working_dir, environment_variables)
84+
result = ps_manager(resource[:timeout]).execute(powershell_code, timeout_ms, working_dir, environment_variables)
8585
stdout = result[:stdout]
8686
native_out = result[:native_stdout]
8787
stderr = result[:stderr]

0 commit comments

Comments
 (0)