Skip to content

Commit

Permalink
buildman: Set build token expiration to builder's lifetime (PROJQUAY-…
Browse files Browse the repository at this point in the history
…3281) (#1142)

Make sure the build token doesn't expire before the builder instance
does. Set the expiration to the builder instances' max expiration.
  • Loading branch information
kleesc authored Feb 23, 2022
1 parent a044334 commit 32691dd
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
3 changes: 1 addition & 2 deletions buildman/buildmanagerservicer.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,8 @@ def RegisterBuildJob(self, request, context):
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)
Expand Down
3 changes: 1 addition & 2 deletions buildman/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,9 @@ def on_job_complete(self, build_job, job_result, executor_name, execution_id):
"""

@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
Expand Down
4 changes: 2 additions & 2 deletions buildman/manager/ephemeral.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ def on_job_complete(self, build_job, job_result, executor_name, execution_id):

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.
"""
Expand Down Expand Up @@ -431,7 +431,7 @@ def start_job(self, job_id, max_build_time):

# 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
Expand Down

0 comments on commit 32691dd

Please sign in to comment.