Merge pull request #850 from warpc/848-add-status-information-for-product-build-lists
[refs #848]: add status information about servers for ProductBuildLists
This commit is contained in:
commit
bf445d9e5e
|
@ -80,6 +80,7 @@ class Platforms::ProductBuildListsController < Platforms::BaseController
|
||||||
@product_build_lists = @product_build_lists.for_status(params[:status]) if params[:status].present?
|
@product_build_lists = @product_build_lists.for_status(params[:status]) if params[:status].present?
|
||||||
end
|
end
|
||||||
@product_build_lists = @product_build_lists.recent.paginate :page => params[:page]
|
@product_build_lists = @product_build_lists.recent.paginate :page => params[:page]
|
||||||
|
@build_server_status = AbfWorker::StatusInspector.products_status
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
|
@ -28,7 +28,7 @@ class Projects::BuildListsController < Projects::BaseController
|
||||||
@build_lists = BuildList.where(:id => @bls.pluck("#{BuildList.table_name}.id")).recent
|
@build_lists = BuildList.where(:id => @bls.pluck("#{BuildList.table_name}.id")).recent
|
||||||
@build_lists = @build_lists.includes [:save_to_platform, :save_to_repository, :arch, :user, :project => [:owner]]
|
@build_lists = @build_lists.includes [:save_to_platform, :save_to_repository, :arch, :user, :project => [:owner]]
|
||||||
|
|
||||||
@build_server_status = AbfWorker::StatusInspector.get_status
|
@build_server_status = AbfWorker::StatusInspector.projects_status
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
- content_for :sidebar do
|
- content_for :sidebar do
|
||||||
|
= render 'projects/build_lists/server_status', :queues => [:iso]
|
||||||
|
|
||||||
= form_tag product_build_lists_path, :method => :get, :html => {:class => :form} do
|
= form_tag product_build_lists_path, :method => :get, :html => {:class => :form} do
|
||||||
.block
|
.block
|
||||||
%h3.small= t("activerecord.attributes.product_build_list.status")
|
%h3.small= t("activerecord.attributes.product_build_list.status")
|
||||||
|
|
|
@ -1,18 +1,5 @@
|
||||||
- content_for :sidebar do
|
- content_for :sidebar do
|
||||||
.bordered.nopadding
|
= render 'server_status'
|
||||||
%h3= t('layout.build_lists.build_server_status.header')
|
|
||||||
|
|
||||||
- [:rpm, :publish].each do |queue|
|
|
||||||
.table
|
|
||||||
.lefter= t("layout.build_lists.build_server_status.#{queue}_workers")
|
|
||||||
.both
|
|
||||||
- [:count, :tasks, :build_tasks].each do |metric|
|
|
||||||
.table
|
|
||||||
.lefter= t("layout.build_lists.build_server_status.#{metric}")
|
|
||||||
.righter= @build_server_status[queue][metric]
|
|
||||||
.both
|
|
||||||
%br
|
|
||||||
= link_to t('layout.build_lists.new_header'), new_project_build_list_path(@project), :class => 'button' if @project and can?(:create, @project.build_lists.build)
|
|
||||||
|
|
||||||
= form_for :filter, :url => @action_url, :html => { :method => :post, :class => :form } do |f|
|
= form_for :filter, :url => @action_url, :html => { :method => :post, :class => :form } do |f|
|
||||||
- if current_user
|
- if current_user
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
- queues ||= [:rpm, :publish]
|
||||||
|
.bordered.nopadding
|
||||||
|
%h3= t('layout.build_lists.build_server_status.header')
|
||||||
|
|
||||||
|
- queues.each do |queue|
|
||||||
|
.table
|
||||||
|
.lefter= t("layout.build_lists.build_server_status.#{queue}_workers")
|
||||||
|
.both
|
||||||
|
- [:count, :tasks, :build_tasks].each do |metric|
|
||||||
|
.table
|
||||||
|
.lefter= t("layout.build_lists.build_server_status.#{metric}")
|
||||||
|
.righter= @build_server_status[queue][metric]
|
||||||
|
.both
|
||||||
|
%br
|
||||||
|
= link_to t('layout.build_lists.new_header'), new_project_build_list_path(@project), :class => 'button' if @project and can?(:create, @project.build_lists.build)
|
|
@ -94,6 +94,7 @@ en:
|
||||||
tasks: '- tasks in queue'
|
tasks: '- tasks in queue'
|
||||||
build_tasks: '- tasks in execution'
|
build_tasks: '- tasks in execution'
|
||||||
rpm_workers: Workers for building
|
rpm_workers: Workers for building
|
||||||
|
iso_workers: Workers for building
|
||||||
publish_workers: Workers for publishing
|
publish_workers: Workers for publishing
|
||||||
|
|
||||||
items:
|
items:
|
||||||
|
|
|
@ -91,6 +91,7 @@ ru:
|
||||||
tasks: '- заданий в очереди'
|
tasks: '- заданий в очереди'
|
||||||
build_tasks: '- заданий выполняется'
|
build_tasks: '- заданий выполняется'
|
||||||
rpm_workers: Воркеров для сборки
|
rpm_workers: Воркеров для сборки
|
||||||
|
iso_workers: Воркеров для сборки
|
||||||
publish_workers: Воркеров для публикации
|
publish_workers: Воркеров для публикации
|
||||||
|
|
||||||
items:
|
items:
|
||||||
|
|
|
@ -1,20 +1,40 @@
|
||||||
module AbfWorker
|
module AbfWorker
|
||||||
class StatusInspector
|
class StatusInspector
|
||||||
|
|
||||||
def self.get_status
|
class << self
|
||||||
redis, all_workers = Resque.redis, Resque.workers
|
def projects_status
|
||||||
status = {}
|
get_status(:rpm, :publish) { |w, worker|
|
||||||
[:rpm, :publish].each do |worker|
|
w.to_s =~ /#{worker}_worker_default/
|
||||||
workers = all_workers.select{ |w| w.to_s =~ /#{worker}_worker_default/ }
|
}
|
||||||
key = "queue:#{worker}_worker"
|
end
|
||||||
status[worker] = {
|
|
||||||
|
def products_status
|
||||||
|
get_status(:iso) { |w, worker|
|
||||||
|
str = w.to_s
|
||||||
|
str =~ /iso_worker/ && str !~ /observer/
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
protected
|
||||||
|
|
||||||
|
def get_status(*queues)
|
||||||
|
status = {}
|
||||||
|
queues.each do |worker|
|
||||||
|
workers = Resque.workers.select{ |w| yield w, worker }
|
||||||
|
status[worker] = status_of_worker workers, worker
|
||||||
|
end
|
||||||
|
status
|
||||||
|
end
|
||||||
|
|
||||||
|
def status_of_worker(workers, worker)
|
||||||
|
redis, key = Resque.redis, "queue:#{worker}_worker"
|
||||||
|
{
|
||||||
:count => workers.count,
|
:count => workers.count,
|
||||||
:build_tasks => workers.select{ |w| w.working? }.count,
|
:build_tasks => workers.select{ |w| w.working? }.count,
|
||||||
:tasks => (redis.llen("#{key}_default") + redis.llen(key))
|
:tasks => (redis.llen("#{key}_default") + redis.llen(key))
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
status
|
|
||||||
end
|
|
||||||
|
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -94,6 +94,7 @@ describe Projects::BuildListsController do
|
||||||
:build_for_platforms => [@platform.id]
|
:build_for_platforms => [@platform.id]
|
||||||
}
|
}
|
||||||
any_instance_of(Project, :versions => ['v1.0', 'v2.0'])
|
any_instance_of(Project, :versions => ['v1.0', 'v2.0'])
|
||||||
|
stub_redis
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'for guest' do
|
context 'for guest' do
|
||||||
|
|
Loading…
Reference in New Issue