remote-subnet4-set inconsistent work when id/subnet is duplicated.
- Kea is started without any subnet configured.
- execute command
remote-subnet4-set
:
{"command": "remote-subnet4-set",
"arguments": {"subnets": [{"interface": "enp0s9",
"subnet": "192.168.50.0/24",
"pools": [{"pool": "192.168.50.1-192.168.50.100"}],
"id": 5}],
"server-tags": ["abc"],
"remote": {"type": "mysql"}
}
}
- Kea will be configured correctly with subnet 192.168.50.0/24 with id 5.
- Let's now execute command
remote-subnet4-set
with different subnet but with the same value of id:
{"command": "remote-subnet4-set",
"arguments": {"subnets": [{"interface": "enp0s9",
"subnet": "192.168.51.0/24",
"pools": [{"pool": "192.168.51.1-192.168.51.100"}],
"id": 5}],
"server-tags": ["abc"],
"remote": {"type": "mysql"}
}
}
{
"arguments": {
"subnets": [
{
"id": 5,
"subnet": "192.168.51.0/24"
}
]
},
"result": 0,
"text": "IPv4 subnet successfully set."
}
mysql> select * from dhcp4_subnet;
+-----------+-----------------+---------------+------------------+------------+----------------+--------------+-----------+-----------------+---------------------+-------------+--------------+-------+-------------+------------------------+------------------+-----------------+---------------------+--------------+----------------+
| subnet_id | subnet_prefix | 4o6_interface | 4o6_interface_id | 4o6_subnet | boot_file_name | client_class | interface | match_client_id | modification_ts | next_server | rebind_timer | relay | renew_timer | require_client_classes | reservation_mode | server_hostname | shared_network_name | user_context | valid_lifetime |
+-----------+-----------------+---------------+------------------+------------+----------------+--------------+-----------+-----------------+---------------------+-------------+--------------+-------+-------------+------------------------+------------------+-----------------+---------------------+--------------+----------------+
| 5 | 192.168.51.0/24 | NULL | NULL | NULL | NULL | NULL | enp0s9 | 1 | 2019-02-19 06:05:39 | NULL | NULL | NULL | NULL | [ ] | 3 | NULL | NULL | NULL | 7200 |
+-----------+-----------------+---------------+------------------+------------+----------------+--------------+-----------+-----------------+---------------------+-------------+--------------+-------+-------------+------------------------+------------------+-----------------+---------------------+--------------+----------------+
result: there is now just one subnet configured and it's 192.168.51.0/24
so previous one was overwritten without warning/notification
- But when second command will duplicated subnet kea will respond with a bit cryptic error:
{
"result": 1,
"text": "unable to execute for <INSERT INTO dhcp4_pool( start_address, end_address, subnet_id, modification_ts) VALUES (?, ?, ?, ?)>, reason: Cannot add or update a child row: a foreign key constraint fails (`keadb`.`dhcp4_pool`, CONSTRAINT `fk_dhcp4_pool_subnet_id` FOREIGN KEY (`subnet_id`) REFERENCES `dhcp4_subnet` (`subnet_id`) ON DELETE CASCADE ON UPDATE CASCADE) (error code 1452)"
}
id
and subnet
are two ways of exactly identify record in database so I guess it should work in the same manner. Either override, or return error saying that there is such record in the database.
Edited by Francis Dupont