Container created with profile does not have volatile.eth0.hwaddr before first start

We have two LXD hosts creating containers with default profile results in different containers, on the second host containers do not have volatile.eth0.hwaddr option.
What can cause this? Does it matter the different LXD versions (3.0.3, 3.0.4)?

First host

root@pilot-lxc:~# lxd --version                                                                                                                                                                                                                                                                                              
3.0.3
                                                                                                                                                                                                                                                                
root@pilot-lxc:~# lxc init images:debian/10/amd64 -p default test-container-1                                                                                  
Creating test-container-1
root@pilot-lxc:~# lxc profile show default                                     
config: {}
description: Default LXD profile
devices:
  eth0:
    name: eth0
    nictype: bridged
    parent: br0
    type: nic
  root:
    path: /
    pool: default
    type: disk
name: default
used_by:
- /1.0/containers/test-container-1

root@pilot-lxc:~# lxc config show test-container-1 
architecture: x86_64
config:
  image.architecture: amd64
  image.description: Debian buster amd64 (20201029_05:24)
  image.os: Debian
  image.release: buster
  image.serial: "20201029_05:24"
  volatile.apply_template: create
  volatile.base_image: 6c982b800e35a225d75b555b866dbc3c78a25256734a1af752de541a6f50c69c
  **volatile.eth0.hwaddr: 00:16:3e:48:50:ca**
  volatile.idmap.base: "0"
  volatile.idmap.next: '[{"Isuid":true,"Isgid":false,"Hostid":100000,"Nsid":0,"Maprange":65536},{"Isuid":false,"Isgid":true,"Hostid":100000,"Nsid":0,"Maprange":65536}]'
  volatile.last_state.idmap: '[{"Isuid":true,"Isgid":false,"Hostid":100000,"Nsid":0,"Maprange":65536},{"Isuid":false,"Isgid":true,"Hostid":100000,"Nsid":0,"Maprange":65536}]'
devices: {}
ephemeral: false
profiles:
- default
stateful: false
description: ""

On second host the same
Container config has not volatile.eth0.hwaddr option

root@lxd-cihost:~# lxd --version
3.0.4

root@lxd-cihost:~# lxc init images:debian/10/amd64 -p default test-container-1
Creating test-container-1
root@lxd-cihost:~# lxc profile show default 
config: {}
description: Default LXD profile
devices:
  eth0:
    name: eth0
    nictype: bridged
    parent: br0
    type: nic
  root:
    path: /
    pool: default
    type: disk
name: default
used_by:
- /1.0/containers/test-container-1
root@lxd-cihost:~# lxc config show test-container-1
architecture: x86_64
config:
  image.architecture: amd64
  image.description: Debian buster amd64 (20201029_05:24)
  image.os: Debian
  image.release: buster
  image.serial: "20201029_05:24"
  volatile.apply_template: create
  volatile.base_image: 6c982b800e35a225d75b555b866dbc3c78a25256734a1af752de541a6f50c69c
  volatile.idmap.base: "0"
  volatile.idmap.next: '[{"Isuid":true,"Isgid":false,"Hostid":1000000,"Nsid":0,"Maprange":1000000000},{"Isuid":false,"Isgid":true,"Hostid":1000000,"Nsid":0,"Maprange":1000000000}]'
  volatile.last_state.idmap: '[]'
devices: {}
ephemeral: false
profiles:
- default
stateful: false
description: ""

Your subject mentions “not started”, has the container never been started?

yes, never started

And if you start it the entry is added?

Yes, and after stopping the container it persists.

On our 3.0.3. LXD system the entry exists after container has been created.
I’ve read in the 3.0.4. release notes that:

If I do:
lxc network attach br0 test-container-1 eth0 eth0
The entry will be shown.

Seems ok using the snap:

root@v1:~# snap install lxd --channel 3.0/stable
2020-10-29T16:36:17Z INFO Waiting for automatic snapd restart...
lxd (3.0/stable) 3.0.4 from Canonical✓ installed
root@v1:~# lxd init --auto
root@v1:~# lxc init images:debian/buster c1
root@v1:~# lxc config show c1 --expanded
architecture: x86_64
config:
  image.architecture: amd64
  image.description: Debian buster amd64 (20201029_05:24)
  image.os: Debian
  image.release: buster
  image.serial: "20201029_05:24"
  volatile.apply_template: create
  volatile.base_image: 6c982b800e35a225d75b555b866dbc3c78a25256734a1af752de541a6f50c69c
  volatile.eth0.hwaddr: 00:16:3e:72:00:d0
  volatile.idmap.base: "0"
  volatile.idmap.next: '[{"Isuid":true,"Isgid":false,"Hostid":1000000,"Nsid":0,"Maprange":1000000000},{"Isuid":false,"Isgid":true,"Hostid":1000000,"Nsid":0,"Maprange":1000000000}]'
  volatile.last_state.idmap: '[]'
devices:
  eth0:
    name: eth0
    nictype: bridged
    parent: lxdbr0
    type: nic
  root:
    path: /
    pool: default
    type: disk
ephemeral: false
profiles:
- default
stateful: false
description: ""

Can you show ouput of a new container on the affected host of:

lxc init images:debian/buster c1
lxc config show c1 --expanded
root@lxd-cihost:~# lxc init images:debian/buster c1
Creating c1
root@lxd-cihost:~# lxc config show c1 --expanded
architecture: x86_64
config:
  image.architecture: amd64
  image.description: Debian buster amd64 (20201029_05:24)
  image.os: Debian
  image.release: buster
  image.serial: "20201029_05:24"
  volatile.apply_template: create
  volatile.base_image: 6c982b800e35a225d75b555b866dbc3c78a25256734a1af752de541a6f50c69c
  volatile.idmap.base: "0"
  volatile.idmap.next: '[{"Isuid":true,"Isgid":false,"Hostid":1000000,"Nsid":0,"Maprange":1000000000},{"Isuid":false,"Isgid":true,"Hostid":1000000,"Nsid":0,"Maprange":1000000000}]'
  volatile.last_state.idmap: '[]'
devices:
  eth0:
    name: eth0
    nictype: bridged
    parent: br0
    type: nic
  root:
    path: /
    pool: default
    type: disk
ephemeral: false
profiles:
- default
stateful: false
description: ""

Are you running the snap by the way?

What do you mean?

root@lxd-cihost:~# snap list
Name  Version    Rev    Tracking       Publisher   Notes
core  16-2.47.1  10185  latest/stable  canonical✓  core
lxd   3.0.4      11348  3.0/stable/…   canonical✓  -
root@lxd-cihost:~# 

OK you’re running the snap.

I think the issue is that the br0 interface is not an LXD managed bridge, and therefore it does not generate a static DHCP lease file for dnsmasq at create time (which would trigger the volatile MAC address key to be added).

Is the br0 on the other host a LXD managed bridge (i.e in lxc network ls it shows “yes” in the “Managed” column?

You are right:

root@lxd-cihost:~# lxc network ls | grep br0
| br0             | bridge   | NO      |             | 12      |

But the on other system (LXD 3.0.3) the situation is the same (not managed) and it provides the entry.

root@pilot-lxc:~# lxc network ls | grep br0
| br0      | bridge   | NO      |             | 49      |

I’ve confirmed that the LXD 3.0.3 deb on Ubuntu Bionic does not have this behaviour that LXD 3.0.4 snap is exhibiting.

Would it be possible for you to use the LXD 4.0 LTS branch as that has longer support and I’ve confirmed it does not have the behaviour (as it has a refreshed devices framework, and the NIC’s volatile MAC address is always generated when the device’s config is loaded).

Thank you for your help!
Can I upgrade LXD to 4.0 LTS without any trouble?

Hi,

Yes this should be fine, I just tried it now in a VM:

apt install snapd
snap install lxd --channel=3.0/stable
lxd init --auto
lxc launch images:ubuntu/focal c1
lxc stop c1
snap refresh lxd --channel=4.0/stable
lxc start c1
lxc ls c1
+------+---------+-----------------------+-----------------------------------------------+-----------+-----------+
| NAME |  STATE  |         IPV4          |                     IPV6                      |   TYPE    | SNAPSHOTS |
+------+---------+-----------------------+-----------------------------------------------+-----------+-----------+
| c1   | RUNNING | 10.119.183.220 (eth0) | fd42:c6e5:1fe5:835f:216:3eff:feb9:47f8 (eth0) | CONTAINER | 0         |
+------+---------+-----------------------+-----------------------------------------------+-----------+-----------+

Thank you very much. I’ve created a snap snapshot (save) about the lxd and I’ll update it.