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 datetime
|
||||||
|
import time
|
||||||
import logging
|
import logging
|
||||||
import json
|
import json
|
||||||
import trollius
|
import trollius
|
||||||
|
@ -31,20 +32,19 @@ class ComponentStatus(object):
|
||||||
class BuildComponent(BaseComponent):
|
class BuildComponent(BaseComponent):
|
||||||
""" An application session component which conducts one (or more) builds. """
|
""" 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):
|
def __init__(self, config, realm=None, token=None, **kwargs):
|
||||||
self.expected_token = token
|
self.expected_token = token
|
||||||
self.builder_realm = realm
|
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)
|
BaseComponent.__init__(self, config, **kwargs)
|
||||||
|
|
||||||
def onConnect(self):
|
def onConnect(self):
|
||||||
|
@ -213,7 +213,9 @@ class BuildComponent(BaseComponent):
|
||||||
# Parse and update the phase and the status_dict. The status dictionary contains
|
# Parse and update the phase and the status_dict. The status dictionary contains
|
||||||
# the pull/push progress, as well as the current step index.
|
# the pull/push progress, as well as the current step index.
|
||||||
with self._build_status as status_dict:
|
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)
|
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
|
# If the current message represents the beginning of a new step, then update the
|
||||||
|
@ -319,7 +321,7 @@ class BuildComponent(BaseComponent):
|
||||||
build_status = self._build_status
|
build_status = self._build_status
|
||||||
if build_status is not None:
|
if build_status is not None:
|
||||||
with build_status as status_dict:
|
with build_status as status_dict:
|
||||||
status_dict['heartbeat'] = int(datetime.time())
|
status_dict['heartbeat'] = int(time.time())
|
||||||
|
|
||||||
# Check the heartbeat from the worker.
|
# Check the heartbeat from the worker.
|
||||||
LOGGER.debug('Checking heartbeat on realm %s', self.builder_realm)
|
LOGGER.debug('Checking heartbeat on realm %s', self.builder_realm)
|
||||||
|
|
|
@ -34,12 +34,13 @@ class StatusHandler(object):
|
||||||
|
|
||||||
def set_phase(self, phase, extra_data=None):
|
def set_phase(self, phase, extra_data=None):
|
||||||
if phase == self._current_phase:
|
if phase == self._current_phase:
|
||||||
return
|
return False
|
||||||
|
|
||||||
self._current_phase = phase
|
self._current_phase = phase
|
||||||
self._append_log_message(phase, self._build_logs.PHASE, extra_data)
|
self._append_log_message(phase, self._build_logs.PHASE, extra_data)
|
||||||
self._repository_build.phase = phase
|
self._repository_build.phase = phase
|
||||||
self._repository_build.save()
|
self._repository_build.save()
|
||||||
|
return True
|
||||||
|
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
return self._status
|
return self._status
|
||||||
|
|
|
@ -154,7 +154,7 @@ class BuilderServer(object):
|
||||||
self._loop = loop
|
self._loop = loop
|
||||||
|
|
||||||
# Create the WAMP server.
|
# Create the WAMP server.
|
||||||
transport_factory = WampWebSocketServerFactory(self._session_factory, debug_wamp=False)
|
transport_factory = WampWebSocketServerFactory(self._session_factory, debug_wamp=True)
|
||||||
transport_factory.setProtocolOptions(failByDrop=True)
|
transport_factory.setProtocolOptions(failByDrop=True)
|
||||||
|
|
||||||
# Initialize the controller server and the WAMP server
|
# Initialize the controller server and the WAMP server
|
||||||
|
@ -162,4 +162,4 @@ class BuilderServer(object):
|
||||||
yield From(loop.create_server(transport_factory, host, 8080))
|
yield From(loop.create_server(transport_factory, host, 8080))
|
||||||
|
|
||||||
# Initialize the work queue checker.
|
# Initialize the work queue checker.
|
||||||
yield self._work_checker()
|
yield From(self._work_checker())
|
||||||
|
|
Reference in a new issue