Handle mqtt errors on failures before out_event is set
There are some conditions where we fail before out_event is defined. In those cases the mqtt publish won't work and will raise an exception because out_event is not defined. This commit addresses that by using fields instead of out_event. (which is the original source for out_event) Fields exists earlier and build_uuid always remains the same across the 2 dicts. Additionally we define fields to an empty dict outside of the try to ensure that in the off chance of a failure before fields is defined we don't fail sending a failure on mqtt. Change-Id: I546a2ee42ea0f67f35c5e132d51f239a32a5582e
This commit is contained in:
parent
5e8ec7ad3f
commit
4037e7b1ba
|
@ -110,6 +110,7 @@ class SubunitRetriever(object):
|
|||
logging.exception("Exception retrieving log event.")
|
||||
|
||||
def _handle_event(self):
|
||||
fields = {}
|
||||
job = self.gearman_worker.getJob()
|
||||
try:
|
||||
arguments = json.loads(job.arguments.decode('utf-8'))
|
||||
|
@ -146,11 +147,11 @@ class SubunitRetriever(object):
|
|||
job.sendWorkException(str(e).encode('utf-8'))
|
||||
if self.mqtt:
|
||||
msg = json.dumps({
|
||||
'build_uuid': out_event.get('build_uuid'),
|
||||
'build_uuid': fields.get('build_uuid'),
|
||||
'status': 'failed',
|
||||
})
|
||||
self.mqtt.publish_single(msg, out_event.get('project'),
|
||||
out_event.get('build_change'))
|
||||
self.mqtt.publish_single(msg, fields.get('project'),
|
||||
fields.get('build_change'))
|
||||
|
||||
def _retrieve_subunit_v2(self, source_url, retry):
|
||||
# TODO (clarkb): This should check the content type instead of file
|
||||
|
|
Loading…
Reference in New Issue