@@ -60,13 +60,6 @@ def set_timeout
6060 resource [ :dsc_timeout ] ? resource [ :dsc_timeout ] * 1000 : 1_200_000
6161 end
6262
63- def compile_timeout_msg ( timeout )
64- "The DSC Resource did not respond within the timeout limit of #{ timeout } milliseconds. \
65- This can occur if the DSC Resource is stuck in an infinite loop, or if the DSC Resource is waiting for user input. \
66- Please check the DSC Resource for any prompts that may require user input, and ensure that the DSC Resource does not contain any infinite loops. \
67- If the DSC Resource is functioning correctly, you may need to increase the timeout limit using the 'dsc_timeout' parameter"
68- end
69-
7063 def ps_manager
7164 debug_output = Puppet ::Util ::Log . level == :debug
7265 Pwsh ::Manager . instance ( command ( :powershell ) , Pwsh ::Manager . powershell_args , debug : debug_output )
@@ -81,14 +74,15 @@ def exists?
8174 Puppet . debug "\n " + self . class . redact_content ( script_content )
8275
8376 if Pwsh ::Manager . windows_powershell_supported?
84- output = ps_manager . execute ( script_content , timeout ) [ :stdout ]
77+ output = ps_manager . execute ( script_content , timeout )
78+ raise Puppet ::Error , output [ :errormessage ] if output [ :errormessage ] &.match? ( %r{PowerShell module timeout \( \d + ms\) exceeded while executing} )
79+
80+ output = output [ :stdout ]
8581 else
8682 self . class . upgrade_message
8783 output = powershell ( Pwsh ::Manager . powershell_args , script_content )
8884 end
8985
90- raise Puppet ::Error , compile_timeout_msg ( timeout ) if output . nil?
91-
9286 Puppet . debug "Dsc Resource returned: #{ output } "
9387 data = JSON . parse ( output )
9488 raise ( data [ 'errormessage' ] ) unless data [ 'errormessage' ] . empty?
@@ -107,14 +101,15 @@ def create
107101 Puppet . debug "\n " + self . class . redact_content ( script_content )
108102
109103 if Pwsh ::Manager . windows_powershell_supported?
110- output = ps_manager . execute ( script_content , timeout ) [ :stdout ]
104+ output = ps_manager . execute ( script_content , timeout )
105+ raise Puppet ::Error , output [ :errormessage ] if output [ :errormessage ] &.match? ( %r{PowerShell module timeout \( \d + ms\) exceeded while executing} )
106+
107+ output = output [ :stdout ]
111108 else
112109 self . class . upgrade_message
113110 output = powershell ( Pwsh ::Manager . powershell_args , script_content )
114111 end
115112
116- raise Puppet ::Error , compile_timeout_msg ( timeout ) if output . nil?
117-
118113 Puppet . debug "Create Dsc Resource returned: #{ output } "
119114 data = JSON . parse ( output )
120115
0 commit comments