Various small fixes
This commit is contained in:
parent
6df6f28edf
commit
63f2e7794f
3 changed files with 20 additions and 17 deletions
|
@ -1,4 +1,5 @@
|
|||
import datetime
|
||||
import time
|
||||
import logging
|
||||
import json
|
||||
import trollius
|
||||
|
@ -31,20 +32,19 @@ class ComponentStatus(object):
|
|||
class BuildComponent(BaseComponent):
|
||||
""" An application session component which conducts one (or more) builds. """
|
||||
|
||||
server_hostname = None
|
||||
expected_token = None
|
||||
builder_realm = None
|
||||
|
||||
_component_status = ComponentStatus.JOINING
|
||||
_last_heartbeat = None
|
||||
_current_job = None
|
||||
_build_status = None
|
||||
_image_info = None
|
||||
|
||||
def __init__(self, config, realm=None, token=None, **kwargs):
|
||||
self.expected_token = token
|
||||
self.builder_realm = realm
|
||||
|
||||
self.parent_manager = None
|
||||
self.server_hostname = None
|
||||
|
||||
self._component_status = ComponentStatus.JOINING
|
||||
self._last_heartbeat = None
|
||||
self._current_job = None
|
||||
self._build_status = None
|
||||
self._image_info = None
|
||||
|
||||
BaseComponent.__init__(self, config, **kwargs)
|
||||
|
||||
def onConnect(self):
|
||||
|
@ -147,7 +147,7 @@ class BuildComponent(BaseComponent):
|
|||
LOGGER.debug('With Arguments: %s', build_arguments)
|
||||
|
||||
return (self.call("io.quay.builder.build", **build_arguments)
|
||||
.add_done_callback(self._build_complete))
|
||||
.add_done_callback(self._build_complete))
|
||||
|
||||
@staticmethod
|
||||
def _total_completion(statuses, total_images):
|
||||
|
@ -213,7 +213,9 @@ class BuildComponent(BaseComponent):
|
|||
# Parse and update the phase and the status_dict. The status dictionary contains
|
||||
# the pull/push progress, as well as the current step index.
|
||||
with self._build_status as status_dict:
|
||||
self._build_status.set_phase(phase)
|
||||
if self._build_status.set_phase(phase):
|
||||
LOGGER.debug('Build %s has entered a new phase: %s', self.builder_realm, phase)
|
||||
|
||||
BuildComponent._process_pushpull_status(status_dict, phase, docker_data, self._image_info)
|
||||
|
||||
# If the current message represents the beginning of a new step, then update the
|
||||
|
@ -234,7 +236,7 @@ class BuildComponent(BaseComponent):
|
|||
def _build_failure(self, error_message, exception=None):
|
||||
""" Handles and logs a failed build. """
|
||||
self._build_status.set_error(error_message, {
|
||||
'internal_error': exception.message if exception else None
|
||||
'internal_error': exception.message if exception else None
|
||||
})
|
||||
|
||||
build_id = self._current_job.repo_build().uuid
|
||||
|
@ -319,7 +321,7 @@ class BuildComponent(BaseComponent):
|
|||
build_status = self._build_status
|
||||
if build_status is not None:
|
||||
with build_status as status_dict:
|
||||
status_dict['heartbeat'] = int(datetime.time())
|
||||
status_dict['heartbeat'] = int(time.time())
|
||||
|
||||
# Check the heartbeat from the worker.
|
||||
LOGGER.debug('Checking heartbeat on realm %s', self.builder_realm)
|
||||
|
|
Reference in a new issue