diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2017-09-14 09:26:51 +0200 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2017-09-20 08:01:02 +0200 |
commit | 41b0e8c5a5e7cc7cf4a1c0fcc3210f56bbfb7af4 (patch) | |
tree | 4fb596754ad63a438c7b98d98036f9a93e413a81 | |
parent | 74845f80ec8213a431a3112afe23b05661cddb79 (diff) | |
download | NetworkManager-41b0e8c5a5e7cc7cf4a1c0fcc3210f56bbfb7af4.tar.gz |
manager: downgrade error message for missing dependencies
At startup the manager tries to create virtual devices without a
specific order and spits warnings when a device can't be realized
because the parent device is not yet created. These failures are not
something the user should worry about because the creation will be
retried when the parent appears.
A better approach is to return an error code from the device's
create_and_realize() telling that it failed because the parent doesn't
exist. In this way, the manager knows that the device isn't ready and
can avoid printing warning messages.
-rw-r--r-- | libnm-core/nm-errors.h | 3 | ||||
-rw-r--r-- | src/devices/nm-device-infiniband.c | 6 | ||||
-rw-r--r-- | src/devices/nm-device-macsec.c | 2 | ||||
-rw-r--r-- | src/devices/nm-device-macvlan.c | 2 | ||||
-rw-r--r-- | src/devices/nm-device-ppp.c | 2 | ||||
-rw-r--r-- | src/devices/nm-device-vlan.c | 4 | ||||
-rw-r--r-- | src/nm-manager.c | 11 |
7 files changed, 20 insertions, 10 deletions
diff --git a/libnm-core/nm-errors.h b/libnm-core/nm-errors.h index 35f7dc2f34..6bacc8da56 100644 --- a/libnm-core/nm-errors.h +++ b/libnm-core/nm-errors.h @@ -143,6 +143,8 @@ GQuark nm_crypto_error_quark (void); * activation request (eg, the #NMAccessPoint or #NMWimaxNsp) was not * found. * @NM_DEVICE_ERROR_VERSION_ID_MISMATCH: the version id did not match. + * @NM_DEVICE_ERROR_MISSING_DEPENDENCIES: the requested operation could not + * be completed due to missing dependencies. * * Device-related errors. * @@ -160,6 +162,7 @@ typedef enum { NM_DEVICE_ERROR_NOT_ALLOWED, /*< nick=NotAllowed >*/ NM_DEVICE_ERROR_SPECIFIC_OBJECT_NOT_FOUND, /*< nick=SpecificObjectNotFound >*/ NM_DEVICE_ERROR_VERSION_ID_MISMATCH, /*< nick=VersionIdMismatch >*/ + NM_DEVICE_ERROR_MISSING_DEPENDENCIES, /*< nick=MissingDependencies >*/ } NMDeviceError; #define NM_DEVICE_ERROR nm_device_error_quark () diff --git a/src/devices/nm-device-infiniband.c b/src/devices/nm-device-infiniband.c index 12b0845485..09ad2855b4 100644 --- a/src/devices/nm-device-infiniband.c +++ b/src/devices/nm-device-infiniband.c @@ -269,13 +269,13 @@ create_and_realize (NMDevice *device, } if (!parent) { - g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED, + g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_MISSING_DEPENDENCIES, "InfiniBand partitions can not be created without a parent interface"); return FALSE; } if (!NM_IS_DEVICE_INFINIBAND (parent)) { - g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED, + g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_MISSING_DEPENDENCIES, "Parent interface %s must be an InfiniBand interface", nm_device_get_iface (parent)); return FALSE; @@ -283,7 +283,7 @@ create_and_realize (NMDevice *device, priv->parent_ifindex = nm_device_get_ifindex (parent); if (priv->parent_ifindex <= 0) { - g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED, + g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_MISSING_DEPENDENCIES, "failed to get InfiniBand parent %s ifindex", nm_device_get_iface (parent)); return FALSE; diff --git a/src/devices/nm-device-macsec.c b/src/devices/nm-device-macsec.c index 3a43dd5c69..a117b8e216 100644 --- a/src/devices/nm-device-macsec.c +++ b/src/devices/nm-device-macsec.c @@ -692,7 +692,7 @@ create_and_realize (NMDevice *device, g_assert (s_macsec); if (!parent) { - g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED, + g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_MISSING_DEPENDENCIES, "MACsec devices can not be created without a parent interface"); return FALSE; } diff --git a/src/devices/nm-device-macvlan.c b/src/devices/nm-device-macvlan.c index 5d6328f1f4..8803beb524 100644 --- a/src/devices/nm-device-macvlan.c +++ b/src/devices/nm-device-macvlan.c @@ -234,7 +234,7 @@ create_and_realize (NMDevice *device, parent_ifindex = parent ? nm_device_get_ifindex (parent) : 0; if (parent_ifindex <= 0) { - g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED, + g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_MISSING_DEPENDENCIES, "MACVLAN devices can not be created without a parent interface"); g_return_val_if_fail (!parent, FALSE); return FALSE; diff --git a/src/devices/nm-device-ppp.c b/src/devices/nm-device-ppp.c index d786a62e22..81db1dc0f7 100644 --- a/src/devices/nm-device-ppp.c +++ b/src/devices/nm-device-ppp.c @@ -209,7 +209,7 @@ create_and_realize (NMDevice *device, int parent_ifindex; if (!parent) { - g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED, + g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_MISSING_DEPENDENCIES, "PPP devices can not be created without a parent interface"); return FALSE; } diff --git a/src/devices/nm-device-vlan.c b/src/devices/nm-device-vlan.c index c6c3f46f94..4d02b4ad2b 100644 --- a/src/devices/nm-device-vlan.c +++ b/src/devices/nm-device-vlan.c @@ -231,14 +231,14 @@ create_and_realize (NMDevice *device, g_assert (s_vlan); if (!parent) { - g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED, + g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_MISSING_DEPENDENCIES, "VLAN devices can not be created without a parent interface"); return FALSE; } parent_ifindex = nm_device_get_ifindex (parent); if (parent_ifindex <= 0) { - g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED, + g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_MISSING_DEPENDENCIES, "cannot retrieve ifindex of interface %s (%s): skip VLAN creation for now", nm_device_get_iface (parent), nm_device_get_type_desc (parent)); diff --git a/src/nm-manager.c b/src/nm-manager.c index 12f2ef0552..d0429fe9e5 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -1301,6 +1301,7 @@ system_create_virtual_device (NMManager *self, NMConnection *connection) gs_free char *iface = NULL; NMDevice *device = NULL, *parent = NULL; GError *error = NULL; + NMLogLevel log_level; g_return_val_if_fail (NM_IS_MANAGER (self), NULL); g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL); @@ -1381,8 +1382,14 @@ system_create_virtual_device (NMManager *self, NMConnection *connection) /* Create any backing resources the device needs */ if (!nm_device_create_and_realize (device, connection, parent, &error)) { - _LOG3W (LOGD_DEVICE, connection, "couldn't create the device: %s", - error->message); + log_level = g_error_matches (error, + NM_DEVICE_ERROR, + NM_DEVICE_ERROR_MISSING_DEPENDENCIES) + ? LOGL_DEBUG + : LOGL_ERR; + _NMLOG3 (log_level, LOGD_DEVICE, connection, + "couldn't create the device: %s", + error->message); g_error_free (error); remove_device (self, device, FALSE, TRUE); return NULL; |