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
Fix issue #23774 Make transport_test use exec #23775
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We wanted to avoid doing a full roundtrip using the protocol as it is more expensive than a single TCP test. So maybe we should modify the default delay for these tests.
We could also get rid of the transport_test altogether, and only do the real remote module run.
display.vvv("attempting transport test to %s:%s" % (host, port)) | ||
sock = socket.create_connection((host, port), connect_timeout) | ||
sock.close() | ||
display.vvv("attempting transport test to %s" % self.host) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fails because self_host is not defined for accelerate transport.
sock.close() | ||
display.vvv("attempting transport test to %s" % self.host) | ||
self.reset() | ||
self.exec_command("exit") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if exit is an accepted command.
display.vvv("attempting transport test to %s:%s" % (host, port)) | ||
sock = socket.create_connection((host, port), connect_timeout) | ||
sock.close() | ||
display.vvv("attempting transport test to %s" % self.host) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here also self.host is not defined.
display.vvv("attempting transport test to %s:%s" % (host, port)) | ||
sock = socket.create_connection((host, port), connect_timeout) | ||
sock.close() | ||
display.vvv("attempting transport test to %s" % self.host) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again self_host is not defined for winrm.
sock.close() | ||
display.vvv("attempting transport test to %s" % self.host) | ||
self.reset() | ||
self.exec_command("exit") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would probably go for "Exit" here, but that's more cosmetic than functional.
Some ansible hosts are not directly reachable via socket connections. It is best to use the transport mechanism itself than to assume that the host is reachable via socket. If we can exec a command, then the transport is working.
7fde1c9
to
12d133c
Compare
@dagwieers Thanks for the feedback. What would you recommend for configuring connect_timeout? Currently, the exec_command uses the same timeout from the self._play_context.timeout, this code is ignoring anything set for the connect_timeout. |
@smikulcik Good question, I don't know what we do best in this case. Maybe we should discuss this in the core meeting. |
The integration test found a weird issue related to our code:
Needs investigation. |
Beware that the deadline for getting new features/modules accepted in Ansible v2.5 is nearing, it is set to either 2018-01-15 or 2018-01-31. If you are blocked, or you need feedback, please discuss on IRC channel #ansible-windows or add a comment to [the Windows Working Group meeting agenda] |
I still think this would be a useful addition, the transport test was disabled so it would still work over proxied connections, but I prefer keeping this around. |
@dagwieers @jborean93 @nitzmahone - This one seems dead for quite a while, still relevant? |
Considering the age and merge conflicts I am going to close this PR. If this is still a problem please feel free to open a new PR that has been rebased. |
SUMMARY
Since ssh may re-route traffic to any number of places before it
reaches a host by the ssh config files and proxy hosts, we cannot use
sockets to test our transport.
It would make sense to use the same mechanism that we use to
perform actions on a host as we would to verify connectivity.
This change performs a dummy exec_command on the host to verify
that its transport works instead of using a single socket.
In particular, this fixes #23774
By using the ssh configuration built into exec_command, we are able to
handle proxy jumps specified in ssh config files. This allows us to handle
bastion hosts when using wait_for_connection
ISSUE TYPE
COMPONENT NAME
wait_for_connection
ansible.plugins.connection.accelerate
ansible.plugins.connection.ssh
ansible.plugins.connection.paramiko_ssh
ansible.plugins.connection.winrm
ANSIBLE VERSION
ADDITIONAL INFORMATION
For testing purposes, here is a demo that illustrates the bug fixed in this change https://github.com/smikulcik/ansible-waitforconnection-bug-demo