mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-12 11:46:31 +00:00
Avoid early DNS plug-in start (#5922)
* Avoid early DNS plug-in start A connectivity check can potentially be triggered before the DNS plug-in is loaded. Avoid calling restart on the DNS plug-in before it got initially loaded. This prevents starting before attaching. The attaching makes sure that the DNS plug-in container is recreated before the DNS plug-in is initially started, which is e.g. needed by a potentially hassio network configuration change (e.g. the migration required to enable/disable IPv6 on the hassio network, see #5879). * Mock DNS plug-in running
This commit is contained in:
parent
2a88cb9339
commit
42f885595e
@ -158,6 +158,7 @@ class NetworkManager(CoreSysAttributes):
|
||||
DBUS_ATTR_PRIMARY_CONNECTION in changed
|
||||
and changed[DBUS_ATTR_PRIMARY_CONNECTION]
|
||||
and changed[DBUS_ATTR_PRIMARY_CONNECTION] != DBUS_OBJECT_BASE
|
||||
and await self.sys_plugins.dns.is_running()
|
||||
):
|
||||
await self.sys_plugins.dns.restart()
|
||||
|
||||
|
@ -211,7 +211,7 @@ class PluginDns(PluginBase):
|
||||
try:
|
||||
await self.instance.restart()
|
||||
except DockerError as err:
|
||||
raise CoreDNSError("Can't start CoreDNS plugin", _LOGGER.error) from err
|
||||
raise CoreDNSError("Can't restart CoreDNS plugin", _LOGGER.error) from err
|
||||
|
||||
async def start(self) -> None:
|
||||
"""Run CoreDNS."""
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
# pylint: disable=protected-access
|
||||
import asyncio
|
||||
from unittest.mock import PropertyMock, patch
|
||||
from unittest.mock import AsyncMock, PropertyMock, patch
|
||||
|
||||
import pytest
|
||||
|
||||
@ -92,7 +92,12 @@ async def test_dns_restart_on_connection_change(
|
||||
):
|
||||
"""Test dns plugin is restarted when primary connection changes."""
|
||||
await coresys.host.network.load()
|
||||
with patch.object(PluginDns, "restart") as restart:
|
||||
with (
|
||||
patch.object(PluginDns, "restart") as restart,
|
||||
patch.object(
|
||||
PluginDns, "is_running", new_callable=AsyncMock, return_value=True
|
||||
),
|
||||
):
|
||||
network_manager_service.emit_properties_changed({"PrimaryConnection": "/"})
|
||||
await network_manager_service.ping()
|
||||
restart.assert_not_called()
|
||||
|
Loading…
x
Reference in New Issue
Block a user