MAAS: How to release old dhcp leases

Hello,

I’m facing a problem while deploying a server in MAAS. The error shows as “No more IPs available in subnet:”

I checked the subnet and some of the IPs are not being used anymore. How do I release those leases?

For example, i have this hostname1 with two DHCP IPs, one is old and the other is new. I want to remove the old which is not pinging anymore.

thanks,
Jewsco

Can you run

sudo -u postgres psql -d maasdb -c "
SELECT count(*)
from maasserver_staticipaddress
left join maasserver_interface_ip_addresses on maasserver_staticipaddress.id = maasserver_interface_ip_addresses.staticipaddress_id
left join maasserver_interface on maasserver_interface.id = maasserver_interface_ip_addresses.interface_id
where maasserver_staticipaddress.ip is NULL and maasserver_interface.type = 'unknown' and maasserver_staticipaddress.alloc_type = 6;
"

?

@r00ta , thanks for responding, here it is.

$ psql -d maasdb -c "SELECT count(*)

from maasserver_staticipaddress
left join maasserver_interface_ip_addresses on maasserver_staticipaddress.id = maasserver_interface_ip_addresses.staticipaddress_id
left join maasserver_interface on maasserver_interface.id = maasserver_interface_ip_addresses.interface_id
where maasserver_staticipaddress.ip is NULL and maasserver_interface.type = ‘unknown’ and maasserver_staticipaddress.alloc_type = 6;
"
count


 2

(1 row)

Looks like you have only 2 orphans? BTW !Action required: this cleanup might speedup your MAAS (3.4.0 and below) environments

Thanks @r00ta

So i got a subnet allocated(172.21.68.64/27) and a maas owned dynamic range(172.21.68.71 - 172.21.68.94) which would yield 24 IPs and the Used IP addresses is only showing 11. One of the IP is pingable(172.21.68.76) and the rest are not. SO i’m wondering why i get this “No more IPs available in subnet” error.

You might be facing Bug #2050200 “IP exhaustion during deployment of machine” : Bugs : MAAS .

In short, try to clean the neighbours in the UI and check if you have IPs available

Thanks for the update.

Do you mean clean the neighbors/discovered through the UI? I’m not able to find a button in the UI to do that.

Do you mean clean the ARP table in the Rack server using arp -d? I only see two entries there, the eth1 is the dhcp facing interface.
root@lxmasracknpes03:~# arp -a |grep eth1
? (172.21.68.79) at c4:cb:e1:ab:17:31 [ether] on eth1
lxmasracknpes04-pxe.example.com (172.21.68.68) at 00:50:56:a8:f7:62 [ether] on eth1
? (172.21.68.69) at c4:cb:e1:ab:17:30 [ether] on eth1
root@lxmasracknpes03:~#

btw, i’m only having IP exhaustion at the “Deploy” action, inlisting/commissioning shows no issue.

You can maas admin discoveries clear with the CLI

$ maas admin discoveries clear all=True -k
Success.
Machine-readable output follows:

$ maas admin discoveries read -k
Success.
Machine-readable output follows:
[]
$

Run the deploy again and still got the same error - No more IPs available in subnet: 172.21.68.64/27

After you try to deploy what’s the response from maas admin discoveries read (without cleaning them again)?

Its been a while, here is the current output of discoveries read |grep 172.21.68

    "ip": "172.21.68.93",
    "ip": "172.21.68.67",
    "ip": "172.21.68.68",
    "ip": "172.21.68.74",
    "ip": "172.21.68.66",
    "ip": "172.21.68.91",
    "ip": "172.21.68.89",
    "ip": "172.21.68.86",
    "ip": "172.21.68.71",
    "ip": "172.21.68.79",
    "ip": "172.21.68.92",
    "ip": "172.21.68.83",
    "ip": "172.21.68.73",
    "ip": "172.21.68.94",
    "ip": "172.21.68.72",
    "ip": "172.21.68.93",
    "ip": "172.21.68.87",
    "ip": "172.21.68.76",
    "ip": "172.21.68.88",

We notice that if we reserve small chunk of IPs instead of setting the whole range, we don’t face the out of IP issue.

Like for subnet 172.21.68.64/27, instead of having to set an ip dynamic range of 172.21.68.65 - 172.21.68.94 we set it like this and it works. Is this the good practice going forward?

172.21.68.65 172.21.68.70 naal Reserved — EditDelete
172.21.68.75 172.21.68.80 MAAS Dynamic Dynamic EditDelete
172.21.68.81 172.21.68.85 MAAS Dynamic Dynamic EditDelete
172.21.68.86 172.21.68.90 MAAS Dynamic Dynamic