Skip to content

[lr/client-running] libnm/client: don't consider client running if we got no NMManager

Lubomir Rintel requested to merge lr/client-running into main

We silently tolerate NetworkManager not responding at all (easily reproduced with e.g. pkill -STOP NetworkManager):

$ LIBNM_CLIENT_DEBUG=trace nmcli c show dummy666 libnm-dbus[23540]: [3316.81989] nmclient[ddafb84b8deebe4a]: new NMClient instance libnm-dbus[23540]: [3316.81998] nmclient[ddafb84b8deebe4a]: starting async initialization... libnm-dbus[23540]: [3316.82461] nmclient[ddafb84b8deebe4a]: name owner changed: (null) -> ":1.2" libnm-dbus[23540]: [3316.82464] nmclient[ddafb84b8deebe4a]: fetch all libnm-dbus[23540]: [3341.85715] nmclient[ddafb84b8deebe4a]: GetManagedObjects() call failed: Timeout was reached libnm-dbus[23540]: [3341.85740] nmclient[ddafb84b8deebe4a]: async init complete with success Error: dummy666 - no such connection profile. libnm-dbus[23540]: [3341.86723] nmclient[ddafb84b8deebe4a]: release all libnm-dbus[23540]: [3341.86798] nmclient[ddafb84b8deebe4a]: disposed $

As a comment in _dbus_get_managed_objects_cb() explains, this is sort of intentional. NetworkManager might just be shutting down and the libnm users will eventually see the objects once a new daemon starts up.

This may make some sense for long-running clients ("nmcli monitor", various desktop environments), but not for one-shot invocations that require the daemon running, such as those of "nmcli c ...".

Let's not consider the client running unless we actually got the manager object. That way the error message will make more sense:

$ LIBNM_CLIENT_DEBUG=trace nmcli c show dummy666 libnm-dbus[24730]: [5360.95480] nmclient[8cb898d3c891e210]: new NMClient instance libnm-dbus[24730]: [5360.95487] nmclient[8cb898d3c891e210]: starting async initialization... libnm-dbus[24730]: [5360.95901] nmclient[8cb898d3c891e210]: name owner changed: (null) -> ":1.2" libnm-dbus[24730]: [5360.95904] nmclient[8cb898d3c891e210]: fetch all libnm-dbus[24730]: [5385.98487] nmclient[8cb898d3c891e210]: GetManagedObjects() call failed: Timeout was reached libnm-dbus[24730]: [5385.98497] nmclient[8cb898d3c891e210]: async init complete with success Error: NetworkManager is not running. libnm-dbus[24730]: [5385.98571] nmclient[8cb898d3c891e210]: release all libnm-dbus[24730]: [5385.98698] nmclient[8cb898d3c891e210]: disposed $

Merge request reports

Loading