Fix psrp - ReadTimeout exceptions now mark host as unreachable (#85974)

* psrp - ReadTimeout exceptions now mark host as unreachable

* add try to _exec_psrp_script

* fix indent E111

* update raise format

switch to raise Exception from e

Co-authored-by: Jordan Borean <jborean93@gmail.com>

---------

Co-authored-by: Jordan Borean <jborean93@gmail.com>
milestone
Michał Gąsior 2 months ago committed by GitHub
parent c02f59ca3a
commit 9fcf1f7c58
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,2 @@
bugfixes:
- psrp - ReadTimeout exceptions now mark host as unreachable instead of fatal (https://github.com/ansible/ansible/issues/85966)

@ -331,7 +331,7 @@ try:
from pypsrp.host import PSHost, PSHostUserInterface
from pypsrp.powershell import PowerShell, RunspacePool
from pypsrp.wsman import WSMan
from requests.exceptions import ConnectionError, ConnectTimeout
from requests.exceptions import ConnectionError, ConnectTimeout, ReadTimeout
except ImportError as err:
HAS_PYPSRP = False
PYPSRP_IMP_ERR = err
@ -479,11 +479,16 @@ class Connection(ConnectionBase):
pwsh_in_data = in_data
display.vvv(u"PSRP: EXEC %s" % script, host=self._psrp_host)
rc, stdout, stderr = self._exec_psrp_script(
script=script,
input_data=pwsh_in_data.splitlines() if pwsh_in_data else None,
arguments=script_args,
)
try:
rc, stdout, stderr = self._exec_psrp_script(
script=script,
input_data=pwsh_in_data.splitlines() if pwsh_in_data else None,
arguments=script_args,
)
except ReadTimeout as e:
raise AnsibleConnectionFailure(
"HTTP read timeout during PSRP script execution"
) from e
return rc, stdout, stderr
def put_file(self, in_path: str, out_path: str) -> None:

Loading…
Cancel
Save