Handle exception on DNS for add-ons (#2042)

* Handle exception on DNS for add-ons

* fix logger

* capture exception
This commit is contained in:
Pascal Vizeli 2020-09-11 19:35:04 +02:00 committed by GitHub
parent 7be508214a
commit da83edf231
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -26,7 +26,7 @@ from ..const import (
SECURITY_PROFILE,
)
from ..coresys import CoreSys
from ..exceptions import DockerAPIError
from ..exceptions import CoreDNSError, DockerAPIError
from ..utils import process_lock
from .interface import DockerInterface
@ -379,7 +379,13 @@ class DockerAddon(DockerInterface):
_LOGGER.info("Start Docker add-on %s with version %s", self.image, self.version)
# Write data to DNS server
self.sys_plugins.dns.add_host(ipv4=self.ip_address, names=[self.addon.hostname])
try:
self.sys_plugins.dns.add_host(
ipv4=self.ip_address, names=[self.addon.hostname]
)
except CoreDNSError as err:
_LOGGER.warning("Can't update DNS for %s", self.name)
self.sys_capture_exception(err)
def _install(
self, tag: str, image: Optional[str] = None, latest: bool = False
@ -505,5 +511,9 @@ class DockerAddon(DockerInterface):
Need run inside executor.
"""
if self.ip_address != NO_ADDDRESS:
self.sys_plugins.dns.delete_host(self.addon.hostname)
try:
self.sys_plugins.dns.delete_host(self.addon.hostname)
except CoreDNSError as err:
_LOGGER.warning("Can't update DNS for %s", self.name)
self.sys_capture_exception(err)
super()._stop(remove_container)