Make sure build components timeout if the initial connection fails
This commit is contained in:
parent
ecebc06343
commit
bead839abd
1 changed files with 10 additions and 4 deletions
|
@ -17,6 +17,7 @@ from buildman.jobutil.workererror import WorkerError
|
||||||
from data.database import BUILD_PHASE
|
from data.database import BUILD_PHASE
|
||||||
|
|
||||||
HEARTBEAT_DELTA = datetime.timedelta(seconds=30)
|
HEARTBEAT_DELTA = datetime.timedelta(seconds=30)
|
||||||
|
BUILD_HEARTBEAT_DELAY = datetime.timedelta(seconds=30)
|
||||||
HEARTBEAT_TIMEOUT = 10
|
HEARTBEAT_TIMEOUT = 10
|
||||||
INITIAL_TIMEOUT = 25
|
INITIAL_TIMEOUT = 25
|
||||||
|
|
||||||
|
@ -76,8 +77,8 @@ class BuildComponent(BaseComponent):
|
||||||
@trollius.coroutine
|
@trollius.coroutine
|
||||||
def start_build(self, build_job):
|
def start_build(self, build_job):
|
||||||
""" Starts a build. """
|
""" Starts a build. """
|
||||||
logger.debug('Starting build for component %s (worker version: %s)',
|
logger.debug('Starting build for component %s (build %s, worker version: %s)',
|
||||||
self.builder_realm, self._worker_version)
|
self.builder_realm, build_job.repo_build.uuid, self._worker_version)
|
||||||
|
|
||||||
self._current_job = build_job
|
self._current_job = build_job
|
||||||
self._build_status = StatusHandler(self.build_logs, build_job.repo_build.uuid)
|
self._build_status = StatusHandler(self.build_logs, build_job.repo_build.uuid)
|
||||||
|
@ -150,6 +151,11 @@ class BuildComponent(BaseComponent):
|
||||||
|
|
||||||
self.call("io.quay.builder.build", **build_arguments).add_done_callback(self._build_complete)
|
self.call("io.quay.builder.build", **build_arguments).add_done_callback(self._build_complete)
|
||||||
|
|
||||||
|
# Set the heartbeat for the future. If the builder never receives the build call,
|
||||||
|
# then this will cause a timeout after 30 seconds. We know the builder has registered
|
||||||
|
# by this point, so it makes sense to have a timeout.
|
||||||
|
self._last_heartbeat = datetime.datetime.utcnow() + BUILD_HEARTBEAT_DELAY
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _commit_sha(build_config):
|
def _commit_sha(build_config):
|
||||||
""" Determines whether the metadata is using an old schema or not and returns the commit. """
|
""" Determines whether the metadata is using an old schema or not and returns the commit. """
|
||||||
|
@ -401,8 +407,8 @@ class BuildComponent(BaseComponent):
|
||||||
yield From(self._timeout())
|
yield From(self._timeout())
|
||||||
raise Return()
|
raise Return()
|
||||||
|
|
||||||
logger.debug('Heartbeat on realm %s is valid: %s.', self.builder_realm,
|
logger.debug('Heartbeat on realm %s is valid: %s (%s).', self.builder_realm,
|
||||||
self._last_heartbeat)
|
self._last_heartbeat, self._component_status)
|
||||||
|
|
||||||
yield From(trollius.sleep(HEARTBEAT_TIMEOUT))
|
yield From(trollius.sleep(HEARTBEAT_TIMEOUT))
|
||||||
|
|
||||||
|
|
Reference in a new issue