Comment 5 for bug 1219795

Revision history for this message
Brian D. Burns (iosctr) wrote :

The original race condition still exists. From above:

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

Also, since the new patch attempts to consume an unused port for dhcp,
it's consuming the port I'm creating:

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
neutron port-create test_net --name test_port
neutron port-show test_port

Also, note that while the device_id was set when consuming this port,
the device_owner was not (should be 'network:dhcp'). As a result,
the existence of this port will prevent deleting the network.

The only example that works correctly is the 2nd initial example above:

neutron net-create test_net
neutron port-create test_net --name test_port_temp
neutron port-delete test_port_temp
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
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

There are 2 reasons why this works.

1. Adding and removing a port from the network before the subnets are created
creates a condition where the dhcp port is created when the subnet is created.
Without that add/remove port, this does not occur.

2. You must sleep after creating the subnet to give the dhcp port time to be
created before creating your port to avoid the race condition.