Merge "Fix for status always in PENDING_CREATE for Edge service router"
This commit is contained in:
commit
df3e4c1239
@ -25,6 +25,7 @@ from neutron.db import l3_db
|
|||||||
from neutron.db.loadbalancer import loadbalancer_db
|
from neutron.db.loadbalancer import loadbalancer_db
|
||||||
from neutron.db import routedserviceinsertion_db as rsi_db
|
from neutron.db import routedserviceinsertion_db as rsi_db
|
||||||
from neutron.extensions import firewall as fw_ext
|
from neutron.extensions import firewall as fw_ext
|
||||||
|
from neutron.extensions import l3
|
||||||
from neutron.openstack.common import excutils
|
from neutron.openstack.common import excutils
|
||||||
from neutron.openstack.common import log as logging
|
from neutron.openstack.common import log as logging
|
||||||
from neutron.plugins.common import constants as service_constants
|
from neutron.plugins.common import constants as service_constants
|
||||||
@ -473,14 +474,10 @@ class NvpAdvancedPlugin(sr_db.ServiceRouter_mixin,
|
|||||||
return lrouter
|
return lrouter
|
||||||
|
|
||||||
def _delete_lrouter(self, context, id):
|
def _delete_lrouter(self, context, id):
|
||||||
if not self._is_advanced_service_router(context, id):
|
|
||||||
super(NvpAdvancedPlugin, self)._delete_lrouter(context, id)
|
|
||||||
if id in self._router_type:
|
|
||||||
del self._router_type[id]
|
|
||||||
return
|
|
||||||
|
|
||||||
binding = vcns_db.get_vcns_router_binding(context.session, id)
|
binding = vcns_db.get_vcns_router_binding(context.session, id)
|
||||||
if binding:
|
if not binding:
|
||||||
|
super(NvpAdvancedPlugin, self)._delete_lrouter(context, id)
|
||||||
|
else:
|
||||||
vcns_db.update_vcns_router_binding(
|
vcns_db.update_vcns_router_binding(
|
||||||
context.session, id, status=service_constants.PENDING_DELETE)
|
context.session, id, status=service_constants.PENDING_DELETE)
|
||||||
|
|
||||||
@ -499,8 +496,9 @@ class NvpAdvancedPlugin(sr_db.ServiceRouter_mixin,
|
|||||||
}
|
}
|
||||||
self.vcns_driver.delete_edge(id, edge_id, jobdata=jobdata)
|
self.vcns_driver.delete_edge(id, edge_id, jobdata=jobdata)
|
||||||
|
|
||||||
# delete LR
|
# delete LR
|
||||||
nvplib.delete_lrouter(self.cluster, id)
|
nvplib.delete_lrouter(self.cluster, id)
|
||||||
|
|
||||||
if id in self._router_type:
|
if id in self._router_type:
|
||||||
del self._router_type[id]
|
del self._router_type[id]
|
||||||
|
|
||||||
@ -1528,24 +1526,33 @@ class VcnsCallbacks(object):
|
|||||||
lrouter = jobdata['lrouter']
|
lrouter = jobdata['lrouter']
|
||||||
context = jobdata['context']
|
context = jobdata['context']
|
||||||
name = task.userdata['router_name']
|
name = task.userdata['router_name']
|
||||||
router_db = self.plugin._get_router(context, lrouter['uuid'])
|
router_db = None
|
||||||
|
try:
|
||||||
|
router_db = self.plugin._get_router(context, lrouter['uuid'])
|
||||||
|
except l3.RouterNotFound:
|
||||||
|
# Router might have been deleted before deploy finished
|
||||||
|
LOG.exception(_("Router %s not found"), lrouter['uuid'])
|
||||||
|
|
||||||
if task.status == TaskStatus.COMPLETED:
|
if task.status == TaskStatus.COMPLETED:
|
||||||
LOG.debug(_("Successfully deployed %(edge_id)s for "
|
LOG.debug(_("Successfully deployed %(edge_id)s for "
|
||||||
"router %(name)s"), {
|
"router %(name)s"), {
|
||||||
'edge_id': task.userdata['edge_id'],
|
'edge_id': task.userdata['edge_id'],
|
||||||
'name': name})
|
'name': name})
|
||||||
if router_db['status'] == service_constants.PENDING_CREATE:
|
if (router_db and
|
||||||
|
router_db['status'] == service_constants.PENDING_CREATE):
|
||||||
router_db['status'] = service_constants.ACTIVE
|
router_db['status'] = service_constants.ACTIVE
|
||||||
binding = vcns_db.get_vcns_router_binding(
|
|
||||||
context.session, lrouter['uuid'])
|
binding = vcns_db.get_vcns_router_binding(
|
||||||
# only update status to active if its status is pending create
|
context.session, lrouter['uuid'])
|
||||||
if binding['status'] == service_constants.PENDING_CREATE:
|
# only update status to active if its status is pending create
|
||||||
vcns_db.update_vcns_router_binding(
|
if binding['status'] == service_constants.PENDING_CREATE:
|
||||||
context.session, lrouter['uuid'],
|
vcns_db.update_vcns_router_binding(
|
||||||
status=service_constants.ACTIVE)
|
context.session, lrouter['uuid'],
|
||||||
|
status=service_constants.ACTIVE)
|
||||||
else:
|
else:
|
||||||
LOG.debug(_("Failed to deploy Edge for router %s"), name)
|
LOG.debug(_("Failed to deploy Edge for router %s"), name)
|
||||||
router_db['status'] = service_constants.ERROR
|
if router_db:
|
||||||
|
router_db['status'] = service_constants.ERROR
|
||||||
vcns_db.update_vcns_router_binding(
|
vcns_db.update_vcns_router_binding(
|
||||||
context.session, lrouter['uuid'],
|
context.session, lrouter['uuid'],
|
||||||
status=service_constants.ERROR)
|
status=service_constants.ERROR)
|
||||||
|
@ -102,7 +102,8 @@ class EdgeApplianceDriver(object):
|
|||||||
}
|
}
|
||||||
if secondary:
|
if secondary:
|
||||||
address_group['secondaryAddresses'] = {
|
address_group['secondaryAddresses'] = {
|
||||||
'ipAddress': secondary
|
'ipAddress': secondary,
|
||||||
|
'type': 'IpAddressesDto'
|
||||||
}
|
}
|
||||||
|
|
||||||
vnic['addressGroups'] = {
|
vnic['addressGroups'] = {
|
||||||
|
@ -166,7 +166,7 @@ class ServiceRouterTestCase(ServiceRouterTest, NvpRouterTestCase):
|
|||||||
('admin_state_up', True),
|
('admin_state_up', True),
|
||||||
('external_gateway_info', None),
|
('external_gateway_info', None),
|
||||||
('service_router', True)]
|
('service_router', True)]
|
||||||
with self.router(name='router1', admin_state_up=True,
|
with self.router(name=name, admin_state_up=True,
|
||||||
tenant_id=tenant_id) as router:
|
tenant_id=tenant_id) as router:
|
||||||
expected_value_1 = expected_value + [('status', 'PENDING_CREATE')]
|
expected_value_1 = expected_value + [('status', 'PENDING_CREATE')]
|
||||||
for k, v in expected_value_1:
|
for k, v in expected_value_1:
|
||||||
@ -196,6 +196,21 @@ class ServiceRouterTestCase(ServiceRouterTest, NvpRouterTestCase):
|
|||||||
if lswitch['display_name'] == lswitch_name:
|
if lswitch['display_name'] == lswitch_name:
|
||||||
self.fail("Integration switch is not deleted")
|
self.fail("Integration switch is not deleted")
|
||||||
|
|
||||||
|
def test_router_delete_after_plugin_restart(self):
|
||||||
|
name = 'router1'
|
||||||
|
tenant_id = _uuid()
|
||||||
|
with self.router(name=name, admin_state_up=True,
|
||||||
|
tenant_id=tenant_id):
|
||||||
|
# clear router type cache to mimic plugin restart
|
||||||
|
plugin = NeutronManager.get_plugin()
|
||||||
|
plugin._router_type = {}
|
||||||
|
|
||||||
|
# check an integration lswitch is deleted
|
||||||
|
lswitch_name = "%s-ls" % name
|
||||||
|
for lswitch_id, lswitch in self.fc2._lswitches.iteritems():
|
||||||
|
if lswitch['display_name'] == lswitch_name:
|
||||||
|
self.fail("Integration switch is not deleted")
|
||||||
|
|
||||||
def test_router_show(self):
|
def test_router_show(self):
|
||||||
name = 'router1'
|
name = 'router1'
|
||||||
tenant_id = _uuid()
|
tenant_id = _uuid()
|
||||||
|
Loading…
Reference in New Issue
Block a user