buildman: linter fixes

This commit is contained in:
Evan Cordell 2016-10-04 10:42:31 -04:00
parent f4e1748bb7
commit 943a20f042

View file

@ -461,7 +461,7 @@ class EphemeralBuilderManager(BaseManager):
continue
logger.debug('Starting builder for job %s with selected executor: %s', build_uuid,
executor.name)
executor.name)
try:
execution_id = yield From(executor.start_builder(realm, token, build_uuid))
@ -496,7 +496,7 @@ class EphemeralBuilderManager(BaseManager):
# Job was started!
logger.debug('Started execution with ID %s for job: %s with executor: %s',
execution_id, build_uuid, started_with_executor.name)
# Store metric data
metric_spec = json.dumps({
'executor_name': started_with_executor.name,
@ -510,7 +510,6 @@ class EphemeralBuilderManager(BaseManager):
'UUID collision or something is very very wrong.', realm, build_uuid)
except etcd.EtcdException:
logger.exception('Exception when writing realm %s to etcd for job %s', realm, build_uuid)
# Store the realm spec which will allow any manager to accept this builder when it connects
realm_spec = json.dumps({
@ -555,7 +554,8 @@ class EphemeralBuilderManager(BaseManager):
job.build_uuid, build_component.builder_realm)
yield From(build_component.start_build(job))
yield From(self._write_duration_metric(metric_queue.builder_time_to_build, build_component.builder_realm))
yield From(self._write_duration_metric(metric_queue.builder_time_to_build,
build_component.builder_realm))
try:
# Clean up the bookkeeping for allowing any manager to take the job.
@ -573,7 +573,7 @@ class EphemeralBuilderManager(BaseManager):
build_job.build_uuid, job_status)
yield From(self._write_duration_metric(metric_queue.build_time, build_component.builder_realm))
# Mark the job as completed. Since this is being invoked from the component, we don't need
# to ask for the phase to be updated as well.
build_info = self._build_uuid_to_info.get(build_job.build_uuid, None)
@ -589,7 +589,7 @@ class EphemeralBuilderManager(BaseManager):
yield From(self._etcd_client.delete(job_key))
except (KeyError, etcd.EtcdKeyError):
logger.debug('Builder is asking for job to be removed, but work already completed')
# Delete the metric from etcd
metric_key = self._etcd_metric_key(build_component.builder_realm)
try:
@ -671,8 +671,8 @@ class EphemeralBuilderManager(BaseManager):
raise Return(True)
except (KeyError, etcd.EtcdKeyError):
raise Return(False)
@coroutine
@coroutine
def _write_duration_metric(self, metric, realm):
""" Returns true if the metric was written and and false otherwise.
"""
@ -680,9 +680,11 @@ class EphemeralBuilderManager(BaseManager):
metric_data = yield From(self._etcd_client.read(self._etcd_metric_key(realm)))
parsed_metric_data = json.loads(metric_data.value)
start_time = parsed_metric_data['start_time']
metric.Observe(time.time() - start_time, labelvalues=[parsed_metric_data.get('executor_name', 'unknown')])
metric.Observe(time.time() - start_time,
labelvalues=[parsed_metric_data.get('executor_name',
'unknown')])
except Exception:
logger.exception("Could not write metric for realm %s", realm)
logger.exception("Could not write metric for realm %s", realm)
def _etcd_metric_key(self, realm):
""" Create a key which is used to track a job in etcd.