[Urgent] Fix fip creation error

1. What is the problem
In the patch[1] for solving bug[2], we introduce an error that when
a fip is created with port ID and the bottom port is not there, the
fip body is not returned. Our smoke test doesn't find out this error
because it only affects the response, the fip is correctly created
in the database. But the log does show an error message.

2. What is the solution for the problem
Always return fip body. Unit test is modified to use the returned
body to ensure it's not None.

3. What features need to be implemented to the Tricircle to
realize the solution
N/A

[1] https://review.openstack.org/#/c/465870
[2] https://launchpad.net/bugs/1691918

Change-Id: I71fcc8fab9fb2a50ab058d67980f6e1e1e4e6d90
This commit is contained in:
zhiyuan_cai 2017-06-24 15:26:45 +08:00
parent 582e2becc8
commit 359ad4131e
2 changed files with 16 additions and 1 deletions

View File

@ -1746,7 +1746,7 @@ class TricirclePlugin(db_base_plugin_v2.NeutronDbPluginV2,
# mapping does not exist, meaning that the bottom port has
# not been created, we just return and defer the work to
# setup bottom floating ip until vm creation
return
return fip
int_net_pod, b_int_port_id = mappings[0]
int_port = self.get_port(context, fip['port_id'])

View File

@ -2967,6 +2967,21 @@ class PluginTest(unittest.TestCase,
# in _prepare_associate_floatingip_test, we have created an empty fip,
# but here we just ignore it and create a new fip by specifying fix ip
# at the same time
# we manaully remove the resource routing for port to construct the
# scenario that bottom port has not been created
db_api.delete_mappings_by_bottom_id(t_ctx, b_port_id)
fip_body = {'floating_network_id': e_net['id'],
'port_id': t_port_id,
'tenant_id': TEST_TENANT_ID}
fip = fake_plugin.create_floatingip(q_ctx, {'floatingip': fip_body})
self.assertFalse(mock_create.called)
fake_plugin.delete_floatingip(q_ctx, fip['id'])
# put the resource routing back for the scenario that bottom port has
# been created
db_api.create_resource_mapping(t_ctx, t_port_id, b_port_id, 'pod_id_1',
TEST_TENANT_ID, constants.RT_PORT)
fip_body = {'floating_network_id': e_net['id'],
'port_id': t_port_id,
'tenant_id': TEST_TENANT_ID}