Several IPs assigned to the same iface in the DB due to 'free' leases

Bug #1657491 reported by Victor Tapia
12
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MAAS
Fix Released
Critical
Mike Pontillo

Bug Description

Using MAAS 1.9.4, when the dhcpd.leases file contains a 'free' lease, it is parsed and inserted in the DB as an 'active' lease would be. If the deployed server uses only 'DHCP' interfaces, it might trigger DNS issues (the FQDN could change IPs).

For instance, this is an affected DB:

maasdb=# SELECT node.id, node.hostname, iface.id, iface.name, mac_address, sip.id, ip, alloc_type FROM maasserver_staticipaddress AS sip LEFT JOIN maasserver_interface_ip_addresses AS iia ON iia.staticipaddress_id = sip.id LEFT JOIN maasserver_interface AS iface ON iface.id = iia.interface_id LEFT JOIN maasserver_node AS node ON node.id = iface.node_id ORDER BY node.hostname, iface.name, sip.ip;

id | hostname | id | name | mac_address | id | ip | alloc_type
----+----------+----+------+-------------------+----+-------------+------------
  1 | node1 | 2 | eth0 | fa:16:3e:45:da:d8 | 28 | 10.12.1.100 | 6
  1 | node1 | 2 | eth0 | fa:16:3e:45:da:d8 | 29 | 10.12.1.102 | 6
  1 | node1 | 2 | eth0 | fa:16:3e:45:da:d8 | 10 | | 5
  1 | node1 | 3 | eth1 | fa:16:3e:a2:8e:84 | 24 | 10.12.1.101 | 6
  1 | node1 | 3 | eth1 | fa:16:3e:a2:8e:84 | 11 | | 1
  2 | node2 | 6 | eth0 | fa:16:3e:09:82:db | 24 | 10.12.1.101 | 6
  2 | node2 | 6 | eth0 | fa:16:3e:09:82:db | 16 | 10.12.1.103 | 6
  2 | node2 | 6 | eth0 | fa:16:3e:09:82:db | 17 | | 5
  2 | node2 | 7 | eth1 | fa:16:3e:ee:bc:2e | 29 | 10.12.1.102 | 6
  2 | node2 | 7 | eth1 | fa:16:3e:ee:bc:2e | 18 | | 1
  3 | node3 | 8 | eth0 | fa:16:3e:9e:fa:80 | 16 | 10.12.1.103 | 6
  3 | node3 | 8 | eth0 | fa:16:3e:9e:fa:80 | 20 | 10.12.1.105 | 6

And a 'free' lease that ended up in the table:

lease 10.12.1.100 {
  starts 4 2016/12/22 06:39:09;
  cltt 4 2016/12/22 06:39:09;
  binding state free;
  hardware ethernet fa:16:3e:45:da:d8;
}

I'm still testing, but changing get_expiry_date(lease) to ignore non-'active' leases fixes it for me so far:

--- 1/src/provisioningserver/dhcp/leases_parser.py 2016-07-12 15:51:53.000000000 +0200
+++ 2/src/provisioningserver/dhcp/leases_parser.py 2017-01-18 16:15:10.948283550 +0100
@@ -126,7 +126,15 @@
     """
     assert is_lease(lease)
     ends = getattr(lease, 'ends', None)
- if ends is None or len(ends) == 0 or ends.lower() == 'never':
+ if ends is None or len(ends) == 0:
+ state = getattr(lease, 'binding state', None)
+ if state.lower() == 'active':
+ return None
+ else:
+ # Free leases have starts but not ends
+ starts = getattr(lease, 'starts', None)
+ return datetime.strptime(starts, '%w %Y/%m/%d %H:%M:%S')
+ if ends.lower() == 'never':
         return None
     else:
         return datetime.strptime(ends, '%w %Y/%m/%d %H:%M:%S')

Tags: sts

Related branches

Revision history for this message
Andres Rodriguez (andreserl) wrote :

As per the discussion, MAAS 2.0 addresses the issues related to IP addressing and 2.0 is not backportable to trusty.

Changed in maas:
status: New → Won't Fix
Revision history for this message
Mike Pontillo (mpontillo) wrote :

We're revisiting this, since some critical bugs with the DHCP lease parser were found when looking at this. (Thanks for the patch; it was a good starting point.) See the linked branch for more details.

Note that even with these fixes, there are still potential issues with IP addressing in MAAS 1.9 that can only be fixed by design (by upgrading to MAAS 2.x).

Changed in maas:
status: Won't Fix → In Progress
importance: Undecided → Critical
assignee: nobody → Mike Pontillo (mpontillo)
milestone: none → 1.9.5
Revision history for this message
Victor Tapia (vtapia) wrote :

Hi Mike, Andres:

We've been testing the suggested branch and the reported issue disappears, so +1 to merging :).

Thanks again!

Changed in maas:
status: In Progress → Fix Committed
Changed in maas:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.