canonical / lxd

Powerful system container and virtual machine manager
https://canonical.com/lxd
GNU Affero General Public License v3.0
4.35k stars 931 forks source link

Containers using OVN networks get different IPs on reboot #11658

Closed peppepetra closed 1 month ago

peppepetra commented 1 year ago

Required information

Issue description

OVN assigns IPs sequentially. That means if I create two containers then delete one and stop/start the other one, the latter changes IP.

Steps to reproduce

  1. lxc launch ubuntu:22.04 test-sticky-ip lxc launch ubuntu:22.04 test-sticky-ip-2

    | test-sticky-ip   | RUNNING | 10.47.208.3 (eth0)  |      | CONTAINER | 0         | host3 |
    +------------------+---------+---------------------+------+-----------+-----------+-----------------+
    | test-sticky-ip-2 | RUNNING | 10.47.208.4 (eth0)  |      | CONTAINER | 0         | host2 |
  2. lxc delete test-sticky-ip --force

  3. lxc stop test-sticky-ip-2

  4. lxc start test-sticky-ip-2

  5. Result test-sticky-ip-2 get IP previously allocated for test-sticky-ip

    | test-sticky-ip-2 | RUNNING | 10.47.208.3 (eth0)  |      | CONTAINER | 0         | host2 |
nishant-dash commented 4 months ago

Hello,

I have a scenario where I am using juju deployed on LXD vms in a microcloud setup and rebooting a single vm mutliple times does not result in an ip change but rebooting a physical host results in almost every vm on that host getting a new ip, even with volatile.eth0.last_state.ip_addresses being set.

Versions:

tomponline commented 3 months ago

Reproducer:

lxc launch ubuntu:noble guest1
lxc stop guest1
lxc launch ubuntu:noble guest2
lxc start guest1

The key difference is that the 2nd instance wasn't started for the first time until after the 1st instance was stopped.

So it was then allocated the next free IP, which was the one guest1 had released when it was stopped.

When guest1 is started again, it tries to use its old IP, but is unable to because guest2 has taken it.

This is working as intended because the sticky IPs feature was best-effort sticky IPs, not automatic guaranteed static IP allocation.

Although this doesn't reflect the issue @nishant-dash saw, as all the instances had been previously started before he rebooted the LXD host.