-
Notifications
You must be signed in to change notification settings - Fork 216
Use controlled execution environment, to avoid failure if PATH is unset (LP: #1959570) #336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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):
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
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/nmcli
for normal NetworkManager and/snap/bin/nmcli -> /snap/bin/network-manager.nmcli
for NetworkManager snap as valid implementations.Checklist
make check
successfully.make check-coverage
).