From 1a44b634f9e644ac97a5fc34765e040572cb390e Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Wed, 20 Mar 2013 01:11:16 +0400 Subject: [PATCH 1/6] Update BuildListsPublishTaskManager and PublishObserver --- lib/abf_worker/base_observer.rb | 2 +- lib/abf_worker/build_lists_publish_task_manager.rb | 3 ++- lib/abf_worker/publish_observer.rb | 5 +++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/abf_worker/base_observer.rb b/lib/abf_worker/base_observer.rb index 45151da79..d7d1ec01a 100644 --- a/lib/abf_worker/base_observer.rb +++ b/lib/abf_worker/base_observer.rb @@ -32,7 +32,7 @@ module AbfWorker def sort_results_and_save(results, item = subject) item.results = results.sort_by{ |r| r['file_name'] } - item.save! + item.save(false) end end diff --git a/lib/abf_worker/build_lists_publish_task_manager.rb b/lib/abf_worker/build_lists_publish_task_manager.rb index dc731f2dc..4ec75ea8a 100644 --- a/lib/abf_worker/build_lists_publish_task_manager.rb +++ b/lib/abf_worker/build_lists_publish_task_manager.rb @@ -237,8 +237,9 @@ module AbfWorker build_lists = build_lists.where('build_lists.id NOT IN (?)', locked_ids) unless locked_ids.empty? build_lists = build_lists.limit(50) + project_ids = build_lists.map(&:project_id).uniq projects_for_cleanup = @redis.lrange(PROJECTS_FOR_CLEANUP, 0, -1). - select{ |k| k =~ /#{save_to_repository_id}\-#{build_for_platform_id}$/ } + select{ |k| k =~ /#{save_to_repository_id}\-#{build_for_platform_id}$/ && k !~ /^(#{project_ids.join('|')})\-/ } old_packages = {:sources => [], :binaries => {:x86_64 => [], :i586 => []}} diff --git a/lib/abf_worker/publish_observer.rb b/lib/abf_worker/publish_observer.rb index a3958510f..c4acc9204 100644 --- a/lib/abf_worker/publish_observer.rb +++ b/lib/abf_worker/publish_observer.rb @@ -36,9 +36,10 @@ module AbfWorker update_results build_list case status when COMPLETED - build_list.published + # `update_column` - when build_list has been removed from repository + build_list.published || build_list.update_column(:status, BuildList::BUILD_PUBLISHED) when FAILED, CANCELED - build_list.fail_publish + build_list.fail_publish || build_list.update_column(:status, BuildList::FAILED_PUBLISH) end AbfWorker::BuildListsPublishTaskManager.unlock_build_list build_list end From 3d2d945e417bc2b59ccd70c8a6d1795604a4e2e3 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Wed, 20 Mar 2013 01:23:31 +0400 Subject: [PATCH 2/6] update comment --- lib/abf_worker/publish_observer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/abf_worker/publish_observer.rb b/lib/abf_worker/publish_observer.rb index c4acc9204..56dee3ac3 100644 --- a/lib/abf_worker/publish_observer.rb +++ b/lib/abf_worker/publish_observer.rb @@ -36,7 +36,7 @@ module AbfWorker update_results build_list case status when COMPLETED - # `update_column` - when build_list has been removed from repository + # 'update_column' - when build_list has been removed from repository build_list.published || build_list.update_column(:status, BuildList::BUILD_PUBLISHED) when FAILED, CANCELED build_list.fail_publish || build_list.update_column(:status, BuildList::FAILED_PUBLISH) From 915204a66fd66e0eef5bdde64c0916c2f3f45199 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Thu, 21 Mar 2013 21:37:13 +0400 Subject: [PATCH 3/6] small refactoring according to Alexander's comment --- lib/abf_worker/build_lists_publish_task_manager.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/abf_worker/build_lists_publish_task_manager.rb b/lib/abf_worker/build_lists_publish_task_manager.rb index 4ec75ea8a..73854c766 100644 --- a/lib/abf_worker/build_lists_publish_task_manager.rb +++ b/lib/abf_worker/build_lists_publish_task_manager.rb @@ -237,7 +237,7 @@ module AbfWorker build_lists = build_lists.where('build_lists.id NOT IN (?)', locked_ids) unless locked_ids.empty? build_lists = build_lists.limit(50) - project_ids = build_lists.map(&:project_id).uniq + project_ids = build_lists.pluck(:project_id).uniq projects_for_cleanup = @redis.lrange(PROJECTS_FOR_CLEANUP, 0, -1). select{ |k| k =~ /#{save_to_repository_id}\-#{build_for_platform_id}$/ && k !~ /^(#{project_ids.join('|')})\-/ } From 2da7db221797a8c264e0d06344a32e24e11d1177 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Fri, 22 Mar 2013 01:43:00 +0400 Subject: [PATCH 4/6] add comments to code --- lib/abf_worker/build_lists_publish_task_manager.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/abf_worker/build_lists_publish_task_manager.rb b/lib/abf_worker/build_lists_publish_task_manager.rb index 73854c766..3cae6d46f 100644 --- a/lib/abf_worker/build_lists_publish_task_manager.rb +++ b/lib/abf_worker/build_lists_publish_task_manager.rb @@ -238,6 +238,9 @@ module AbfWorker build_lists = build_lists.limit(50) project_ids = build_lists.pluck(:project_id).uniq + # Projects which should be removed: + # - /#{save_to_repository_id}\-#{build_for_platform_id}$/ - from repository; + # - /^(#{project_ids.join('|')})\-/ - not published in current transaction. projects_for_cleanup = @redis.lrange(PROJECTS_FOR_CLEANUP, 0, -1). select{ |k| k =~ /#{save_to_repository_id}\-#{build_for_platform_id}$/ && k !~ /^(#{project_ids.join('|')})\-/ } From 67cf79fac2a7ff77ee2e0b4a28849e83e713bdae Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Fri, 22 Mar 2013 15:43:22 +0400 Subject: [PATCH 5/6] #46: not publish new builds into repository if project of builds has been removed from repository --- .../build_lists_publish_task_manager.rb | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/abf_worker/build_lists_publish_task_manager.rb b/lib/abf_worker/build_lists_publish_task_manager.rb index 3cae6d46f..bba427d49 100644 --- a/lib/abf_worker/build_lists_publish_task_manager.rb +++ b/lib/abf_worker/build_lists_publish_task_manager.rb @@ -228,6 +228,17 @@ module AbfWorker end def create_rpm_build_task(save_to_repository_id, build_for_platform_id) + projects_for_cleanup = @redis.lrange(PROJECTS_FOR_CLEANUP, 0, -1). + select{ |k| k =~ /#{save_to_repository_id}\-#{build_for_platform_id}$/ } + + # We should not to publish new builds into repository + # if project of builds has been removed from repository. + BuildList.where( + :project_id => projects_for_cleanup.map{ |k| k.split('-')[0] }.uniq, + :save_to_repository_id => repository.id, + :status => BuildList::BUILD_PUBLISH + ).update_all(:status => BuildList::FAILED_PUBLISH) + build_lists = BuildList. where(:new_core => true, :status => BuildList::BUILD_PUBLISH). where(:save_to_repository_id => save_to_repository_id). @@ -237,13 +248,6 @@ module AbfWorker build_lists = build_lists.where('build_lists.id NOT IN (?)', locked_ids) unless locked_ids.empty? build_lists = build_lists.limit(50) - project_ids = build_lists.pluck(:project_id).uniq - # Projects which should be removed: - # - /#{save_to_repository_id}\-#{build_for_platform_id}$/ - from repository; - # - /^(#{project_ids.join('|')})\-/ - not published in current transaction. - projects_for_cleanup = @redis.lrange(PROJECTS_FOR_CLEANUP, 0, -1). - select{ |k| k =~ /#{save_to_repository_id}\-#{build_for_platform_id}$/ && k !~ /^(#{project_ids.join('|')})\-/ } - old_packages = {:sources => [], :binaries => {:x86_64 => [], :i586 => []}} projects_for_cleanup.each do |key| From 8fec7cb13315b8ef1375c39f487036ca626fa01f Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Fri, 22 Mar 2013 15:46:22 +0400 Subject: [PATCH 6/6] #46: update comment to code --- lib/abf_worker/publish_observer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/abf_worker/publish_observer.rb b/lib/abf_worker/publish_observer.rb index 56dee3ac3..a6166535a 100644 --- a/lib/abf_worker/publish_observer.rb +++ b/lib/abf_worker/publish_observer.rb @@ -36,7 +36,7 @@ module AbfWorker update_results build_list case status when COMPLETED - # 'update_column' - when build_list has been removed from repository + # 'update_column' - when project of build_list has been removed from repository build_list.published || build_list.update_column(:status, BuildList::BUILD_PUBLISHED) when FAILED, CANCELED build_list.fail_publish || build_list.update_column(:status, BuildList::FAILED_PUBLISH)