Use controlled execution environment, to avoid failure if PATH is unset (LP: #1959570)#336
Use controlled execution environment, to avoid failure if PATH is unset (LP: #1959570)#336slyon merged 3 commits intocanonical:mainfrom
Conversation
|
This fix seems to be working generally. There's still a brief interruption of the network connectivity, while restarting the "snap.network-manager.networkmanager.service" daemon (obviously), but the SSH connection is recovered after a few seconds. I've built a core22 base snap, using https://launchpad.net/~slyon/+archive/ubuntu/lp1959570 and a UC22 image out of this to run this test (all executed over an SSH connection): |
daniloegea
left a comment
There was a problem hiding this comment.
Would it be enough settings the environment variables only once via os.environ in the entry point of the python code?
This is to allow execution in constrained environments, like early boot or Ubuntu Core 20/22 where the PATH environment variable might not be set. E.g. for the 'nmcli' binary: It could be /usr/bin/nmcli for normal NetworkManager or /snap/bin/nmcli -> /snap/bin/network-manager.nmcli for NM snap
Also, consider /usr/bin/nmcli and /snap/bin/nmcli -> /snap/bin/network-manager.nmcli as valid implementations of 'nmcli', so it can be exected in a minimal environment, without the PATH variable being set (e.g. early boot or Ubuntu Core 20/22).
|
All tests green. I've re-built a package in the above-mentioned PPA + core22 base snap + UC22 image and run the reproducer from the bug report: Merging. |
…et (LP: #1959570) (#336) Use a controlled execution environment. This is to allow execution in constrained environments, like early boot or Ubuntu Core 20/22 where the PATH environment variable might not be set Also, handle nmcli's "NetworkManager not running" error gracefully. Considering /usr/bin/nmcli for normal NetworkManager and /snap/bin/nmcli -> /snap/bin/network-manager.nmcli for NetworkManager snap as valid implementations. COMMITS: * cli: use controlled execution environment This is to allow execution in constrained environments, like early boot or Ubuntu Core 20/22 where the PATH environment variable might not be set. E.g. for the 'nmcli' binary: It could be /usr/bin/nmcli for normal NetworkManager or /snap/bin/nmcli -> /snap/bin/network-manager.nmcli for NM snap * cli:status:ip: Introduce utils.nmcli_out() * cli:apply: Handle 'nmcli' NM not running gracefully Also, consider /usr/bin/nmcli and /snap/bin/nmcli -> /snap/bin/network-manager.nmcli as valid implementations of 'nmcli', so it can be exected in a minimal environment, without the PATH variable being set (e.g. early boot or Ubuntu Core 20/22).
Description
Use a controlled execution environment.
This is to allow execution in constrained environments, like early boot or
Ubuntu Core 20/22 where the PATH environment variable might not be set
Also, handle
nmcli's "NetworkManager not running" error gracefully.Considering
/usr/bin/nmclifor normal NetworkManager and/snap/bin/nmcli -> /snap/bin/network-manager.nmclifor NetworkManager snap as valid implementations.Checklist
make checksuccessfully.make check-coverage).