diff --git a/app/controllers/api/v1/jobs_controller.rb b/app/controllers/api/v1/jobs_controller.rb index d8c660ba8..b4a0527b1 100644 --- a/app/controllers/api/v1/jobs_controller.rb +++ b/app/controllers/api/v1/jobs_controller.rb @@ -15,10 +15,11 @@ class Api::V1::JobsController < Api::V1::BaseController oldest.order(:created_at) build_lists = build_lists.for_platform(platform_ids) if platform_ids.present? if current_user.system? - # TODO: rollback later - # @build_list = build_lists.not_owned_external_nodes.first - @build_list = build_lists.external_nodes(:everything).first - + @build_list = build_lists.not_owned_external_nodes.first + # TODO: Hook for resque, remove later + if @build_list && @build_list.external_nodes.blank? && @build_list.destroy_from_resque_queue != 1 + @build_list = nil + end @build_list.touch if @build_list else @build_list = build_lists.external_nodes(:owned).for_user(current_user).first diff --git a/lib/abf_worker/model_helper.rb b/lib/abf_worker/model_helper.rb index ff9aefd9f..d39e525f1 100644 --- a/lib/abf_worker/model_helper.rb +++ b/lib/abf_worker/model_helper.rb @@ -29,12 +29,7 @@ module AbfWorker::ModelHelper end def cancel_job - deleted = Resque::Job.destroy( - worker_queue_with_priority, - worker_queue_class, - abf_worker_args - ) - if deleted == 1 + if destroy_from_resque_queue == 1 build_canceled else send_stop_signal @@ -42,6 +37,14 @@ module AbfWorker::ModelHelper true end + def destroy_from_resque_queue + Resque::Job.destroy( + worker_queue_with_priority, + worker_queue_class, + abf_worker_args + ) + end + def worker_queue_with_priority(queue = nil) queue ||= abf_worker_base_queue queue << '_' << abf_worker_priority if abf_worker_priority.present?