diff options
author | Paride Legovini <paride.legovini@canonical.com> | 2020-08-27 17:20:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-27 11:20:35 -0400 |
commit | 1f3a225af78dbfbff75c3faad28a5dc8cad0d1e3 (patch) | |
tree | 745122ff254494ef9cf38411e3aee3ad23800000 /cloudinit/config | |
parent | 575750ac4a3abb6fdfa45e2cc65186df291d8ddf (diff) | |
download | vyos-cloud-init-1f3a225af78dbfbff75c3faad28a5dc8cad0d1e3.tar.gz vyos-cloud-init-1f3a225af78dbfbff75c3faad28a5dc8cad0d1e3.zip |
LXD: detach network from profile before deleting it (#542)
* LXD: detach network from profile before deleting it
When cleaning up the bridge network created by default by LXD as part
of the `lxd init` process detach the network its profile before deleting
it. LXD will otherwise refuse to delete it with error:
Error: The network is currently in use.
Discussion with LXD upstream: https://github.com/lxc/lxd/issues/7804.
LP: #1776958
* LXD bridge deletion: fail if bridge exists but can't be deleted
* LXD bridge deletion: remove useless failure logging
Diffstat (limited to 'cloudinit/config')
-rw-r--r-- | cloudinit/config/cc_lxd.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/cloudinit/config/cc_lxd.py b/cloudinit/config/cc_lxd.py index 7129c9c6..486037d9 100644 --- a/cloudinit/config/cc_lxd.py +++ b/cloudinit/config/cc_lxd.py @@ -283,14 +283,18 @@ def maybe_cleanup_default(net_name, did_init, create, attach, fail_assume_enoent = "failed. Assuming it did not exist." succeeded = "succeeded." if create: - msg = "Deletion of lxd network '%s' %s" + msg = "Detach of lxd network '%s' from profile '%s' %s" try: - _lxc(["network", "delete", net_name]) - LOG.debug(msg, net_name, succeeded) + _lxc(["network", "detach-profile", net_name, profile]) + LOG.debug(msg, net_name, profile, succeeded) except subp.ProcessExecutionError as e: if e.exit_code != 1: raise e - LOG.debug(msg, net_name, fail_assume_enoent) + LOG.debug(msg, net_name, profile, fail_assume_enoent) + else: + msg = "Deletion of lxd network '%s' %s" + _lxc(["network", "delete", net_name]) + LOG.debug(msg, net_name, succeeded) if attach: msg = "Removal of device '%s' from profile '%s' %s" |