error creating lxdbr0.

Bug #1776958 reported by Scott Moser
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cloud-init
Fix Released
Medium
Paride Legovini
cloud-init (Ubuntu)
Fix Released
Medium
Unassigned

Bug Description

$ cat > my.yaml <<EOF
#cloud-config
lxd:
  init:
    storage_backend: dir
  bridge:
    mode: new
    name: lxdbr0
    ipv4_address: 10.100.100.1
    ipv4_netmask: 24
    ipv4_dhcp_first: 10.100.100.100
    ipv4_dhcp_last: 10.100.100.200
    ipv4_nat: true
    domain: lxd
EOF

$ name=c1
$ lxc launch ubuntu-daily:cosmic $name "--config=user.user-data=$(cat my.yaml)"
$ sleep 10
$ lxc exec $name cat /run/cloud-init/result.json
{
 "v1": {
  "datasource": "DataSourceNoCloud [seed=/var/lib/cloud/seed/nocloud-net][dsmode=net]",
  "errors": [
   "('lxd', ProcessExecutionError(\"Unexpected error while running command.\\nCommand: ['lxc', 'network', 'create', 'lxdbr0', 'ipv4.address=10.100.100.1/24', 'ipv4.dhcp.ranges=10.100.100.100-10.100.100.200', 'ipv6.address=none', 'dns.domain=lxd', '--force-local']\\nExit code: 1\\nReason: -\\nStdout: \\nStderr: Error: The network already exists\",))"
  ]
 }
}

The integration test case tests/cloud_tests/testcases/modules/lxd_bridge.py
is demonstrates this failure on cosmic. It currently only occurs on
cosmic but will occur anywhere with lxd 3.1.0.

ProblemType: Bug
DistroRelease: Ubuntu 18.10
Package: cloud-init 18.2-64-gbbcc5e82-0ubuntu1
ProcVersionSignature: Ubuntu 4.15.0-22.24-generic 4.15.17
Uname: Linux 4.15.0-22-generic x86_64
ApportVersion: 2.20.10-0ubuntu3
Architecture: amd64
CloudName: LXD
Date: Thu Jun 14 18:34:15 2018
PackageArchitecture: all
ProcEnviron:
 TERM=xterm-256color
 PATH=(custom, no user)
 LANG=C.UTF-8
SourcePackage: cloud-init
UpgradeStatus: No upgrade log present (probably fresh install)
cloud-init-log-warnings:
 2018-06-14 18:34:08,417 - util.py[WARNING]: Running module lxd (<module 'cloudinit.config.cc_lxd' from '/usr/lib/python3/dist-packages/cloudinit/config/cc_lxd.py'>) failed
 cloudinit.util.ProcessExecutionError: Unexpected error while running command.
 Stderr: Error: The network already exists

Related branches

Revision history for this message
Scott Moser (smoser) wrote :
Changed in cloud-init:
status: New → Confirmed
Changed in cloud-init (Ubuntu):
status: New → Confirmed
Changed in cloud-init:
importance: Undecided → Medium
Changed in cloud-init (Ubuntu):
importance: Undecided → Medium
Revision history for this message
Scott Moser (smoser) wrote :

The change in behavior of lxd init was filed as an upstream issue at https://github.com/lxc/lxd/issues/4649 .

Revision history for this message
Stéphane Graber (stgraber) wrote :

The cloud-init integration would benefit from using the `--preseed` feature of "lxd init" moving forward (on anything that's >= 3.0) as that should let you do pretty much straight yaml passthrough to LXD and avoid having to update the cloud-init schema every time a new feature is added.

Revision history for this message
Chad Smith (chad.smith) wrote :

An upstream commit landed for this bug.

To view that commit see the following URL:
https://git.launchpad.net/cloud-init/commit/?id=4ce67201

Changed in cloud-init:
status: Confirmed → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package cloud-init - 18.2-77-g4ce67201-0ubuntu1

---------------
cloud-init (18.2-77-g4ce67201-0ubuntu1) cosmic; urgency=medium

  * New upstream snapshot.
    - lxd: Delete default network and detach device if lxd-init created them.
      (LP: #1776958)
    - openstack: avoid unneeded metadata probe on non-openstack platforms
      (LP: #1776701)
    - stages: fix tracebacks if a module stage is undefined or empty
      [Robert Schweikert] (LP: #1770462)
    - Be more safe on string/bytes when writing multipart user-data to disk.
      (LP: #1768600)
    - Fix get_proc_env for pids that have non-utf8 content in environment.
      (LP: #1775371)
    - tests: fix salt_minion integration test on bionic and later
    - tests: provide human-readable integration test summary when --verbose
    - tests: skip chrony integration tests on lxd running artful or older
    - test: add optional --preserve-instance arg to integraiton tests
    - netplan: fix mtu if provided by network config for all rendered types
      (LP: #1774666)
    - tests: remove pip install workarounds for pylxd, take upstream fix.
    - subp: support combine_capture argument.
    - tests: ordered tox dependencies for pylxd install

 -- Chad Smith <email address hidden> Fri, 15 Jun 2018 20:05:07 -0600

Changed in cloud-init (Ubuntu):
status: Confirmed → Fix Released
Revision history for this message
Scott Moser (smoser) wrote : Fixed in cloud-init version 18.3.

This bug is believed to be fixed in cloud-init in version 18.3. If this is still a problem for you, please make a comment and set the state back to New

Thank you.

Changed in cloud-init:
status: Fix Committed → Fix Released
Revision history for this message
Paride Legovini (paride) wrote :
Download full text (4.1 KiB)

This is happening again with Focal and Groovy:

tox -e citest -- run --os-name=focal --platform=lxd --preserve-data --data-dir=results --verbose --deb=cloud-init_20.2-134-g747723a4-1\~bddeb_all.deb --test-config=tests/cloud_tests/testcases/modules/lxd_bridge.yaml

=============================================

2020-08-21 15:56:11,115 - subp.py[DEBUG]: Running command ['lxd', 'waitready', '--timeout=300'] with allowed return codes [0] (shell=False, capture=True)
2020-08-21 15:56:20,165 - subp.py[DEBUG]: Running command ['lxd', 'init', '--auto', '--storage-backend=dir'] with allowed return codes [0] (shell=False, capture=True)
2020-08-21 15:56:23,684 - subp.py[DEBUG]: Running command ['lxc', 'network', 'delete', 'lxdbr0', '--force-local'] with allowed return codes [0] (shell=False, capture=True)
2020-08-21 15:56:24,413 - cc_lxd.py[DEBUG]: Deletion of lxd network 'lxdbr0' failed. Assuming it did not exist.
2020-08-21 15:56:24,413 - subp.py[DEBUG]: Running command ['lxc', 'profile', 'device', 'remove', 'default', 'eth0', '--force-local'] with allowed return codes [0] (shell=False, capture=True)
2020-08-21 15:56:24,491 - cc_lxd.py[DEBUG]: Removal of device 'eth0' from profile 'default' succeeded.
2020-08-21 15:56:24,491 - cc_lxd.py[DEBUG]: Creating lxd bridge: network create lxdbr0 ipv4.address=10.100.100.1/24 ipv4.dhcp.ranges=10.100.100.100-10.100.100.200 ipv6.address=none dns.domain=lxd
2020-08-21 15:56:24,492 - subp.py[DEBUG]: Running command ['lxc', 'network', 'create', 'lxdbr0', 'ipv4.address=10.100.100.1/24', 'ipv4.dhcp.ranges=10.100.100.100-10.100.100.200', 'ipv6.address=none', 'dns.domain=lxd', '--force-local'] with allowed return codes [0] (shell=False, capture=True)
2020-08-21 15:56:24,569 - handlers.py[DEBUG]: finish: modules-final/config-lxd: FAIL: running config-lxd with frequency once-per-instance
2020-08-21 15:56:24,569 - util.py[WARNING]: Running module lxd (<module 'cloudinit.config.cc_lxd' from '/usr/lib/python3/dist-packages/cloudinit/config/cc_lxd.py'>) failed
2020-08-21 15:56:24,569 - util.py[DEBUG]: Running module lxd (<module 'cloudinit.config.cc_lxd' from '/usr/lib/python3/dist-packages/cloudinit/config/cc_lxd.py'>) failed
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/cloudinit/stages.py", line 848, in _run_modules
    ran, _r = cc.run(run_name, mod.handle, func_args,
  File "/usr/lib/python3/dist-packages/cloudinit/cloud.py", line 54, in run
    return self._runners.run(name, functor, args, freq, clear_on_fail)
  File "/usr/lib/python3/dist-packages/cloudinit/helpers.py", line 185, in run
    results = functor(*args)
  File "/usr/lib/python3/dist-packages/cloudinit/config/cc_lxd.py", line 152, in handle
    _lxc(cmd_create)
  File "/usr/lib/python3/dist-packages/cloudinit/config/cc_lxd.py", line 268, in _lxc
    subp.subp(['lxc'] + list(cmd) + ["--force-local"], update_env=env)
  File "/usr/lib/python3/dist-packages/cloudinit/subp.py", line 290, in subp
    raise ...

Read more...

Changed in cloud-init:
status: Fix Released → New
Revision history for this message
Paride Legovini (paride) wrote :
Revision history for this message
Paride Legovini (paride) wrote :

It seems we require an extra step:

  lxc network detach-profile lxdbr0 default

otherwise the deletion fails with:

  Error: The network is currently in use.

Revision history for this message
Paride Legovini (paride) wrote :
Paride Legovini (paride)
Changed in cloud-init (Ubuntu):
status: Fix Released → New
Changed in cloud-init:
assignee: nobody → Paride Legovini (paride)
status: New → Triaged
Revision history for this message
Chad Smith (chad.smith) wrote :
Changed in cloud-init (Ubuntu):
status: New → Fix Committed
Changed in cloud-init:
status: Triaged → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package cloud-init - 20.3-15-g6d332e5c-0ubuntu1

---------------
cloud-init (20.3-15-g6d332e5c-0ubuntu1) groovy; urgency=medium

  * d/cloud-init.postinst: fix the grub install device for NVMe-rooted
    instances on upgrade. (LP: #1889555)
  * d/cloud-init.templates: add RbxCloud to Choices-C.
  * Add d/clean to fully clean the build artifacts.
  * d/control:
    - Bump Standards-Version to 4.5.0, no changes needed.
    - B-D on debhelper-compat; drop d/compat.
  * Bump the debhelper compat level to 13. Required changes:
    - Stop including the dh systemd plugin.
    - Switch from dh_systemd_start to dh_installsystemd
  * New upstream snapshot.
    - create a shutdown_command method in distro classes (#567)
      [Emmanuel Thomé]
    - user_data: remove unused constant (#566)
    - network: Fix type and respect name when rendering vlan in
      sysconfig. (#541) [Eduardo Otubo] (LP: #1788915, #1826608)
    - Retrieve SSH keys from IMDS first with OVF as a fallback (#509)
      [Thomas Stringer]
    - Add jqueuniet as contributor (#569) [Johann Queuniet]
    - distros: minor typo fix (#562)
    - Bump the integration-requirements versioned dependencies (#565)
      [Paride Legovini]
    - network-config-format-v1: fix typo in nameserver example (#564)
      [Stanislas]
    - Run cloud-init-local.service after the hv_kvp_daemon (#505)
      [Robert Schweikert]
    - Add method type hints for Azure helper (#540) [Johnson Shi]
    - systemd: add Before=shutdown.target when Conflicts=shutdown.target is
      used (#546) [Paride Legovini]
    - LXD: detach network from profile before deleting it (#542)
      [Paride Legovini] (LP: #1776958)
    - redhat spec: add missing BuildRequires (#552) [Paride Legovini]

 -- Chad Smith <email address hidden> Tue, 15 Sep 2020 20:19:10 -0600

Changed in cloud-init (Ubuntu):
status: Fix Committed → Fix Released
Revision history for this message
Chad Smith (chad.smith) wrote : Fixed in cloud-init version 20.4.

This bug is believed to be fixed in cloud-init in version 20.4. If this is still a problem for you, please make a comment and set the state back to New

Thank you.

Changed in cloud-init:
status: Fix Committed → Fix Released
Revision history for this message
James Falcon (falcojr) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.