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
This commit is contained in:
elajkat 2022-01-19 11:14:48 +01:00
parent c919ccd485
commit 7c862f7d2c

View File

@ -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."""