1
0
mirror of https://github.com/quay/quay.git synced 2025-04-18 10:44:06 +03:00

buildman: Set build token expiration to builder's lifetime (PROJQUAY-3281) (#1142)

Make sure the build token doesn't expire before the builder instance
does. Set the expiration to the builder instances' max expiration.
This commit is contained in:
Kenny Lee Sin Cheong 2022-02-23 18:11:19 -05:00 committed by GitHub
parent a0443340cb
commit 32691dd812
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 6 deletions

View File

@ -68,9 +68,8 @@ class BuildManagerServicer(buildman_pb2_grpc.BuildManagerServicer):
return buildman_pb2.BuildPack()
job_id = decoded_token["job_id"]
max_build_time = decoded_token["expiration"]
token, build_args = self._lifecycle_manager.start_job(job_id, max_build_time)
token, build_args = self._lifecycle_manager.start_job(job_id)
if not token or not build_args:
msg = "Build manager unable to start job"
self._handle_error(context, grpc.StatusCode.INTERNAL, msg)

View File

@ -70,10 +70,9 @@ class BuildStateInterface(ABC):
"""
@abstractmethod
def start_job(self, job_id, max_build_time):
def start_job(self, job_id):
"""Mark a job as started.
Returns False if the job does not exists, or has already started.
The worker's lifetime should be set to max_build_time
"""
@abstractmethod

View File

@ -369,7 +369,7 @@ class EphemeralBuilderManager(BuildStateInterface):
logger.debug("Job completed for job %s with result %s", job_id, job_result)
def start_job(self, job_id, max_build_time):
def start_job(self, job_id):
"""Starts the build job. This is invoked by the worker once the job has been created and
scheduled, returing the buildpack needed to start the actual build.
"""
@ -431,7 +431,7 @@ class EphemeralBuilderManager(BuildStateInterface):
# Generate the build token
token = self.generate_build_token(
BUILD_JOB_TOKEN_TYPE, build_job.build_uuid, job_id, max_build_time
BUILD_JOB_TOKEN_TYPE, build_job.build_uuid, job_id, self.machine_max_expiration
)
# Publish the time it took for a worker to ack the build