Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • edbaunton/buildgrid
  • BuildGrid/buildgrid
  • bloomberg/buildgrid
  • devcurmudgeon/buildgrid
  • mhadjimichael/buildgrid
  • jmacarthur/buildgrid
  • rkothur/buildgrid
  • valentindavid/buildgrid
  • jjardon/buildgrid
  • RichKen/buildgrid
  • jbonney/buildgrid
  • onsha_alexander/buildgrid
  • santigl/buildgrid
  • mostynb/buildgrid
  • hoffbrinkle/buildgrid
  • Malinskiy/buildgrid
  • coldtom/buildgrid
  • azeemb_a/buildgrid
  • pointswaves/buildgrid
  • BenjaminSchubert/buildgrid
  • michaellee8/buildgrid
  • anil-anil/buildgrid
  • seanborg/buildgrid
  • jdelong12/buildgrid
  • jclay/buildgrid
  • bweston92/buildgrid
  • zchen723/buildgrid
  • cpratt34/buildgrid
  • armbiant/apache-buildgrid
  • armbiant/android-buildgrid
  • itsme300/buildgrid
  • sbairoliya/buildgrid
32 results
Show changes
Commits on Source (4)
......@@ -83,7 +83,7 @@ class BotsInterface:
self._check_bot_ids(bot_session.bot_id, name)
self._check_assigned_leases(bot_session)
for lease in bot_session.leases:
for lease in list(bot_session.leases):
checked_lease = self._check_lease_state(lease)
if not checked_lease:
# TODO: Make sure we don't need this
......@@ -91,7 +91,10 @@ class BotsInterface:
self._assigned_leases[name].remove(lease.id)
except KeyError:
pass
lease.Clear()
self._scheduler.delete_job_lease(lease.id)
bot_session.leases.remove(lease)
self._request_leases(bot_session)
return bot_session
......@@ -117,7 +120,7 @@ class BotsInterface:
try:
if self._scheduler.get_job_lease_cancelled(lease.id):
lease.state.CopyFrom(LeaseState.CANCELLED.value)
lease.state = LeaseState.CANCELLED.value
return lease
except KeyError:
# Job does not exist, remove from bot.
......
......@@ -222,6 +222,13 @@ class Job:
if self._lease is not None:
self.update_lease_state(LeaseState.CANCELLED)
def delete_lease(self):
"""Discard the job's :class:Lease."""
self.__worker_start_timestamp.Clear()
self.__worker_completed_timestamp.Clear()
self._lease = None
def update_operation_stage(self, stage):
"""Operates a stage transition for the job's :class:Operation.
......
......@@ -62,18 +62,8 @@ class Scheduler:
job.unregister_client(queue)
if not job.n_clients and job.operation.done:
del self.jobs[job_name]
if self._is_instrumented:
self.__operations_by_stage[OperationStage.CACHE_CHECK].discard(job_name)
self.__operations_by_stage[OperationStage.QUEUED].discard(job_name)
self.__operations_by_stage[OperationStage.EXECUTING].discard(job_name)
self.__operations_by_stage[OperationStage.COMPLETED].discard(job_name)
self.__leases_by_state[LeaseState.PENDING].discard(job_name)
self.__leases_by_state[LeaseState.ACTIVE].discard(job_name)
self.__leases_by_state[LeaseState.COMPLETED].discard(job_name)
if not job.n_clients and job.operation.done and not job.lease:
self._delete_job(job.name)
def queue_job(self, job, skip_cache_lookup=False):
self.jobs[job.name] = job
......@@ -199,6 +189,15 @@ class Scheduler:
"""Returns true if the lease is cancelled"""
return self.jobs[job_name].lease_cancelled
def delete_job_lease(self, job_name):
"""Discards the lease associated to a job."""
job = self.jobs[job_name]
self.jobs[job.name].delete_lease()
if not job.n_clients and job.operation.done:
self._delete_job(job.name)
def get_job_operation(self, job_name):
"""Returns the operation associated to job."""
return self.jobs[job_name].operation
......@@ -296,6 +295,20 @@ class Scheduler:
# --- Private API ---
def _delete_job(self, job_name):
"""Drops an entry from the internal list of jobs."""
del self.jobs[job_name]
if self._is_instrumented:
self.__operations_by_stage[OperationStage.CACHE_CHECK].discard(job_name)
self.__operations_by_stage[OperationStage.QUEUED].discard(job_name)
self.__operations_by_stage[OperationStage.EXECUTING].discard(job_name)
self.__operations_by_stage[OperationStage.COMPLETED].discard(job_name)
self.__leases_by_state[LeaseState.PENDING].discard(job_name)
self.__leases_by_state[LeaseState.ACTIVE].discard(job_name)
self.__leases_by_state[LeaseState.COMPLETED].discard(job_name)
def _update_job_operation_stage(self, job_name, operation_stage):
"""Requests a stage transition for the job's :class:Operations.
......