oboki commented on code in PR #38466:
URL: https://github.com/apache/airflow/pull/38466#discussion_r1538300908


##########
airflow/providers/docker/operators/docker.py:
##########
@@ -343,13 +345,21 @@ def hook(self) -> DockerHook:
             assert_hostname=self.tls_hostname,
             ssl_version=self.tls_ssl_version,
         )
-        return DockerHook(
-            docker_conn_id=self.docker_conn_id,
-            base_url=self.docker_url,
-            version=self.api_version,
-            tls=tls_config,
-            timeout=self.timeout,
-        )
+        hook = None
+        for url in self.docker_url:
+            hook = DockerHook(
+                docker_conn_id=self.docker_conn_id,
+                base_url=url,
+                version=self.api_version,
+                tls=tls_config,
+                timeout=self.timeout
+            )
+            try:
+                hook.get_conn()
+                return hook
+            except Exception as e:
+                self.log.error(f"Failed to establish connection to Docker host 
{url}: {e}")
+        return hook

Review Comment:
   Adding an error-raising step instead of returning a nullable hook cause the 
following two tests to fail:
   
   ```log
   ================================== short test summary info 
===================================
   FAILED 
tests/providers/docker/operators/test_docker.py::test_on_kill_client_not_created
 - Exception: Failed to establish connection to Docker host.
   FAILED 
tests/providers/docker/operators/test_docker_swarm.py::TestDockerSwarmOperator::test_on_kill_client_not_created
 - Exception: Failed to establish connection to Docker host.
   ========================= 2 failed, 133 passed, 2 warnings in 21.62s 
=========================
   ```
   
   I'm not very good at dealing with mocks, could I get some additional support?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to