Comment 3 for bug 2027621

Revision history for this message
Mauricio Faria de Oliveira (mfo) wrote (last edit ):

Verification done on MAAS 3.1.3.

In a HA deployment with 1 region+rack and 1 rack,
the dhcpd.conf file's section 'failover peer' has
IPv4+IPv6 address in 3.1.2 and only IPv4 in 3.1.3.

The synthetic reproducer changes the order of IPs
in the maasdb so the IPv6 address has a _lower id_
than then IPv4 address (and thus goes first in the
for-loop in get_ip_address_for_rack_controller()).

 def get_ip_address_for_rack_controller(rack_controller, vlan, ip_version: int):
 ...
     interfaces = rack_controller.interface_set.all().prefetch_related(
 ...
     for interface in interfaces:
  for ip_address in interface.ip_addresses.all():
 ...

MAAS 3.1.2:

 $ snap list maas
 Name Version Rev Tracking Publisher Notes
 maas 3.1.2-10926-g.5ad7060e5 30495 3.1/stable canonical✓ -

Before changing maasdb:

 $ maas admin rack-controllers read | jq '.[] | [.system_id, .hostname, (.interface_set[] | .links[] | [.id, .ip_address, .subnet.vlan.id])]'
 [
   "xx8thd",
   "maas-srv-31snap",
   [
     1,
     "10.31.200.2",
     5001
   ],
   [
     7,
     "fc00::2",
     5001
   ]
 ]
 [
   "w6fgbh",
   "maas-srv-peer-31snap",
   [
     2,
     "10.31.200.3",
     5001
   ],
   [
     8,
     "fc00::3",
     5001
   ]
 ]

Change maasdb:

 $ sudo maas-test-db.psql
 maasdb=# \c maasdb

 maasdb=# select * from maasserver_staticipaddress order by id;
  id | created | updated | ip | alloc_type | subnet_id | user_id | lease_time | temp_expires_on
 ----+-------------------------------+-------------------------------+-------------+------------+-----------+---------+------------+-----------------
   1 | 2024-02-23 10:07:47.030013+00 | 2024-02-23 10:07:47.030013+00 | 10.31.200.2 | 1 | 1 | | 0 |
   2 | 2024-02-23 10:16:10.319517+00 | 2024-02-23 10:16:10.319517+00 | 10.31.200.3 | 1 | 1 | | 0 |
   7 | 2024-02-23 11:32:50.972432+00 | 2024-02-23 11:32:50.972432+00 | fc00::2 | 1 | 6 | | 0 |
   8 | 2024-02-23 11:33:25.04944+00 | 2024-02-23 11:33:25.04944+00 | fc00::3 | 1 | 6 | | 0 |
 (4 rows)

 <just a swap value to replace the ip address which must be unique/non-duplicated>

 maasdb=# update maasserver_staticipaddress set ip='10.31.200.33' where id=8;
 UPDATE 1
 maasdb=# update maasserver_staticipaddress set ip='fc00::3' where id=2;
 UPDATE 1
 maasdb=# update maasserver_staticipaddress set ip='10.31.200.3' where id=8;
 UPDATE 1

 maasdb=# select * from maasserver_staticipaddress order by id;
  id | created | updated | ip | alloc_type | subnet_id | user_id | lease_time | temp_expires_on
 ----+-------------------------------+-------------------------------+-------------+------------+-----------+---------+------------+-----------------
   1 | 2024-02-23 10:07:47.030013+00 | 2024-02-23 10:07:47.030013+00 | 10.31.200.2 | 1 | 1 | | 0 |
   2 | 2024-02-23 10:16:10.319517+00 | 2024-02-23 10:16:10.319517+00 | fc00::3 | 1 | 1 | | 0 |
   7 | 2024-02-23 11:32:50.972432+00 | 2024-02-23 11:32:50.972432+00 | fc00::2 | 1 | 6 | | 0 |
   8 | 2024-02-23 11:33:25.04944+00 | 2024-02-23 11:33:25.04944+00 | 10.31.200.3 | 1 | 6 | | 0 |
 (4 rows)

 maasdb=# \q

After changing maasdb:

 $ maas admin rack-controllers read | jq '.[] | [.system_id, .hostname, (.interface_set[] | .links[] | [.id, .ip_address, .subnet.vlan.id])]'
 [
   "xx8thd",
   "maas-srv-31snap",
   [
     1,
     "10.31.200.2",
     5001
   ],
   [
     7,
     "fc00::2",
     5001
   ]
 ]
 [
   "w6fgbh",
   "maas-srv-peer-31snap",
   [
     2,
     "fc00::3",
     5001
   ],
   [
     8,
     "10.31.200.3",
     5001
   ]
 ]

In the UI, go to Subnets, untagged vlan, Enable DHCP, select Primary Controller and Secondary Controller, and Configure DHCP.

The dhcpd.conf file has both IPv4 and IPv6 addresses (but it's for IPv4 only; dhcpd6.conf is for IPv6):

 ubuntu@maas-srv-31snap:~$ sudo cat /var/snap/maas/common/maas/dhcpd.conf | sed -n '/^failover peer/,/^}/p'
 failover peer "failover-vlan-5001" {
     secondary;
     address 10.31.200.2;
     peer address fc00::3;
     max-response-delay 60;
     max-unacked-updates 10;
     load balance max seconds 3;
 }

 root@maas-srv-peer-31snap:~# sudo cat /var/snap/maas/common/maas/dhcpd.conf | sed -n '/^failover peer/,/^}/p'
 failover peer "failover-vlan-5001" {
     primary;
     address fc00::3;
     peer address 10.31.200.2;
     max-response-delay 60;
     max-unacked-updates 10;
     load balance max seconds 3;
     mclt 3600;
     split 255;
 }

Now click 'Reconfigure DHCP', untick 'MAAS provides DHCP', Reconfigure DHCP.
And the DHCP server configuration files are gone.

MAAS 3.1.3:

 $ sudo snap refresh --channel=3.1/edge maas

 $ snap list maas
 Name Version Rev Tracking Publisher Notes
 maas 3.1.3-10930-g.2eb4e7525 33606 3.1/edge canonical✓ -

IP addresses are still in the same order:

 $ maas admin rack-controllers read | jq '.[] | [.system_id, .hostname, (.interface_set[] | .links[] | [.id, .ip_address, .subnet.vlan.id])]'
 [
   "xx8thd",
   "maas-srv-31snap",
   [
     1,
     "10.31.200.2",
     5001
   ],
   [
     7,
     "fc00::2",
     5001
   ]
 ]
 [
   "w6fgbh",
   "maas-srv-peer-31snap",
   [
     2,
     "fc00::3",
     5001
   ],
   [
     8,
     "10.31.200.3",
     5001
   ]
 ]

Again, Enable DHCP in HA (as above).

The dhcpd.conf file has only IPv4 addresses.

 ubuntu@maas-srv-31snap:~$ sudo cat /var/snap/maas/common/maas/dhcpd.conf | sed -n '/^failover peer/,/^}/p'
 failover peer "failover-vlan-5001" {
     secondary;
     address 10.31.200.2;
     peer address 10.31.200.3;
     max-response-delay 60;
     max-unacked-updates 10;
     load balance max seconds 3;
 }

 root@maas-srv-peer-31snap:~# sudo cat /var/snap/maas/common/maas/dhcpd.conf | sed -n '/^failover peer/,/^}/p'
 failover peer "failover-vlan-5001" {
     primary;
     address 10.31.200.3;
     peer address 10.31.200.2;
     max-response-delay 60;
     max-unacked-updates 10;
     load balance max seconds 3;
     mclt 3600;
     split 255;
 }

Disable/Enable (flip primary/secondary), still the same:

 ubuntu@maas-srv-31snap:~$ sudo cat /var/snap/maas/common/maas/dhcpd.conf | sed -n '/^failover peer/,/^}/p'
 failover peer "failover-vlan-5001" {
     primary;
     address 10.31.200.2;
     peer address 10.31.200.3;
     max-response-delay 60;
     max-unacked-updates 10;
     load balance max seconds 3;
     mclt 3600;
     split 255;
 }

 root@maas-srv-peer-31snap:~# sudo cat /var/snap/maas/common/maas/dhcpd.conf | sed -n '/^failover peer/,/^}/p'
 failover peer "failover-vlan-5001" {
     secondary;
     address 10.31.200.3;
     peer address 10.31.200.2;
     max-response-delay 60;
     max-unacked-updates 10;
     load balance max seconds 3;
 }

Repeat again to double check, still the same content in the 2 steps.
Only IPv4 addresses in dhcpd.conf 'failover peer' section.