Merge pull request #1554 from jpnurmi/netplan-generate

network: reset SNAP when calling netplan in dry-run mode
This commit is contained in:
Dan Bungert 2023-02-10 13:45:40 -07:00 committed by GitHub
commit 4855fd316d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 2 deletions

View File

@ -15,6 +15,7 @@
import abc
import asyncio
import contextlib
import logging
import os
import subprocess
@ -294,10 +295,15 @@ class BaseNetworkController(BaseController):
if os.path.exists('/lib/netplan/generate'):
# If netplan appears to be installed, run generate to
# at least test that what we wrote is acceptable to
# netplan.
# netplan but clear the SNAP environment variable to
# avoid that netplan thinks its running in a snap and
# tries to call netplan over the system bus.
env = os.environ.copy()
with contextlib.suppress(KeyError):
del env['SNAP']
await arun_command(
['netplan', 'generate', '--root', self.root],
check=True)
check=True, env=env)
else:
if devs_to_down or devs_to_delete:
try: