From 7b3d7d27a9142dd1c423d4298995e349f5a349c5 Mon Sep 17 00:00:00 2001 From: Wedge Date: Sun, 10 Feb 2019 17:15:46 +0300 Subject: [PATCH] Fix observer workers so that they don't raise error if item is already deleted --- app/jobs/abf_worker/base_observer.rb | 2 +- app/jobs/abf_worker/iso_worker_observer.rb | 1 + app/jobs/abf_worker/publish_observer.rb | 1 + app/jobs/abf_worker/rpm_worker_observer.rb | 3 ++- 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/jobs/abf_worker/base_observer.rb b/app/jobs/abf_worker/base_observer.rb index 984a57686..c5c4385bf 100644 --- a/app/jobs/abf_worker/base_observer.rb +++ b/app/jobs/abf_worker/base_observer.rb @@ -24,7 +24,7 @@ module AbfWorker protected def subject - @subject ||= @subject_class.find(options['id']) + @subject ||= @subject_class.find(options['id']) rescue nil end def update_results diff --git a/app/jobs/abf_worker/iso_worker_observer.rb b/app/jobs/abf_worker/iso_worker_observer.rb index 3e6fc866f..fbc52976f 100644 --- a/app/jobs/abf_worker/iso_worker_observer.rb +++ b/app/jobs/abf_worker/iso_worker_observer.rb @@ -4,6 +4,7 @@ module AbfWorker def real_perform @subject_class = ProductBuildList + return if !subject subject.with_lock do case status when COMPLETED diff --git a/app/jobs/abf_worker/publish_observer.rb b/app/jobs/abf_worker/publish_observer.rb index faa41ba83..c5841dcc8 100644 --- a/app/jobs/abf_worker/publish_observer.rb +++ b/app/jobs/abf_worker/publish_observer.rb @@ -4,6 +4,7 @@ module AbfWorker def real_perform @subject_class = BuildList + return if !subject return if status == STARTED # do nothing when publication started extra = options['extra'] repository_status = RepositoryStatus.where(id: extra['repository_status_id']).first diff --git a/app/jobs/abf_worker/rpm_worker_observer.rb b/app/jobs/abf_worker/rpm_worker_observer.rb index 98b0aacbf..1ca36b83b 100644 --- a/app/jobs/abf_worker/rpm_worker_observer.rb +++ b/app/jobs/abf_worker/rpm_worker_observer.rb @@ -11,10 +11,11 @@ module AbfWorker def real_perform @subject_class = BuildList + return if !subject unless subject.valid? && restart_task if options['feedback_from_user'] user = User.find options['feedback_from_user'] - raise ActiveRecord::Rollback if !user.system? && subject.builder != user + return if !user.system? && subject.builder != user end fill_container_data if status != STARTED