buildman: linter fixes
This commit is contained in:
parent
f4e1748bb7
commit
943a20f042
1 changed files with 12 additions and 10 deletions
|
@ -461,7 +461,7 @@ class EphemeralBuilderManager(BaseManager):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
logger.debug('Starting builder for job %s with selected executor: %s', build_uuid,
|
logger.debug('Starting builder for job %s with selected executor: %s', build_uuid,
|
||||||
executor.name)
|
executor.name)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
execution_id = yield From(executor.start_builder(realm, token, build_uuid))
|
execution_id = yield From(executor.start_builder(realm, token, build_uuid))
|
||||||
|
@ -496,7 +496,7 @@ class EphemeralBuilderManager(BaseManager):
|
||||||
# Job was started!
|
# Job was started!
|
||||||
logger.debug('Started execution with ID %s for job: %s with executor: %s',
|
logger.debug('Started execution with ID %s for job: %s with executor: %s',
|
||||||
execution_id, build_uuid, started_with_executor.name)
|
execution_id, build_uuid, started_with_executor.name)
|
||||||
|
|
||||||
# Store metric data
|
# Store metric data
|
||||||
metric_spec = json.dumps({
|
metric_spec = json.dumps({
|
||||||
'executor_name': started_with_executor.name,
|
'executor_name': started_with_executor.name,
|
||||||
|
@ -510,7 +510,6 @@ class EphemeralBuilderManager(BaseManager):
|
||||||
'UUID collision or something is very very wrong.', realm, build_uuid)
|
'UUID collision or something is very very wrong.', realm, build_uuid)
|
||||||
except etcd.EtcdException:
|
except etcd.EtcdException:
|
||||||
logger.exception('Exception when writing realm %s to etcd for job %s', realm, build_uuid)
|
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
|
# Store the realm spec which will allow any manager to accept this builder when it connects
|
||||||
realm_spec = json.dumps({
|
realm_spec = json.dumps({
|
||||||
|
@ -555,7 +554,8 @@ class EphemeralBuilderManager(BaseManager):
|
||||||
job.build_uuid, build_component.builder_realm)
|
job.build_uuid, build_component.builder_realm)
|
||||||
yield From(build_component.start_build(job))
|
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:
|
try:
|
||||||
# Clean up the bookkeeping for allowing any manager to take the job.
|
# 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)
|
build_job.build_uuid, job_status)
|
||||||
|
|
||||||
yield From(self._write_duration_metric(metric_queue.build_time, build_component.builder_realm))
|
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
|
# 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.
|
# to ask for the phase to be updated as well.
|
||||||
build_info = self._build_uuid_to_info.get(build_job.build_uuid, None)
|
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))
|
yield From(self._etcd_client.delete(job_key))
|
||||||
except (KeyError, etcd.EtcdKeyError):
|
except (KeyError, etcd.EtcdKeyError):
|
||||||
logger.debug('Builder is asking for job to be removed, but work already completed')
|
logger.debug('Builder is asking for job to be removed, but work already completed')
|
||||||
|
|
||||||
# Delete the metric from etcd
|
# Delete the metric from etcd
|
||||||
metric_key = self._etcd_metric_key(build_component.builder_realm)
|
metric_key = self._etcd_metric_key(build_component.builder_realm)
|
||||||
try:
|
try:
|
||||||
|
@ -671,8 +671,8 @@ class EphemeralBuilderManager(BaseManager):
|
||||||
raise Return(True)
|
raise Return(True)
|
||||||
except (KeyError, etcd.EtcdKeyError):
|
except (KeyError, etcd.EtcdKeyError):
|
||||||
raise Return(False)
|
raise Return(False)
|
||||||
|
|
||||||
@coroutine
|
@coroutine
|
||||||
def _write_duration_metric(self, metric, realm):
|
def _write_duration_metric(self, metric, realm):
|
||||||
""" Returns true if the metric was written and and false otherwise.
|
""" 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)))
|
metric_data = yield From(self._etcd_client.read(self._etcd_metric_key(realm)))
|
||||||
parsed_metric_data = json.loads(metric_data.value)
|
parsed_metric_data = json.loads(metric_data.value)
|
||||||
start_time = parsed_metric_data['start_time']
|
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:
|
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):
|
def _etcd_metric_key(self, realm):
|
||||||
""" Create a key which is used to track a job in etcd.
|
""" Create a key which is used to track a job in etcd.
|
||||||
|
|
Reference in a new issue