mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 03:41:25 -07:00
Fix debug logs failing with persistent connection (#33049)
* Fix debug logs failing with persistent connection Fixes #33047 * As debug logs are written on stdout, it interrupts the communication between ansible-connection(background) process and main process. To avoid this add a string similar to exactly identify the response string. * Remove unwanted code in ansible-connection * Fix review comments * Fix spurious log emitted on ansible-connection stdout issue * ansible-connection which runs as a background process sends a json string (contains response received from remote device) to foreground ansible-playbook process over stdout. * If in case debug flag is enabled the connection_loader api invoked from ansible-connection `ssh = connection_loader.get('ssh', class_only=True)` results in emitting debug logs on stdout. This spurious log interfere with the actual response and results in failure while reading json string in ansible-playbook process * To avoid this save stdout of ansible-connection and redirect it string buffer to accumulate all the logs emitted by core API's * Add these logs in `result['messages']` which is send a json string after reinstating saved stdout * Remove unwanted code in ansible-connection * Fix review comment
This commit is contained in:
parent
bbedb9aac4
commit
90cd87f950
4 changed files with 13 additions and 53 deletions
|
@ -88,6 +88,7 @@ class Connection(ConnectionBase):
|
|||
stdin.write(src)
|
||||
|
||||
stdin.write(b'\n#END_INIT#\n')
|
||||
stdin.flush()
|
||||
|
||||
(stdout, stderr) = p.communicate()
|
||||
stdin.close()
|
||||
|
@ -104,7 +105,7 @@ class Connection(ConnectionBase):
|
|||
if 'error' in result:
|
||||
if self._play_context.verbosity > 2:
|
||||
msg = "The full traceback is:\n" + result['exception']
|
||||
display.display(result['exception'], color=C.COLOR_ERROR)
|
||||
display.display(msg, color=C.COLOR_ERROR)
|
||||
raise AnsibleError(result['error'])
|
||||
|
||||
return result['socket_path']
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue