Comment 10 for bug 2049950

Revision history for this message
maasuser1 (maasuser1) wrote : Re: dhcpd not working

By dug into the sourcecode of `/snap/maas/32469/lib/python3.10/site-packages/maasserver/dhcp.py`, I've identified the problem:

1. The target `fabric-0` has two subnets, both are handled by MAAS's `dhcpd` service.
     - `192.168.0.0/24`
     - `fdc3:a1b1:9f28::/64`
2. The main controller (id:1, regiond + rackd) has two IP addresses:
     - `192.168.0.2/24`
     - `fdc3:a1b1:9f28:0:feaa:14ff:feda:e3ec/64`
3. The secondary controller (id: 102, rackd) has only one IP address:
     - `192.168.0.147/24`
4. `get_ip_address_for_rack_controller(rack_controller, vlan, ip_version: int)` traverses all interfaces of the given controller according to the given IP version (IPv4 or IPv6), and then returns the `best` IP address.
5. Since the secondary controller has no IPv6 address on this fabric, `get_best_interface(interfaces)` returns `None`, and finally causes the "'NoneType' object has no attribute 'ip_addresses'" error on line 232, in `get_ip_address_for_interface()`.

Proposed solution:

1. Check whether all MAAS controllers have IP addresses on both IPv4 and IPv6 according to the fabric. If not, highlight this on Web UI.
2. Handle the exception in `dhcp.py`, which allows the controller to serve DHCP service for a single IP version (IPv4 or IPv6).