Handle exceptions in executor reply processors

Closes bug 1457477

Change-Id: Iee4dfd7db915fe9b128fa638556c2ece23d136b4
This commit is contained in:
Ilya Shakhat
2015-05-26 15:39:19 +03:00
parent f6cdfccbd1
commit d0f13b693c
5 changed files with 116 additions and 2 deletions

View File

@@ -19,6 +19,7 @@ import time
from oslo_log import log as logging
from shaker.agent import agent as agent_process
from shaker.engine.executors import base as base_executors
from shaker.engine import messaging
@@ -44,6 +45,9 @@ class BaseOperation(object):
def process_reply(self, agent_id, message):
return {'status': 'ok'}
def process_error(self, agent_id, exception):
return {'status': 'error', 'info': str(exception)}
def process_failure(self, agent_id):
return {'status': 'lost'}
@@ -87,8 +91,16 @@ class ExecuteOperation(BaseOperation):
return reply
def process_reply(self, agent_id, message):
r = super(ExecuteOperation, self).process_reply(agent_id, message)
r.update(self.executors[agent_id].process_reply(message))
try:
reply = self.executors[agent_id].process_reply(message)
r = super(ExecuteOperation, self).process_reply(agent_id, message)
r.update(reply)
except base_executors.ExecutorException as e:
r = super(ExecuteOperation, self).process_error(agent_id, e)
r.update(e.record)
except Exception as e:
r = super(ExecuteOperation, self).process_error(agent_id, e)
return r
def process_failure(self, agent_id):