Updating network-manager and a snap that uses network manager can fail in post-refresh hooks

For an Ubuntu Core device, we are using the network-manager snap as well as another custom snap that creates/modifies Network Manager connection profiles in a post-refresh hook. We found a situation where when both snaps are refreshed with snap refresh (in one transaction), network-manager updates but when the second snap tries to run nmcli in the post-refresh hook, it fails with Error: NetworkManager is not running. If we run snap refresh again to update the custom snap, it works at that point.

My expectation is that the second snap would not start installing until the first snap is complete but it doesn’t seem to work this way. So what is the appropriate way to deal with this?

1 Like