#276: updated logic of BuildListsPublishTaskManager
This commit is contained in:
parent
75d5bc501f
commit
b8736a03ed
|
@ -33,7 +33,7 @@ class Repository < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def resign
|
||||
unless platform.personal?
|
||||
if platform.main?
|
||||
status = repository_statuses.find_or_create_by_platform_id(platform_id)
|
||||
status.resign
|
||||
end
|
||||
|
|
|
@ -33,8 +33,8 @@ class RepositoryStatus < ActiveRecord::Base
|
|||
attr_accessible :platform_id, :repository_id
|
||||
|
||||
scope :platform_ready, where(:platforms => {:status => READY}).joins(:platform)
|
||||
scope :for_regeneration, platform_ready.where(:status => WAITING_FOR_REGENERATION)
|
||||
scope :for_resign, platform_ready.where(:status => [WAITING_FOR_RESIGN, WAITING_FOR_RESIGN_AND_REGENERATION])
|
||||
scope :for_regeneration, where(:status => WAITING_FOR_REGENERATION)
|
||||
scope :for_resign, where(:status => [WAITING_FOR_RESIGN, WAITING_FOR_RESIGN_AND_REGENERATION])
|
||||
scope :not_ready, where('repository_statuses.status != ?', READY)
|
||||
|
||||
state_machine :status, :initial => :ready do
|
||||
|
|
|
@ -146,7 +146,8 @@ module AbfWorker
|
|||
private
|
||||
|
||||
def create_tasks_for_resign_repositories
|
||||
repository_statuses = RepositoryStatus.for_resign.includes(:repository => :platform)
|
||||
repository_statuses = RepositoryStatus.platform_ready.
|
||||
for_resign.includes(:repository => :platform)
|
||||
repository_statuses.each do |repository_status|
|
||||
r = repository_status.repository
|
||||
# Checks mirror sync status
|
||||
|
@ -175,7 +176,7 @@ module AbfWorker
|
|||
:type => :resign,
|
||||
:skip_feedback => true,
|
||||
:time_living => 9600, # 160 min
|
||||
:extra => {:repository_status_ids => [repository_status.id]}
|
||||
:extra => {:repository_status_id => repository_status.id}
|
||||
}]
|
||||
) if repository_status.start_resign
|
||||
end
|
||||
|
@ -246,7 +247,7 @@ module AbfWorker
|
|||
|
||||
save_to_repository = Repository.find save_to_repository_id
|
||||
# Checks mirror sync status
|
||||
return false if save_to_repository.repo_lock_file_exists?
|
||||
return false if save_to_repository.repo_lock_file_exists? || !save_to_repository.platform.ready?
|
||||
|
||||
repository_status = save_to_repository.find_or_create_by_platform_id(build_for_platform_id)
|
||||
return false unless repository_status.publish
|
||||
|
@ -282,7 +283,7 @@ module AbfWorker
|
|||
:repository => {:id => save_to_repository_id},
|
||||
:type => :publish,
|
||||
:time_living => 9600, # 160 min
|
||||
:extra => {:repository_status_ids => [repository_status.id]}
|
||||
:extra => {:repository_status_id => repository_status.id}
|
||||
}
|
||||
|
||||
packages, build_list_ids, new_sources = self.class.packages_structure, [], {}
|
||||
|
@ -319,23 +320,20 @@ module AbfWorker
|
|||
def create_tasks_for_regenerate_metadata_for_software_center
|
||||
Platfor.main.waiting_for_regeneration.each do |platform|
|
||||
repos = platform.repositories
|
||||
repos.repositories.each(&:regenerate)
|
||||
statuses = RepositoryStatus.where(:platform_id => platform.id, :repository_id => repos.map(&:id))
|
||||
statuses = RepositoryStatus.where(:platform_id => platform.id)
|
||||
next if repos.find{ |r| r.repo_lock_file_exists? }
|
||||
next if statuses.find{ |s| !s.can_start_regeneration? }
|
||||
next if statuses.present? &&
|
||||
statuses.map{ |s| s.ready? || s.can_start_regeneration? || s.can_start_resign? }.uniq == [true]
|
||||
|
||||
build_for_platform = repository_statuses.platform
|
||||
cmd_params = {
|
||||
'RELEASED' => platform.released,
|
||||
'REPOSITORY_NAME' => rep.name,
|
||||
'REPOSITORY_NAME' => platform.repositories.map(&:name).join(','),
|
||||
'TYPE' => platform.distrib_type,
|
||||
'REGENERATE_PLATFORM_METADATA' => true,
|
||||
'SAVE_TO_PLATFORM' => platform.name,
|
||||
'BUILD_FOR_PLATFORM' => platform.name
|
||||
}.map{ |k, v| "#{k}=#{v}" }.join(' ')
|
||||
|
||||
statuses.each(&:start_regeneration)
|
||||
platform.start_regeneration
|
||||
Resque.push(
|
||||
'publish_worker_default',
|
||||
'class' => 'AbfWorker::PublishWorkerDefault',
|
||||
|
@ -343,24 +341,25 @@ module AbfWorker
|
|||
:id => Time.now.to_i,
|
||||
:cmd_params => cmd_params,
|
||||
:platform => {
|
||||
:platform_path => "#{rep.platform.path}/repository",
|
||||
:platform_path => "#{platform.path}/repository",
|
||||
:type => platform.distrib_type,
|
||||
:name => platform.name,
|
||||
:arch => 'x86_64'
|
||||
},
|
||||
:repository => {:id => rep.id},
|
||||
:repository => {:id => platform.repositories.first.id},
|
||||
:type => :publish,
|
||||
:time_living => 9600, # 160 min
|
||||
:skip_feedback => true,
|
||||
:extra => {:repository_status_ids => statuses.map(&:id), :regenerate_platform => true}
|
||||
:extra => {:platform_id => platform.id, :regenerate_platform => true}
|
||||
}]
|
||||
)
|
||||
) if platform.start_regeneration
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
def create_tasks_for_repository_regenerate_metadata
|
||||
repository_statuses = RepositoryStatus.for_regeneration.includes(:repository => :platform)
|
||||
repository_statuses = RepositoryStatus.platform_ready.
|
||||
for_regeneration.includes(:repository => :platform)
|
||||
repository_statuses.each do |repository_status|
|
||||
rep = repository_status.repository
|
||||
# Checks mirror sync status
|
||||
|
@ -392,7 +391,7 @@ module AbfWorker
|
|||
:type => :publish,
|
||||
:time_living => 9600, # 160 min
|
||||
:skip_feedback => true,
|
||||
:extra => {:repository_status_ids => [repository_status.id], :regenerate => true}
|
||||
:extra => {:repository_status_id => repository_status.id, :regenerate => true}
|
||||
}]
|
||||
) if repository_status.start_regeneration
|
||||
end
|
||||
|
|
|
@ -9,17 +9,13 @@ module AbfWorker
|
|||
|
||||
def perform
|
||||
return if status == STARTED # do nothing when publication started
|
||||
repository_statuses = RepositoryStatus.where(:id => options['extra']['repository_status_ids'])
|
||||
repository_status = RepositoryStatus.where(:id => options['extra']['repository_status_id'])
|
||||
begin
|
||||
if options['extra']['regenerate'] # Regenerate metadata
|
||||
last_regenerated_at = Time.now.utc
|
||||
repository_statuses.each do |repository_status|
|
||||
repository_status.last_regenerated_at = last_regenerated_at
|
||||
repository_status.last_regenerated_at = Time.now.utc
|
||||
repository_status.last_regenerated_status = status
|
||||
end
|
||||
elsif options['extra']['regenerate_platform'] # Regenerate metadata for Software Center
|
||||
platform = repository_statuses.first.try(:platform)
|
||||
if platform
|
||||
if platform = Platform.where(:id => options['extra']['platform_id'])).first
|
||||
platform.last_regenerated_at = Time.now.utc
|
||||
platform.last_regenerated_status = status
|
||||
platform.ready
|
||||
|
@ -36,7 +32,7 @@ module AbfWorker
|
|||
update_rpm_builds
|
||||
end
|
||||
ensure
|
||||
repository_statuses.map(&:ready) if repository_statuses.present?
|
||||
repository_status.ready if repository_status.present?
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue