Skip to content

Commit

Permalink
Fixed: Docker Unix socket was broken in 1.20b0
Browse files Browse the repository at this point in the history
  • Loading branch information
ualex73 committed Jan 12, 2025
1 parent a4f9584 commit ee4b858
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions custom_components/monitor_docker/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,19 @@ async def init(self, startCount=0):
if startCount > 0 and url is not None and url.find("unix:") != 0:
await asyncio.sleep(5)

# Check if it is a tcp connection or not
tcpConnection = False

# Do some debugging logging for TCP/TLS
if url is not None:
_LOGGER.debug("%s: Docker URL is '%s'", self._instance, url)

# Check for TLS if it is not unix
if url.find("tcp:") == 0 or url.find("http:") == 0:

# Set this to true, api needs to called different
tcpConnection = True

tlsverify = os.environ.get("DOCKER_TLS_VERIFY", None)
certpath = os.environ.get("DOCKER_CERT_PATH", None)
if tlsverify is None:
Expand Down Expand Up @@ -169,17 +176,22 @@ async def init(self, startCount=0):
os.environ["DOCKER_CERT_PATH"] = self._config[CONF_CERTPATH]

# Create a new connector with 5 seconds timeout, otherwise it can be very long
connector = TCPConnector()
session = ClientSession(
connector=connector,
timeout=ClientTimeout(
connect=5,
sock_connect=5,
total=10,
),
)
if tcpConnection:
connector = TCPConnector()
session = ClientSession(
connector=connector,
timeout=ClientTimeout(
connect=5,
sock_connect=5,
total=10,
),
)
self._api = aiodocker.Docker(
url=url, connector=connector, session=session
)
else:
self._api = aiodocker.Docker(url=url)

self._api = aiodocker.Docker(url=url, connector=connector, session=session)
except Exception as err:
exc_info = True if str(err) == "" else False
_LOGGER.error(
Expand Down

0 comments on commit ee4b858

Please sign in to comment.