mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-25 18:16:32 +00:00
Prune network/interface on repair (#1340)
* Prune network/interface on repair * Force disconnect
This commit is contained in:
parent
615e68b29b
commit
74485262e7
@ -285,6 +285,9 @@ class AddonManager(CoreSysAttributes):
|
|||||||
|
|
||||||
for addon in needs_repair:
|
for addon in needs_repair:
|
||||||
_LOGGER.info("Start repair for add-on: %s", addon.slug)
|
_LOGGER.info("Start repair for add-on: %s", addon.slug)
|
||||||
|
await self.sys_run_in_executor(
|
||||||
|
self.sys_docker.network.stale_cleanup, addon.instance.name
|
||||||
|
)
|
||||||
|
|
||||||
with suppress(DockerAPIError, KeyError):
|
with suppress(DockerAPIError, KeyError):
|
||||||
# Need pull a image again
|
# Need pull a image again
|
||||||
|
@ -178,3 +178,10 @@ class DockerAPI:
|
|||||||
_LOGGER.debug("Volumes prune: %s", output)
|
_LOGGER.debug("Volumes prune: %s", output)
|
||||||
except docker.errors.APIError as err:
|
except docker.errors.APIError as err:
|
||||||
_LOGGER.warning("Error for volumes prune: %s", err)
|
_LOGGER.warning("Error for volumes prune: %s", err)
|
||||||
|
|
||||||
|
_LOGGER.info("Prune stale networks")
|
||||||
|
try:
|
||||||
|
output = self.docker.api.prune_networks()
|
||||||
|
_LOGGER.debug("Networks prune: %s", output)
|
||||||
|
except docker.errors.APIError as err:
|
||||||
|
_LOGGER.warning("Error for networks prune: %s", err)
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
"""Internal network manager for Hass.io."""
|
"""Internal network manager for Hass.io."""
|
||||||
|
from contextlib import suppress
|
||||||
from ipaddress import IPv4Address
|
from ipaddress import IPv4Address
|
||||||
import logging
|
import logging
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
@ -107,3 +108,11 @@ class DockerNetwork:
|
|||||||
except docker.errors.APIError as err:
|
except docker.errors.APIError as err:
|
||||||
_LOGGER.warning("Can't disconnect container from default: %s", err)
|
_LOGGER.warning("Can't disconnect container from default: %s", err)
|
||||||
raise DockerAPIError() from None
|
raise DockerAPIError() from None
|
||||||
|
|
||||||
|
def stale_cleanup(self, container_name: str):
|
||||||
|
"""Remove force a container from Network.
|
||||||
|
|
||||||
|
Fix: https://github.com/moby/moby/issues/23302
|
||||||
|
"""
|
||||||
|
with suppress(docker.errors.APIError):
|
||||||
|
self.network.disconnect(container_name, force=True)
|
||||||
|
@ -605,6 +605,11 @@ class HomeAssistant(JsonConfig, CoreSysAttributes):
|
|||||||
return
|
return
|
||||||
|
|
||||||
_LOGGER.info("Repair Home Assistant %s", self.version)
|
_LOGGER.info("Repair Home Assistant %s", self.version)
|
||||||
|
await self.sys_run_in_executor(
|
||||||
|
self.sys_docker.network.stale_cleanup, self.instance.name
|
||||||
|
)
|
||||||
|
|
||||||
|
# Pull image
|
||||||
try:
|
try:
|
||||||
await self.instance.install(self.version)
|
await self.instance.install(self.version)
|
||||||
except DockerAPIError:
|
except DockerAPIError:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user