Skip to content

Commit 3f7f749

Browse files
committed
fix: requeue only the latest missing jobs
Signed-off-by: Keshav Priyadarshi <git@keshav.space>
1 parent 1d91ce5 commit 3f7f749

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

‎vulnerabilities/schedules.py‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,12 @@ def requeue_missing_jobs():
145145
missing_jobs_count = 0
146146
for job in PipelineRun.objects.filter(run_start_date__isnull=True).iterator(chunk_size=1000):
147147
if not is_job_in_queue(job_id=job.run_id):
148-
enqueue_run(run=job)
149-
missing_jobs_count += 1
148+
pipeline_latest_run = job.pipeline.latest_run
149+
if pipeline_latest_run and pipeline_latest_run.run_id == job.run_id:
150+
enqueue_run(run=job)
151+
missing_jobs_count += 1
152+
else:
153+
job.set_run_staled()
150154

151155
log.info(f"Requeued {missing_jobs_count} missing jobs.")
152156

0 commit comments

Comments
 (0)