2013-09-02 11:45:10 |
Brian D. Burns |
description |
When creating a subnet, the DHCP port is not being created until another
port is created. That is, unless ports have been created on the network.
And a call to create a subnet will return before the DHCP port is established
(if that occurs), which produces a race condition if creating a port immediately
after creating the subnet.
This is easier is explain by example :)
The following can be run from a shell script to reproduce the issue:
neutron net-create test_net
neutron subnet-create test_net 198.18.0.0/24
neutron subnet-create test_net 2001:db8:abc:123::/64 --ip-version 6
sleep 5 # just to be sure
neutron port-list
# dhcp port has not been created yet
neutron port-create test_net --name test_port
# the dhcp port is created after the test_port.
# apparently before the port-create command returns,
# as no sleep is needed before the port-list.
neutron port-list
# test_port assigned 198.18.0.2 and 2001:db8:abc:123::2
# dhcp port assigned 198.18.0.3 and 2001:db8:abc:123::3
neutron port-delete test_port
neutron net-delete test_net
neutron net-create test_net
# this add/remove port before subnet creation causes the dhcp port
# to be setup when the subnets are created.
neutron port-create test_net --name test_port
neutron port-delete test_port
neutron subnet-create test_net 198.18.0.0/24
neutron subnet-create test_net 2001:db8:abc:123::/64 --ip-version 6
sleep 5 # subnet-create returns before the dhcp port is setup
neutron port-list
# dhcp port assigned 198.18.0.2 and 2001:db8:abc:123::2
neutron port-create test_net --name test_port
neutron port-list
# test_port assigned 198.18.0.3 and 2001:db8:abc:123::3
neutron port-delete test_port
neutron net-delete test_net
# this creates a condition where if you create the test_port
# after the subnets without sleeping, the test_port gets the ::2 ipv6
# address before the dhcp port.
neutron net-create test_net
neutron port-create test_net --name test_port
neutron port-delete test_port
neutron subnet-create test_net 198.18.0.0/24
neutron subnet-create test_net 2001:db8:abc:123::/64 --ip-version 6
neutron port-create test_net --name test_port
sleep 5 # in order to see the dhcp port
neutron port-list
# test_port assigned 198.18.0.3 and 2001:db8:abc:123::2
# dhcp port assigned 198.18.0.2 and 2001:db8:abc:123::3
neutron port-delete test_port
neutron net-delete test_net
It seems the solution would be to make sure the DHCP port check is performed
after a subnet is created/updated, and not return until that is completed.
It doesn't seem like this would be necessary when creating/updating a port.
(unless it's the DHCP port that's being modified?) |
When creating a subnet, the DHCP port is not being created until another
port is created. That is, unless ports have been created on the network.
And a call to create a subnet will return before the DHCP port is established
(if that occurs), which produces a race condition if creating a port immediately after creating the subnet.
This is easier is explain by example :)
The following can be run from a shell script to reproduce the issue:
neutron net-create test_net
neutron subnet-create test_net 198.18.0.0/24
neutron subnet-create test_net 2001:db8:abc:123::/64 --ip-version 6
sleep 5 # just to be sure
neutron port-list
# dhcp port has not been created yet
neutron port-create test_net --name test_port
# the dhcp port is created after the test_port.
# apparently before the port-create command returns,
# as no sleep is needed before the port-list.
neutron port-list
# test_port assigned 198.18.0.2 and 2001:db8:abc:123::2
# dhcp port assigned 198.18.0.3 and 2001:db8:abc:123::3
neutron port-delete test_port
neutron net-delete test_net
neutron net-create test_net
# this add/remove port before subnet creation causes the dhcp port
# to be setup when the subnets are created.
neutron port-create test_net --name test_port
neutron port-delete test_port
neutron subnet-create test_net 198.18.0.0/24
neutron subnet-create test_net 2001:db8:abc:123::/64 --ip-version 6
sleep 5 # subnet-create returns before the dhcp port is setup
neutron port-list
# dhcp port assigned 198.18.0.2 and 2001:db8:abc:123::2
neutron port-create test_net --name test_port
neutron port-list
# test_port assigned 198.18.0.3 and 2001:db8:abc:123::3
neutron port-delete test_port
neutron net-delete test_net
# this creates a condition where if you create the test_port
# after the subnets without sleeping, the test_port gets the ::2 ipv6
# address before the dhcp port.
neutron net-create test_net
neutron port-create test_net --name test_port
neutron port-delete test_port
neutron subnet-create test_net 198.18.0.0/24
neutron subnet-create test_net 2001:db8:abc:123::/64 --ip-version 6
neutron port-create test_net --name test_port
sleep 5 # in order to see the dhcp port
neutron port-list
# test_port assigned 198.18.0.3 and 2001:db8:abc:123::2
# dhcp port assigned 198.18.0.2 and 2001:db8:abc:123::3
neutron port-delete test_port
neutron net-delete test_net
It seems the solution would be to make sure the DHCP port check is performed
after a subnet is created/updated, and not return until that is completed.
It doesn't seem like this would be necessary when creating/updating a port.
(unless it's the DHCP port that's being modified?) |
|