Fix ansible-test issues with detecting docker host and forwarding ports (#81726)

* Properly detect docker host using ssh

* Disable ControlPath when creating SSH port forwards

* typo fix

Co-authored-by: Matt Clay <matt@mystile.com>

* Add clog frag

---------

Co-authored-by: Matt Clay <matt@mystile.com>
pull/81733/head
Matt Martz 1 year ago committed by GitHub
parent 710c0a264e
commit 3ec7a6e0db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,5 @@
bugfixes:
- ansible-test - Properly detect docker host when using ``ssh://`` protocol for connecting to the docker daemon.
- ansible-test - Explicitly supply ``ControlPath=none`` when setting up port fowarding over SSH to address
the scenario where the local ssh configuration uses ``ControlPath`` for all hosts, and would prevent
ports to be forwarded after the initial connection to the host.

@ -496,7 +496,7 @@ def get_docker_hostname() -> str:
"""Return the hostname of the Docker service."""
docker_host = os.environ.get('DOCKER_HOST')
if docker_host and docker_host.startswith('tcp://'):
if docker_host and docker_host.startswith(('tcp://', 'ssh://')):
try:
hostname = urllib.parse.urlparse(docker_host)[1].split(':')[0]
display.info('Detected Docker host: %s' % hostname, verbosity=1)

@ -245,6 +245,7 @@ def create_ssh_port_forwards(
"""
options: dict[str, t.Union[str, int]] = dict(
LogLevel='INFO', # info level required to get messages on stderr indicating the ports assigned to each forward
ControlPath='none', # if the user has ControlPath set up for every host, it will prevent creation of forwards
)
cli_args = []

Loading…
Cancel
Save