2023-02-07 01:54:10 |
Seyeong Kim |
description |
There is an issue with MAAS that, when you have multiple IP addresses on the same interface, the DNS name for the FQDN of the host can change.
In the scenario were you have MAAS + postgres + HA, you can have 2 IP addresses that are controlled via corosync, and based on where the IP address is, MAAS will automatically create DNS entries, we can see the host resolution[1] and he PTR records [2] as shown. Now the VIPs for maas and postgres are 192.168.210.2 and 192.168.210.3, and hence the FQDN shouldn't really be used for these IP addresses, as ultimately they are secondary.
In a juju deployed environment, in some scenarios we have LMA cross model relations, and the 3 MAAS servers also host telegraf, and then direct their data towards prometheus. This then grabs the IP address of the host as per the relational data (primary interface IP), and grabs the DNS record. In this particular scenario, rather than giving infra1.maas, it will give broam.infra1.maas., which is not the required result.
For a simple reproducer, all you need is a simple MAAS server with single IP address. Then add IP address to the same machine in the same network, and we will see the DNS name of the server fluctuate, below is some output of my reproduced issue on a single MAAS server, noting that each time I am expecting 192.168.1.22 to be my MAAS FQDN
ip a a 192.168.1.8/24 dev eth0
log message in regiond.log
2022-12-15 19:18:05 maasserver.region_controller: [info] Reloaded DNS configuration; ip 192.168.1.8 connected to maas on eth0
~~~
root@maas:~# cat /var/snap/maas/current/bind/zone.1.168.192.in-addr.arpa
<SNIP>
8 30 IN PTR maas.maas.
<SNIP>
22 30 IN PTR eth0.maas.maas.
~~~
ip a a 192.168.1.7/24 dev eth0
~~~
root@maas:~# cat /var/snap/maas/current/bind/zone.1.168.192.in-addr.arpa
<SNIP>
22 30 IN PTR maas.maas.
<SNIP>
7 30 IN PTR eth0.maas.maas.
8 30 IN PTR eth0.maas.maas.
~~~
ip a a 192.168.1.6/24 dev eth0
~~~
root@maas:~# cat /var/snap/maas/current/bind/zone.1.168.192.in-addr.arpa
<SNIP
8 30 IN PTR maas.maas.
<SNIP
6 30 IN PTR eth0.maas.maas.
22 30 IN PTR eth0.maas.maas.
7 30 IN PTR eth0.maas.maas.
~~~
As we can see from the above output, we can see the undesired output.
My expectation is that .22 is always maas.maas. in my scenario, as that should be consistent, no matter what the secondary IP address is set
This has been tested in 2.9.2, as well as my lab with 3.2.6
[1] https://paste.ubuntu.com/p/CZ2wfQgnkx/
[2] https://paste.ubuntu.com/p/7WmYFwb2nT/ |
There is an issue with MAAS that, when you have multiple IP addresses on the same interface, the DNS name for the FQDN of the host can change.
In the scenario were you have MAAS + postgres + HA, you can have 2 IP addresses that are controlled via corosync, and based on where the IP address is, MAAS will automatically create DNS entries, we can see the host resolution[1] and he PTR records [2] as shown. Now the VIPs for maas and postgres are 192.168.210.2 and 192.168.210.3, and hence the FQDN shouldn't really be used for these IP addresses, as ultimately they are secondary.
In a juju deployed environment, in some scenarios we have LMA cross model relations, and the 3 MAAS servers also host telegraf, and then direct their data towards prometheus. This then grabs the IP address of the host as per the relational data (primary interface IP), and grabs the DNS record. In this particular scenario, rather than giving infra1.maas, it will give broam.infra1.maas., which is not the required result.
For a simple reproducer, all you need is a simple MAAS server with single IP address. Then add IP address to the same machine in the same network, and we will see the DNS name of the server fluctuate, below is some output of my reproduced issue on a single MAAS server, noting that each time I am expecting 192.168.1.22 to be my MAAS FQDN
ip a a 192.168.1.8/24 dev eth0
log message in regiond.log
2022-12-15 19:18:05 maasserver.region_controller: [info] Reloaded DNS configuration; ip 192.168.1.8 connected to maas on eth0
~~~
root@maas:~# cat /var/snap/maas/current/bind/zone.1.168.192.in-addr.arpa
<SNIP>
8 30 IN PTR maas.maas.
<SNIP>
22 30 IN PTR eth0.maas.maas.
~~~
ip a a 192.168.1.7/24 dev eth0
~~~
root@maas:~# cat /var/snap/maas/current/bind/zone.1.168.192.in-addr.arpa
<SNIP>
22 30 IN PTR maas.maas.
<SNIP>
7 30 IN PTR eth0.maas.maas.
8 30 IN PTR eth0.maas.maas.
~~~
ip a a 192.168.1.6/24 dev eth0
~~~
root@maas:~# cat /var/snap/maas/current/bind/zone.1.168.192.in-addr.arpa
<SNIP
8 30 IN PTR maas.maas.
<SNIP
6 30 IN PTR eth0.maas.maas.
22 30 IN PTR eth0.maas.maas.
7 30 IN PTR eth0.maas.maas.
~~~
As we can see from the above output, we can see the undesired output.
My expectation is that .22 is always maas.maas. in my scenario, as that should be consistent, no matter what the secondary IP address is set
This has been tested in 2.9.2, as well as my lab with 3.2.6
[1] https://paste.ubuntu.com/p/CZ2wfQgnkx/
[2] https://paste.ubuntu.com/p/7WmYFwb2nT/
### ADDED
As this patch https://bugs.launchpad.net/maas/+bug/1600259, it takes IPs reversely and generate zone file.
https://github.com/maas/maas/blob/0c069f0aafbb650928f6c8536debd0de79eb7484/src/maasserver/dns/zonegenerator.py#L399
e.g
assume there is one nic which has 172.16.116.131 as a primary IP.
after adding one more ip to the same nic, zone file refer to secondary IP instead of primary IP.
{<Domain: name=maas>: defaultdict(<class 'maasserver.models.staticipaddress.HostnameIPMapping'>, {'xtrusia.maas': HostnameIPMapping('pca68y', 30, {'172.16.116.131'}, 4, None, None), 'ens33.xtrusia.maas': HostnameIPMapping('pca68y', 30, {'172.16.116.254'}, 4, None, 3), 'lxdbr0.xtrusia.maas': HostnameIPMapping('pca68y', 30, {'10.69.50.1'}, 4, None, 3)}), <Subnet: 172.16.116.0/24:172.16.116.0/24(vid=0)>: defaultdict(<class 'maasserver.models.staticipaddress.HostnameIPMapping'>, {'xtrusia.maas': HostnameIPMapping('pca68y', 30, {'172.16.116.254'}, 4, None, None), 'ens33.xtrusia.maas': HostnameIPMapping('pca68y', 30, {'172.16.116.131'}, 4, None, 3), 'lxdbr0.xtrusia.maas': HostnameIPMapping('pca68y', 30, {'10.69.50.1'}, 4, None, 3)}), 'reverse': defaultdict(<class 'maasserver.models.staticipaddress.HostnameIPMapping'>, {'xtrusia.maas': HostnameIPMapping('pca68y', 30, {'172.16.116.254'}, 4, None, None), 'ens33.xtrusia.maas': HostnameIPMapping('pca68y', 30, {'172.16.116.131'}, 4, None, 3), 'lxdbr0.xtrusia.maas': HostnameIPMapping('pca68y', 30, {'10.69.50.1'}, 4, None, 3)})}
I printed info from code, xtrusia.maas had 172.16.116.131 in the beginning, but after I added 172.16.116.254, it is changed to later. |
|