Loading app/controllers/projects/settings/ci_cd_controller.rb +1 −1 Original line number Diff line number Diff line Loading @@ -74,7 +74,7 @@ def define_runners_variables .ordered .page(params[:page]).per(20) @shared_runners = ::Ci::Runner.shared.active @shared_runners = ::Ci::Runner.instance_type.active @shared_runners_count = @shared_runners.count(:all) Loading app/helpers/ci_status_helper.rb +1 −1 Original line number Diff line number Diff line Loading @@ -122,7 +122,7 @@ def render_pipeline_status(pipeline, tooltip_placement: 'left') def no_runners_for_project?(project) project.runners.blank? && Ci::Runner.shared.blank? Ci::Runner.instance_type.blank? end def render_status_with_link(type, status, path = nil, tooltip_placement: 'left', cssclass: '', container: 'body') Loading app/models/ci/runner.rb +12 −22 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ module Ci class Runner < ActiveRecord::Base extend Gitlab::Ci::Model include Gitlab::SQL::Pattern include IgnorableColumn include RedisCacheable include ChronicDurationAttribute Loading @@ -11,6 +12,8 @@ class Runner < ActiveRecord::Base AVAILABLE_SCOPES = %w[specific shared active paused online].freeze FORM_EDITABLE = %i[description tag_list active run_untagged locked access_level maximum_timeout_human_readable].freeze ignore_column :is_shared has_many :builds has_many :runner_projects, inverse_of: :runner, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent has_many :projects, through: :runner_projects Loading @@ -21,13 +24,16 @@ class Runner < ActiveRecord::Base before_validation :set_default_values scope :specific, -> { where(is_shared: false) } scope :shared, -> { where(is_shared: true) } scope :active, -> { where(active: true) } scope :paused, -> { where(active: false) } scope :online, -> { where('contacted_at > ?', contact_time_deadline) } scope :ordered, -> { order(id: :desc) } # BACKWARD COMPATIBILITY: There are needed to maintain compatibility with `AVAILABLE_SCOPES` used by `lib/api/runners.rb` scope :shared, -> { instance_type } # this should get replaced with `project_type.or(group_type)` once using Rails5 scope :specific, -> { where(runner_type: [runner_types[:project_type], runner_types[:group_type]]) } scope :belonging_to_project, -> (project_id) { joins(:runner_projects).where(ci_runner_projects: { project_id: project_id }) } Loading @@ -39,9 +45,9 @@ class Runner < ActiveRecord::Base joins(:groups).where(namespaces: { id: hierarchy_groups }) } scope :owned_or_shared, -> (project_id) do scope :owned_or_instance_wide, -> (project_id) do union = Gitlab::SQL::Union.new( [belonging_to_project(project_id), belonging_to_parent_group_of_project(project_id), shared], [belonging_to_project(project_id), belonging_to_parent_group_of_project(project_id), instance_type], remove_duplicates: false ) from("(#{union.to_sql}) ci_runners") Loading @@ -63,7 +69,6 @@ class Runner < ActiveRecord::Base validate :no_groups, unless: :group_type? validate :any_project, if: :project_type? validate :exactly_one_group, if: :group_type? validate :validate_is_shared acts_as_taggable Loading Loading @@ -113,8 +118,7 @@ def set_default_values end def assign_to(project, current_user = nil) if shared? self.is_shared = false if shared? if instance_type? self.runner_type = :project_type elsif group_type? raise ArgumentError, 'Transitioning a group runner to a project runner is not supported' Loading @@ -137,10 +141,6 @@ def display_name description end def shared? is_shared end def online? contacted_at && contacted_at > self.class.contact_time_deadline end Loading @@ -159,10 +159,6 @@ def belongs_to_one_project? runner_projects.count == 1 end def specific? !shared? end def assigned_to_group? runner_namespaces.any? end Loading Loading @@ -260,7 +256,7 @@ def tag_constraints end def assignable_for?(project_id) self.class.owned_or_shared(project_id).where(id: self.id).any? self.class.owned_or_instance_wide(project_id).where(id: self.id).any? end def no_projects Loading @@ -287,12 +283,6 @@ def exactly_one_group end end def validate_is_shared unless is_shared? == instance_type? errors.add(:is_shared, 'is not equal to instance_type?') end end def accepting_tags?(build) (run_untagged? || build.has_tags?) && (build.tag_list - tag_list).empty? end Loading app/models/project.rb +1 −1 Original line number Diff line number Diff line Loading @@ -1422,7 +1422,7 @@ def shared_runners_available? end def shared_runners @shared_runners ||= shared_runners_available? ? Ci::Runner.shared : Ci::Runner.none @shared_runners ||= shared_runners_available? ? Ci::Runner.instance_type : Ci::Runner.none end def group_runners Loading app/models/user.rb +1 −1 Original line number Diff line number Diff line Loading @@ -1032,7 +1032,7 @@ def ci_owned_runners union = Gitlab::SQL::Union.new([project_runner_ids, group_runner_ids]) Ci::Runner.specific.where("ci_runners.id IN (#{union.to_sql})") # rubocop:disable GitlabSecurity/SqlInjection Ci::Runner.where("ci_runners.id IN (#{union.to_sql})") # rubocop:disable GitlabSecurity/SqlInjection end end Loading Loading
app/controllers/projects/settings/ci_cd_controller.rb +1 −1 Original line number Diff line number Diff line Loading @@ -74,7 +74,7 @@ def define_runners_variables .ordered .page(params[:page]).per(20) @shared_runners = ::Ci::Runner.shared.active @shared_runners = ::Ci::Runner.instance_type.active @shared_runners_count = @shared_runners.count(:all) Loading
app/helpers/ci_status_helper.rb +1 −1 Original line number Diff line number Diff line Loading @@ -122,7 +122,7 @@ def render_pipeline_status(pipeline, tooltip_placement: 'left') def no_runners_for_project?(project) project.runners.blank? && Ci::Runner.shared.blank? Ci::Runner.instance_type.blank? end def render_status_with_link(type, status, path = nil, tooltip_placement: 'left', cssclass: '', container: 'body') Loading
app/models/ci/runner.rb +12 −22 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ module Ci class Runner < ActiveRecord::Base extend Gitlab::Ci::Model include Gitlab::SQL::Pattern include IgnorableColumn include RedisCacheable include ChronicDurationAttribute Loading @@ -11,6 +12,8 @@ class Runner < ActiveRecord::Base AVAILABLE_SCOPES = %w[specific shared active paused online].freeze FORM_EDITABLE = %i[description tag_list active run_untagged locked access_level maximum_timeout_human_readable].freeze ignore_column :is_shared has_many :builds has_many :runner_projects, inverse_of: :runner, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent has_many :projects, through: :runner_projects Loading @@ -21,13 +24,16 @@ class Runner < ActiveRecord::Base before_validation :set_default_values scope :specific, -> { where(is_shared: false) } scope :shared, -> { where(is_shared: true) } scope :active, -> { where(active: true) } scope :paused, -> { where(active: false) } scope :online, -> { where('contacted_at > ?', contact_time_deadline) } scope :ordered, -> { order(id: :desc) } # BACKWARD COMPATIBILITY: There are needed to maintain compatibility with `AVAILABLE_SCOPES` used by `lib/api/runners.rb` scope :shared, -> { instance_type } # this should get replaced with `project_type.or(group_type)` once using Rails5 scope :specific, -> { where(runner_type: [runner_types[:project_type], runner_types[:group_type]]) } scope :belonging_to_project, -> (project_id) { joins(:runner_projects).where(ci_runner_projects: { project_id: project_id }) } Loading @@ -39,9 +45,9 @@ class Runner < ActiveRecord::Base joins(:groups).where(namespaces: { id: hierarchy_groups }) } scope :owned_or_shared, -> (project_id) do scope :owned_or_instance_wide, -> (project_id) do union = Gitlab::SQL::Union.new( [belonging_to_project(project_id), belonging_to_parent_group_of_project(project_id), shared], [belonging_to_project(project_id), belonging_to_parent_group_of_project(project_id), instance_type], remove_duplicates: false ) from("(#{union.to_sql}) ci_runners") Loading @@ -63,7 +69,6 @@ class Runner < ActiveRecord::Base validate :no_groups, unless: :group_type? validate :any_project, if: :project_type? validate :exactly_one_group, if: :group_type? validate :validate_is_shared acts_as_taggable Loading Loading @@ -113,8 +118,7 @@ def set_default_values end def assign_to(project, current_user = nil) if shared? self.is_shared = false if shared? if instance_type? self.runner_type = :project_type elsif group_type? raise ArgumentError, 'Transitioning a group runner to a project runner is not supported' Loading @@ -137,10 +141,6 @@ def display_name description end def shared? is_shared end def online? contacted_at && contacted_at > self.class.contact_time_deadline end Loading @@ -159,10 +159,6 @@ def belongs_to_one_project? runner_projects.count == 1 end def specific? !shared? end def assigned_to_group? runner_namespaces.any? end Loading Loading @@ -260,7 +256,7 @@ def tag_constraints end def assignable_for?(project_id) self.class.owned_or_shared(project_id).where(id: self.id).any? self.class.owned_or_instance_wide(project_id).where(id: self.id).any? end def no_projects Loading @@ -287,12 +283,6 @@ def exactly_one_group end end def validate_is_shared unless is_shared? == instance_type? errors.add(:is_shared, 'is not equal to instance_type?') end end def accepting_tags?(build) (run_untagged? || build.has_tags?) && (build.tag_list - tag_list).empty? end Loading
app/models/project.rb +1 −1 Original line number Diff line number Diff line Loading @@ -1422,7 +1422,7 @@ def shared_runners_available? end def shared_runners @shared_runners ||= shared_runners_available? ? Ci::Runner.shared : Ci::Runner.none @shared_runners ||= shared_runners_available? ? Ci::Runner.instance_type : Ci::Runner.none end def group_runners Loading
app/models/user.rb +1 −1 Original line number Diff line number Diff line Loading @@ -1032,7 +1032,7 @@ def ci_owned_runners union = Gitlab::SQL::Union.new([project_runner_ids, group_runner_ids]) Ci::Runner.specific.where("ci_runners.id IN (#{union.to_sql})") # rubocop:disable GitlabSecurity/SqlInjection Ci::Runner.where("ci_runners.id IN (#{union.to_sql})") # rubocop:disable GitlabSecurity/SqlInjection end end Loading