From: Philip Joseph Date: Mon, 17 Apr 2017 12:08:37 +0000 (+0530) Subject: Improve project delete tracebacks X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=2f9c4f6ae8e2d0c24871813708a9c0eea8954c21;p=osm%2FSO.git Improve project delete tracebacks Change-Id: I042faad9933127689e177ac1ef452f7c4300fb9f Signed-off-by: Philip Joseph --- diff --git a/common/python/rift/mano/dts/subscriber/core.py b/common/python/rift/mano/dts/subscriber/core.py index 63cb3211..7bf94f62 100644 --- a/common/python/rift/mano/dts/subscriber/core.py +++ b/common/python/rift/mano/dts/subscriber/core.py @@ -114,8 +114,11 @@ class AbstractOpdataSubscriber(SubscriberDtsHandler): except Exception as e: self.log.exception(e) - finally: + try: xact_info.respond_xpath(rwdts.XactRspCode.ACK) + except rift.tasklets.dts.ResponseError as e: + self._log.error("Reg handle is None during action {} for {}: {}". + format(action, self.__class__, e)) reg_event = asyncio.Event(loop=self.loop) @@ -166,9 +169,15 @@ class AbstractConfigSubscriber(SubscriberDtsHandler): if xact.xact is None: if action == rwdts.AppconfAction.INSTALL: try: - for cfg in self.reg.elements: - if self.callback: - self.callback(cfg, rwdts.QueryAction.CREATE) + if self.reg: + for cfg in self.reg.elements: + if self.callback: + self.callback(cfg, rwdts.QueryAction.CREATE) + + else: + self._log.error("Reg handle is None during action {} for {}". + format(action, self.__class__)) + except Exception as e: self._log.exception("Adding config {} during restart failed: {}". format(cfg, e)) @@ -193,7 +202,12 @@ class AbstractConfigSubscriber(SubscriberDtsHandler): """ on prepare callback """ self._log.debug("Subscriber DTS prepare for project %s: %s", self.project, xact_info.query_action) - xact_info.respond_xpath(rwdts.XactRspCode.ACK) + try: + xact_info.respond_xpath(rwdts.XactRspCode.ACK) + except rift.tasklets.dts.ResponseError as e: + self._log.error( + "Subscriber DTS prepare for project {}, action {} in class {} failed: {}". + format(self.project, xact_info.query_action, self.__class__, e)) acg_hdl = rift.tasklets.AppConfGroup.Handler(on_apply=on_apply) with self.dts.appconf_group_create(handler=acg_hdl) as acg: diff --git a/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/rwnsmtasklet.py b/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/rwnsmtasklet.py index 061ade0c..907831a9 100755 --- a/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/rwnsmtasklet.py +++ b/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/rwnsmtasklet.py @@ -2856,7 +2856,9 @@ class NsdDtsHandler(object): self._nsm.update_nsd(cfg) else: - self._log.error("No reg handle for {} for project {}". + # This can happen if we do the deregister + # during project delete before this is called + self._log.debug("No reg handle for {} for project {}". format(self.__class__, self._project.name)) scratch.pop('nsds', None) @@ -2905,9 +2907,10 @@ class NsdDtsHandler(object): xact_info.respond_xpath(rwdts.XactRspCode.ACK) + xpath = self._project.add_project(NsdDtsHandler.XPATH) self._log.debug( "Registering for NSD config using xpath: %s", - NsdDtsHandler.XPATH, + xpath, ) acg_hdl = rift.tasklets.AppConfGroup.Handler(on_apply=on_apply) @@ -2915,7 +2918,7 @@ class NsdDtsHandler(object): # Need a list in scratch to store NSDs to create/update later # acg._scratch['nsds'] = list() self._regh = acg.register( - xpath=self._project.add_project(NsdDtsHandler.XPATH), + xpath=xpath, flags=rwdts.Flag.SUBSCRIBER | rwdts.Flag.DELTA_READY | rwdts.Flag.CACHE, on_prepare=on_prepare) @@ -2982,8 +2985,9 @@ class VnfdDtsHandler(object): @asyncio.coroutine def on_prepare(dts, acg, xact, xact_info, ks_path, msg, scratch): """ on prepare callback """ + xpath = ks_path.to_xpath(NsdYang.get_schema()) self._log.debug("Got on prepare for VNFD (path: %s) (action: %s) (msg: %s)", - ks_path.to_xpath(NsdYang.get_schema()), xact_info.query_action, msg) + xpath, xact_info.query_action, msg) fref = ProtobufC.FieldReference.alloc() fref.goto_whole_message(msg.to_pbcm()) @@ -2998,7 +3002,13 @@ class VnfdDtsHandler(object): vnfds = scratch.setdefault('vnfds', []) vnfds.append(msg.id) - xact_info.respond_xpath(rwdts.XactRspCode.ACK) + try: + xact_info.respond_xpath(rwdts.XactRspCode.ACK) + except rift.tasklets.dts.ResponseError as e: + self._log.error( + "VnfdDtsHandler in project {} with path {} for action {} failed: {}". + format(self._project, xpath, xact_info.query_action, e)) + xpath = self._project.add_project(VnfdDtsHandler.XPATH) self._log.debug( @@ -3805,7 +3815,7 @@ class NsManager(object): self._conf_url = "https://{ip}:{port}/api/config". \ format(ip=self._ip, port=self._rport) - + self._nsrs = {} self._nsds = {} self._vnfds = {} diff --git a/rwlaunchpad/plugins/rwvnfm/rift/tasklets/rwvnfmtasklet/rwvnfmtasklet.py b/rwlaunchpad/plugins/rwvnfm/rift/tasklets/rwvnfmtasklet/rwvnfmtasklet.py index 50e7f26b..96ccaf8c 100755 --- a/rwlaunchpad/plugins/rwvnfm/rift/tasklets/rwvnfmtasklet/rwvnfmtasklet.py +++ b/rwlaunchpad/plugins/rwvnfm/rift/tasklets/rwvnfmtasklet/rwvnfmtasklet.py @@ -2061,8 +2061,9 @@ class VnfdDtsHandler(object): @asyncio.coroutine def on_prepare(dts, acg, xact, xact_info, ks_path, msg, scratch): """ on prepare callback """ + xpath = ks_path.to_xpath(RwVnfmYang.get_schema()) self._log.debug("Got on prepare for VNFD (path: %s) (action: %s) (msg: %s)", - ks_path.to_xpath(RwVnfmYang.get_schema()), + xpath, xact_info.query_action, msg) fref = ProtobufC.FieldReference.alloc() fref.goto_whole_message(msg.to_pbcm()) @@ -2078,7 +2079,12 @@ class VnfdDtsHandler(object): # Delete a VNFD record yield from self._vnfm.delete_vnfd(msg.id) - xact_info.respond_xpath(rwdts.XactRspCode.ACK) + try: + xact_info.respond_xpath(rwdts.XactRspCode.ACK) + except rift.tasklets.dts.ResponseError as e: + self._log.error( + "VnfdDtsHandler in project {} with path {} for action {} failed: {}". + format(self._vnfm._project, xpath, xact_info.query_action, e)) xpath = self._vnfm._project.add_project(VnfdDtsHandler.XPATH) self._log.debug("Registering for VNFD config using xpath: {}".