From d2b706df056792eedfefc18b2f866d8edf3963e0 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Wed, 20 Oct 2021 15:06:36 +0200 Subject: [PATCH] Ignore disappearing network devices while querying them (#3249) Sometimes NetworkManager network devices disappear while we are query them. Presumably those are network interfaces generated by Docker. Skip them and print a warning. --- supervisor/dbus/network/__init__.py | 6 +++++- supervisor/utils/dbus.py | 7 +++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/supervisor/dbus/network/__init__.py b/supervisor/dbus/network/__init__.py index f4f44f0a5..1152156b5 100644 --- a/supervisor/dbus/network/__init__.py +++ b/supervisor/dbus/network/__init__.py @@ -13,6 +13,7 @@ from ...exceptions import ( DBusError, DBusFatalError, DBusInterfaceError, + DBusInterfaceMethodError, HostNotSupportedError, ) from ...utils.dbus import DBus @@ -162,7 +163,10 @@ class NetworkManager(DBusInterface): # Connect to interface try: await interface.connect() - except DBusFatalError as err: + except (DBusFatalError, DBusInterfaceMethodError) as err: + # Docker creates and deletes interfaces quite often, sometimes + # this causes a race condition: A device disappears while we + # try to query it. Ignore those cases. _LOGGER.warning("Can't process %s: %s", device, err) continue except Exception as err: # pylint: disable=broad-except diff --git a/supervisor/utils/dbus.py b/supervisor/utils/dbus.py index 02597503c..1b6c6edc9 100644 --- a/supervisor/utils/dbus.py +++ b/supervisor/utils/dbus.py @@ -162,11 +162,10 @@ class DBus: ) if reply.message_type == MessageType.ERROR: - if reply.error_name in ( - "org.freedesktop.DBus.Error.ServiceUnknown", - "org.freedesktop.DBus.Error.UnknownMethod", - ): + if reply.error_name == "org.freedesktop.DBus.Error.ServiceUnknown": raise DBusInterfaceError(reply.body[0]) + if reply.error_name == "org.freedesktop.DBus.Error.UnknownMethod": + raise DBusInterfaceMethodError(reply.body[0]) if reply.error_name == "org.freedesktop.DBus.Error.Disconnected": raise DBusNotConnectedError() if reply.body and len(reply.body) > 0: