Move clearing stale builders to worker
This commit is contained in:
parent
d9f2a9f7fb
commit
5437a0b095
|
@ -8,7 +8,6 @@ class Api::V1::JobsController < Api::V1::BaseController
|
|||
skip_after_action :verify_authorized
|
||||
|
||||
def shift
|
||||
clear_stale_builders
|
||||
job_shift_sem = Redis::Semaphore.new(:job_shift_lock)
|
||||
job_shift_sem.lock
|
||||
uid = BuildList.scoped_to_arch(arch_ids).
|
||||
|
@ -100,14 +99,6 @@ class Api::V1::JobsController < Api::V1::BaseController
|
|||
|
||||
protected
|
||||
|
||||
def clear_stale_builders
|
||||
BuildList.transaction do
|
||||
BuildList.where(["updated_at < ?", 900.seconds.ago]).where(status: BuildList::BUILD_PENDING).where.not(builder: nil).find_each(batch_size: 50) do |bl|
|
||||
bl.update_column(:builder_id, nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def platform_ids
|
||||
@platform_ids ||= begin
|
||||
platforms = params[:platforms].to_s.split(',')
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
module BuildLists
|
||||
class ClearStaleBuilders < BaseActiveRecordJob
|
||||
include Sidekiq::Worker
|
||||
sidekiq_options :queue => :low
|
||||
|
||||
def perform_with_ar_connection
|
||||
BuildList.where(["updated_at < ?", 900.seconds.ago]).where(status: BuildList::BUILD_PENDING).where.not(builder: nil).update_all(builder_id: nil)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -69,3 +69,10 @@ build_canceling_destroy:
|
|||
class: 'BuildLists::BuildCancelingDestroyJob'
|
||||
queue: low
|
||||
description: 'Remove build canceling build lists'
|
||||
|
||||
clear_stale_builders:
|
||||
every:
|
||||
- '5m'
|
||||
class: 'BuildLists::ClearStaleBuilders'
|
||||
queue: low
|
||||
description: 'Clear stale builders'
|
||||
|
|
Loading…
Reference in New Issue