mirror of
https://github.com/ansible-collections/community.docker.git
synced 2025-12-15 19:42:06 +00:00
Avoid losing data from events if multiple arrive at the same time. (#1158)
This commit is contained in:
parent
e8ec22d3b1
commit
f7e976f3da
3
changelogs/fragments/1158-select-fix.yml
Normal file
3
changelogs/fragments/1158-select-fix.yml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
bugfixes:
|
||||||
|
- "docker, nsenter connection plugins - fix handling of ``become`` plugin password prompt handling in case multiple events arrive at the same time
|
||||||
|
(https://github.com/ansible-collections/community.docker/pull/1158)."
|
||||||
@ -425,21 +425,24 @@ class Connection(ConnectionBase):
|
|||||||
+ to_native(become_output)
|
+ to_native(become_output)
|
||||||
)
|
)
|
||||||
|
|
||||||
chunk = None
|
chunks = b""
|
||||||
for key, event in events:
|
for key, event in events:
|
||||||
if key.fileobj == p.stdout:
|
if key.fileobj == p.stdout:
|
||||||
chunk = p.stdout.read()
|
chunk = p.stdout.read()
|
||||||
|
if chunk:
|
||||||
|
chunks += chunk
|
||||||
elif key.fileobj == p.stderr:
|
elif key.fileobj == p.stderr:
|
||||||
chunk = p.stderr.read()
|
chunk = p.stderr.read()
|
||||||
# TODO: avoid chunk being set multiple times!
|
if chunk:
|
||||||
|
chunks += chunk
|
||||||
|
|
||||||
if not chunk:
|
if not chunks:
|
||||||
stdout, stderr = p.communicate()
|
stdout, stderr = p.communicate()
|
||||||
raise AnsibleError(
|
raise AnsibleError(
|
||||||
"privilege output closed while waiting for password prompt:\n"
|
"privilege output closed while waiting for password prompt:\n"
|
||||||
+ to_native(become_output)
|
+ to_native(become_output)
|
||||||
)
|
)
|
||||||
become_output += chunk
|
become_output += chunks
|
||||||
finally:
|
finally:
|
||||||
selector.close()
|
selector.close()
|
||||||
|
|
||||||
|
|||||||
@ -177,21 +177,24 @@ class Connection(ConnectionBase):
|
|||||||
+ to_native(become_output)
|
+ to_native(become_output)
|
||||||
)
|
)
|
||||||
|
|
||||||
chunk = None
|
chunks = b""
|
||||||
for key, event in events:
|
for key, event in events:
|
||||||
if key.fileobj == p.stdout:
|
if key.fileobj == p.stdout:
|
||||||
chunk = p.stdout.read()
|
chunk = p.stdout.read()
|
||||||
|
if chunk:
|
||||||
|
chunks += chunk
|
||||||
elif key.fileobj == p.stderr:
|
elif key.fileobj == p.stderr:
|
||||||
chunk = p.stderr.read()
|
chunk = p.stderr.read()
|
||||||
# TODO: avoid chunk being set multiple times!
|
if chunk:
|
||||||
|
chunks += chunk
|
||||||
|
|
||||||
if not chunk:
|
if not chunks:
|
||||||
stdout, stderr = p.communicate()
|
stdout, stderr = p.communicate()
|
||||||
raise AnsibleError(
|
raise AnsibleError(
|
||||||
"privilege output closed while waiting for password prompt:\n"
|
"privilege output closed while waiting for password prompt:\n"
|
||||||
+ to_native(become_output)
|
+ to_native(become_output)
|
||||||
)
|
)
|
||||||
become_output += chunk
|
become_output += chunks
|
||||||
finally:
|
finally:
|
||||||
selector.close()
|
selector.close()
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user