From 7c862f7d2cfdcd97a799b53268571447dbfbb3f4 Mon Sep 17 00:00:00 2001 From: elajkat Date: Wed, 19 Jan 2022 11:14:48 +0100 Subject: [PATCH] Do not try to call status setting methods in case of periodic task [0] enhanced the failure handling of taas agent, but the handling of periodic_task was left out, which resulted in exceptions: KeyError: 'periodic_tasks'. To avoid such exception TaasAgentRpcCallback's self.func_dict must be extended with periodic_task entry. [0]: https://review.opendev.org/c/openstack/tap-as-a-service/+/681946 Change-Id: I623e373b391605f69e9f3ed8f50c6d99f15198bf Closes-Bug: #1958373 --- .../services/taas/agents/common/taas_agent.py | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/neutron_taas/services/taas/agents/common/taas_agent.py b/neutron_taas/services/taas/agents/common/taas_agent.py index a6583ac9..d7396010 100644 --- a/neutron_taas/services/taas/agents/common/taas_agent.py +++ b/neutron_taas/services/taas/agents/common/taas_agent.py @@ -118,7 +118,10 @@ class TaasAgentRpcCallback(api.TaasAgentRpcCallbackMixin): 'msg_name': 'tap_flow', 'set_status_func_name': 'set_tap_flow_status', 'fail_status': constants.PENDING_DELETE, - 'succ_status': constants.INACTIVE} + 'succ_status': constants.INACTIVE}, + 'periodic_tasks': { + 'msg_name': 'periodic_tasks', + } } self.portbind_drivers_map = {portbindings.VNIC_DIRECT: 'sriov', portbindings.VNIC_NORMAL: 'ovs'} @@ -132,7 +135,9 @@ class TaasAgentRpcCallback(api.TaasAgentRpcCallbackMixin): LOG.debug("Invoking Driver for %(func_name)s from agent", {'func_name': func_name}) - status_msg = {'id': args[self.func_dict[func_name]['msg_name']]['id']} + if func_name != 'periodic_tasks': + func_dict = self.func_dict[func_name] + status_msg = {'id': args[func_dict['msg_name']]['id']} try: self.taas_driver.__getattribute__(func_name)(args) @@ -146,11 +151,12 @@ class TaasAgentRpcCallback(api.TaasAgentRpcCallbackMixin): self.conf.host) return - self.taas_plugin_rpc.__getattribute__( - self.func_dict[func_name]['set_status_func_name'])( - status_msg, - self.func_dict[func_name]['succ_status'], - self.conf.host) + if func_name != 'periodic_tasks': + self.taas_plugin_rpc.__getattribute__( + self.func_dict[func_name]['set_status_func_name'])( + status_msg, + self.func_dict[func_name]['succ_status'], + self.conf.host) def create_tap_service(self, context, tap_service, host): """Handle Rpc from plugin to create a tap_service."""