host entry conflict: same identifier, identifier type and subnet id
This comes from the test_v4_host_reservation_conflicts_duplicate_reservations forge test.
The question is what happens with 2 host reservations using the same identifier, identifier type and subnet id.
In the config the host container uses 3 different not unique indexes for the identifier+type, subnet id v4 and v6. As far I know there is no conflict check at config time. The get methods throw DuplicateHost.
MySQL database since schema 5.0 (Kea 1.1.0) uses unique key_dhcp[46]_identifier_subnet_id indexes so does not allow the same identifier + type with the same not null subnet id. The not null matters because the host reservation table is shared between v4 and v6 so same identier and type is allowed with for instance different v4 subnet ids even both v6 subnet ids are null.
MySQL backend get methods do not check: they return the first host if the query returns at least one.
PostgreSQL database is very close to MySQL with a small difference introduced in schema 3.2 (Kea 1.4.0): the unique constraint does not apply when the subnet id is 0.
Cassanda/CQL schema has no constaint. The get methods check if more than one host is found and throw MultipleRecords.
On the forge side:
- test_v4_host_reservation_conflicts_duplicate_reservations verifies that the configuration case allows conflicts
- test_v4_host_reservation_conflicts_duplicate_reservations_mysql verifies that the MySQL case allows conflicts and fails because it is not allowed
There is no check for PostgreSQL but it should fail if reservations are not global.
Note a similar constraint was removed on the same address and subnet id by #1428 (closed) in 1.9.1 (search for ip-reservations-unique).
Proposed action: reverse forge tests, add a PgSQL one and consider to add a check for the configuration case: at least an unit test should verify an incorrect configuration giving failures at run time is rejected.