~psivaa/adt-cloud-worker/add-build-essential

« back to all changes in this revision

Viewing changes to adt_cloud_worker/__init__.py

  • Committer: Ubuntu CI Bot
  • Author(s): Joe Talbott
  • Date: 2015-04-15 21:34:11 UTC
  • mfrom: (34.1.3 add_logging_extra)
  • Revision ID: ubuntu_ci_bot-20150415213411-lrg2220a9l5lead2
Add logging_extra. [r=Parameswaran Sivatharman]

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
    set_config_dict,
39
39
    upload_tarball_to_swift_container,
40
40
)
 
41
from adt_cloud_worker.constants import (
 
42
    API_VERSION,
 
43
    logging_extra,
 
44
)
41
45
 
42
46
ARCHITECTURES = (
43
47
    'amd64',
44
48
    'i386'
45
49
)
46
 
API_VERSION = "v1"
47
50
 
48
51
 
49
52
logger = logging.getLogger(__name__)
86
89
        for later checking.
87
90
        """
88
91
        body['worker'] = self.worker_name
89
 
        logger.info('Received message request: %s', body, extra=body)
 
92
        extra = logging_extra.copy()
 
93
        extra.update(body)
 
94
        logger.info('Received message request: %s', body, extra=extra)
90
95
 
91
96
        # Run requested tests safely.
92
97
        tarball_path = None
105
110
                arguments = _make_adt_argument_list(adt_kwargs)
106
111
                logger.info(
107
112
                    'Running adt-run with: %s', ' '.join(arguments),
108
 
                    extra=body)
 
113
                    extra=extra)
109
114
                body['exit_code'] = run_adt(arguments)
110
115
                logger.info(
111
 
                    'Exit code: %s', body['exit_code'], extra=body)
 
116
                    'Exit code: %s', body['exit_code'], extra=extra)
112
117
                _create_run_metadata_file(result_dir, body)
113
118
                tarball_path = _create_tarball_from_directory(
114
119
                    result_dir,
124
129
            # help debugging of deadletter-ed messages.
125
130
            body['exit_code'] = 100
126
131
            body['worker_traceback'] = traceback.format_exc()
127
 
            logger.error(e, exc_info=True, extra=body)
 
132
            logger.error(e, exc_info=True, extra=extra)
128
133
        finally:
129
 
            logger.info('Posting results: %s', body, extra=body)
 
134
            logger.info('Posting results: %s', body, extra=extra)
130
135
            queue = self.connection.SimpleQueue(
131
136
                'adt.results.{}'.format(API_VERSION))
132
137
            queue.put(body)
134
139
            if tarball_path is not None and os.path.exists(tarball_path):
135
140
                os.remove(tarball_path)
136
141
            message.ack()
137
 
            logger.info('Done!', extra=body)
 
142
            logger.info('Done!', extra=extra)
138
143
 
139
144
 
140
145
def _create_run_metadata_file(directory, request):