Merge lp:~cprov/adt-cloud-worker/int-error into lp:adt-cloud-worker

Proposed by Celso Providelo
Status: Merged
Approved by: Celso Providelo
Approved revision: 33
Merged at revision: 33
Proposed branch: lp:~cprov/adt-cloud-worker/int-error
Merge into: lp:adt-cloud-worker
Diff against target: 35 lines (+7/-4)
1 file modified
adt_cloud_worker/__init__.py (+7/-4)
To merge this branch: bzr merge lp:~cprov/adt-cloud-worker/int-error
Reviewer Review Type Date Requested Status
Thomi Richards (community) Approve
Review via email: mp+253905@code.launchpad.net

Commit message

Fix special 'exit_code' value to 100 (int not string) and also include traceback information in the message payload for helping later debug.

Description of the change

Fix special 'exit_code' value to 100 (int not string) and also include traceback information in the message payload for helping later debug.

To post a comment you must log in.
Revision history for this message
Thomi Richards (thomir-deactivatedaccount) wrote :

LGTM - we need to be careful about where we publish tracebacks to, but in this case the rabbitmq messages are always private.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'adt_cloud_worker/__init__.py'
--- adt_cloud_worker/__init__.py 2015-03-20 19:17:25 +0000
+++ adt_cloud_worker/__init__.py 2015-03-24 01:56:50 +0000
@@ -31,6 +31,7 @@
31import subprocess31import subprocess
32import tarfile32import tarfile
33import tempfile33import tempfile
34import traceback
3435
35from adt_cloud_worker._cloud_support import (36from adt_cloud_worker._cloud_support import (
36 get_default_testbed_flavor,37 get_default_testbed_flavor,
@@ -118,17 +119,19 @@
118 container_name = 'adt-{}'.format(body['request_id'])119 container_name = 'adt-{}'.format(body['request_id'])
119 upload_tarball_to_swift_container(tarball_path, container_name)120 upload_tarball_to_swift_container(tarball_path, container_name)
120 except Exception as e:121 except Exception as e:
121 # Unexpected failures ...122 # Unexpected failures are tagged with special exit_code 100 and
122 body['exit_code'] = '100'123 # carry the worker_traceback in the message payload. This will
124 # help debugging of deadletter-ed messages.
125 body['exit_code'] = 100
126 body['worker_traceback'] = traceback.format_exc()
123 logger.error(e, exc_info=True, extra=body)127 logger.error(e, exc_info=True, extra=body)
124 finally:128 finally:
125 logger.info('Posting results: %s', body, extra=body)129 logger.info('Posting results: %s', body, extra=body)
126 # TODO: send error logging to result-checker in the message.
127 queue = self.connection.SimpleQueue(130 queue = self.connection.SimpleQueue(
128 'adt.results.{}'.format(API_VERSION))131 'adt.results.{}'.format(API_VERSION))
129 queue.put(body)132 queue.put(body)
130 queue.close()133 queue.close()
131 if tarball_path and os.path.exists(tarball_path):134 if tarball_path is not None and os.path.exists(tarball_path):
132 os.remove(tarball_path)135 os.remove(tarball_path)
133 message.ack()136 message.ack()
134 logger.info('Done!', extra=body)137 logger.info('Done!', extra=body)

Subscribers

People subscribed via source and target branches