Taragolis commented on code in PR #38466:
URL: https://github.com/apache/airflow/pull/38466#discussion_r1538671107
##########
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()
Review Comment:
Yeah, I guess `hook.api_client.ping()` ping would be enough
```python
from docker import APIClient
client = APIClient("unix://var/run/docker.sock", version="1.30")
print(client.ping())
try:
client = APIClient("unix://foo/bar/spam.egg", version="1.30")
if not client.ping():
msg = "Unable to retrieve success response on ping docker daemon"
raise ConnectionError(msg)
except Exception as ex:
print("NOPE")
```
Maybe even better to add it into the hook right after client created
https://github.com/apache/airflow/blob/c92b8db0d40672e6dd7e8cf064193e4371fcb2e8/airflow/providers/docker/hooks/docker.py#L149-L152
--
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]