Skip to content

Commit

Permalink
Update DNS plug-in on network change
Browse files Browse the repository at this point in the history
Restart the DNS plug-in when the primary network changes network
changes. This makes sure any potential host OS DNS configuration
changes get picked up by the DNS plug-in as well.
  • Loading branch information
agners committed Oct 9, 2024
1 parent e2b25fe commit 042107a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions supervisor/host/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
from ..dbus.const import (
DBUS_ATTR_CONNECTION_ENABLED,
DBUS_ATTR_CONNECTIVITY,
DBUS_ATTR_PRIMARY_CONNECTION,
DBUS_IFACE_NM,
DBUS_OBJECT_BASE,
DBUS_SIGNAL_NM_CONNECTION_ACTIVE_CHANGED,
ConnectionStateType,
ConnectivityState,
Expand Down Expand Up @@ -142,12 +144,24 @@ async def _check_connectivity_changed(
self, interface: str, changed: dict[str, Any], invalidated: list[str]
):
"""Check if connectivity property has changed."""
_LOGGER.info(
f"_check_connectivity_changed: {interface} changed {changed} invalidated {invalidated}"

Check failure on line 148 in supervisor/host/network.py

View workflow job for this annotation

GitHub Actions / Check ruff

Ruff (G004)

supervisor/host/network.py:148:13: G004 Logging statement uses f-string
)
if interface != DBUS_IFACE_NM:
return

connectivity_check: bool | None = changed.get(DBUS_ATTR_CONNECTION_ENABLED)
connectivity: bool | None = changed.get(DBUS_ATTR_CONNECTIVITY)

# This potentially updated the DNS configuration. Make sure the DNS plug-in
# picks up the latest settings.
if (
DBUS_ATTR_PRIMARY_CONNECTION in changed
and changed[DBUS_ATTR_PRIMARY_CONNECTION]
and changed[DBUS_ATTR_PRIMARY_CONNECTION] != DBUS_OBJECT_BASE
):
await self.sys_plugins.dns.restart()

if (
connectivity_check is True
or DBUS_ATTR_CONNECTION_ENABLED in invalidated
Expand Down

0 comments on commit 042107a

Please sign in to comment.