mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Lxd instance not found fix false positives (#7521)
* lxd: Add lxc command execution debug statement. * lxd: avoid false positives in "instance not found" detection Due to changes over time in the error message which lxd printed when an instance wasn't found, the detection logic in the lxd connection plugin matched any "not found" string. Unfortunately this also false triggered on other errors e.g. "/usr/bin/python3: not found" from the payload, giving a confusing error message "UNREACHABLE! ... instance not found" to the ansible user. * Update changelog fragment. --------- Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
ecea4a2f38
commit
b4a2e9da50
2 changed files with 7 additions and 1 deletions
|
@ -0,0 +1,2 @@
|
|||
minor_changes:
|
||||
- "lxd connection plugin - tighten the detection logic for lxd ``Instance not found`` errors, to avoid false detection on unrelated errors such as ``/usr/bin/python3: not found`` (https://github.com/ansible-collections/community.general/pull/7521)."
|
|
@ -101,6 +101,8 @@ class Connection(ConnectionBase):
|
|||
self.get_option("executable"), "-c", cmd
|
||||
])
|
||||
|
||||
self._display.vvvvv(u"EXEC {0}".format(local_cmd), host=self._host())
|
||||
|
||||
local_cmd = [to_bytes(i, errors='surrogate_or_strict') for i in local_cmd]
|
||||
in_data = to_bytes(in_data, errors='surrogate_or_strict', nonstring='passthru')
|
||||
|
||||
|
@ -110,10 +112,12 @@ class Connection(ConnectionBase):
|
|||
stdout = to_text(stdout)
|
||||
stderr = to_text(stderr)
|
||||
|
||||
self._display.vvvvv(u"EXEC lxc output: {0} {1}".format(stdout, stderr), host=self._host())
|
||||
|
||||
if "is not running" in stderr:
|
||||
raise AnsibleConnectionFailure("instance not running: %s" % self._host())
|
||||
|
||||
if "not found" in stderr:
|
||||
if stderr.strip() == "Error: Instance not found" or stderr.strip() == "error: not found":
|
||||
raise AnsibleConnectionFailure("instance not found: %s" % self._host())
|
||||
|
||||
return process.returncode, stdout, stderr
|
||||
|
|
Loading…
Reference in a new issue