Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wait_for: treat broken connections as "unready" #28839

Merged
merged 2 commits into from
Oct 12, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 17 additions & 4 deletions lib/ansible/modules/utilities/logic/wait_for.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@

import binascii
import datetime
import errno
import math
import os
import re
Expand Down Expand Up @@ -558,15 +559,27 @@ def main():
break

# Shutdown the client socket
s.shutdown(socket.SHUT_RDWR)
s.close()
try:
s.shutdown(socket.SHUT_RDWR)
except socket.error as e:
if e.errno != errno.ENOTCONN:
raise
# else, the server broke the connection on its end, assume it's not ready
else:
s.close()
if matched:
# Found our string, success!
break
else:
# Connection established, success!
s.shutdown(socket.SHUT_RDWR)
s.close()
try:
s.shutdown(socket.SHUT_RDWR)
except socket.error as e:
if e.errno != errno.ENOTCONN:
raise
# else, the server broke the connection on its end, assume it's not ready
else:
s.close()
break

# Conditions not yet met, wait and try again
Expand Down