Skip to content

Commit

Permalink
Delete bgpaas-server object when VN is deleted
Browse files Browse the repository at this point in the history
It is possible that one bgpaas-client object is being created while another one
is being deleted. To avoid race condition during this, we will leave the
bgpaas-server object when the client is deleted. These objects will be deleted
when the VN iteself is deleted. There are no resources held by such object, so
it should be ok to keep them even when they are not being used.

Also fixed a traceback in api server due to not catching cassandra
NotFoundException during update_last_modified.

Change-Id: Iaeea4b13d35443cd015b6b4e1145249d1bfc2606
Closes-Bug: 1529983
  • Loading branch information
Sachin Bansal committed Jan 6, 2016
1 parent daadb34 commit f1ac6fc
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
4 changes: 1 addition & 3 deletions src/config/api-server/vnc_cfg_ifmap.py
Expand Up @@ -894,9 +894,7 @@ def is_latest(self, id, tstamp):

def update_last_modified(self, bch, obj_uuid, id_perms=None):
if id_perms is None:
id_perms = json.loads(
self._obj_uuid_cf.get(obj_uuid,
['prop:id_perms'])['prop:id_perms'])
id_perms = self.uuid_to_obj_perms(obj_uuid)
id_perms['last_modified'] = datetime.datetime.utcnow().isoformat()
self._update_prop(bch, obj_uuid, 'id_perms', {'id_perms': id_perms})
# end update_last_modified
Expand Down
13 changes: 10 additions & 3 deletions src/config/api-server/vnc_cfg_types.py
Expand Up @@ -766,17 +766,18 @@ def post_dbe_delete(cls, id, obj_dict, db_conn):
ri_uuid = db_conn.fq_name_to_uuid(
'routing-instance', ri_fq_name)

backref_fields = list(RoutingInstance.backref_fields)
backref_fields = RoutingInstance.backref_fields
children_fields = RoutingInstance.children_fields
ok, result = db_conn.dbe_read(
obj_type='routing-instance',
obj_ids={'uuid': ri_uuid},
obj_fields=backref_fields)
obj_fields=backref_fields|children_fields)
if not ok:
return ok, result

ri_obj_dict = result
backref_field_types = RoutingInstance.backref_field_types
for backref_field in backref_fields:
backref_field_types = RoutingInstance.backref_field_types
obj_type = backref_field_types[backref_field][0]
def drop_ref(obj_uuid):
# drop ref from ref_uuid to ri_uuid
Expand All @@ -787,6 +788,12 @@ def drop_ref(obj_uuid):
for backref in ri_obj_dict.get(backref_field, []):
drop_ref(backref['uuid'])

children_field_types = RoutingInstance.children_field_types
for child_field in children_fields:
obj_type = children_field_types[child_field][0]
for child in ri_obj_dict.get(child_field, []):
cls.server.internal_request_delete(obj_type, child['uuid'])

cls.server.internal_request_delete('routing-instance', ri_uuid)

return True, ""
Expand Down
9 changes: 9 additions & 0 deletions src/config/schema-transformer/config_db.py
Expand Up @@ -2068,6 +2068,14 @@ def delete_obj(self):
if rp:
rp.delete_routing_instance(self.name)
self.routing_policys = {}
bgpaas_server_name = self.obj.get_fq_name_str() + ':bgpaas-server'
bgpaas_server = BgpRouterST.get(bgpaas_server_name)
if bgpaas_server:
try:
self._vnc_lib.bgp_router_delete(id=bgpaas_server.obj.uuid)
except NoIdError:
pass
BgpRouterST.delete(bgpaas_server_name)
try:
DBBaseST._vnc_lib.routing_instance_delete(id=self.obj.uuid)
except NoIdError:
Expand Down Expand Up @@ -2647,6 +2655,7 @@ def evaluate(self):
except NoIdError:
pass
self._vnc_lib.bgp_router_delete(id=self.obj.uuid)
BgpRouterST.delete(self.name)
elif ret:
self._vnc_lib.bgp_router_update(self.obj)
elif self.router_type != 'bgpaas-server':
Expand Down

0 comments on commit f1ac6fc

Please sign in to comment.