Commit 4d6a836c authored by GitLab Bot's avatar GitLab Bot

Automatic merge of gitlab-org/gitlab master

parents 3cb9a5d9 16bd2926
...@@ -16,13 +16,14 @@ class Projects::TagsController < Projects::ApplicationController ...@@ -16,13 +16,14 @@ class Projects::TagsController < Projects::ApplicationController
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def index def index
begin begin
params[:sort] = params[:sort].presence || sort_value_recently_updated tags_params[:sort] = tags_params[:sort].presence || sort_value_recently_updated
@sort = params[:sort] @sort = tags_params[:sort]
@search = tags_params[:search]
@tags = TagsFinder.new(@repository, params).execute @tags = TagsFinder.new(@repository, tags_params).execute
@tags = Kaminari.paginate_array(@tags).page(params[:page]) @tags = Kaminari.paginate_array(@tags).page(tags_params[:page])
tag_names = @tags.map(&:name) tag_names = @tags.map(&:name)
@tags_pipelines = @project.ci_pipelines.latest_successful_for_refs(tag_names) @tags_pipelines = @project.ci_pipelines.latest_successful_for_refs(tag_names)
...@@ -100,6 +101,10 @@ class Projects::TagsController < Projects::ApplicationController ...@@ -100,6 +101,10 @@ class Projects::TagsController < Projects::ApplicationController
private private
def tags_params
params.permit(:search, :sort, :per_page, :page_token, :page)
end
# TODO: remove this with the release creation moved to it's own form https://gitlab.com/gitlab-org/gitlab/-/issues/214245 # TODO: remove this with the release creation moved to it's own form https://gitlab.com/gitlab-org/gitlab/-/issues/214245
def find_evidence_pipeline def find_evidence_pipeline
evidence_pipeline_sha = @project.repository.commit(params[:ref])&.sha evidence_pipeline_sha = @project.repository.commit(params[:ref])&.sha
......
...@@ -11,11 +11,11 @@ class GitRefsFinder ...@@ -11,11 +11,11 @@ class GitRefsFinder
attr_reader :repository, :params attr_reader :repository, :params
def search def search
@params[:search].presence @params[:search].to_s.presence
end end
def sort def sort
@params[:sort].presence || 'name' @params[:sort].to_s.presence || 'name'
end end
def by_search(refs) def by_search(refs)
......
...@@ -6,12 +6,6 @@ module TagsHelper ...@@ -6,12 +6,6 @@ module TagsHelper
end end
def filter_tags_path(options = {}) def filter_tags_path(options = {})
exist_opts = {
search: params[:search],
sort: params[:sort]
}
options = exist_opts.merge(options)
project_tags_path(@project, @id, options) project_tags_path(@project, @id, options)
end end
......
- @sort ||= sort_value_recently_updated
- page_title s_('TagsPage|Tags') - page_title s_('TagsPage|Tags')
= content_for :meta_tags do = content_for :meta_tags do
= auto_discovery_link_tag(:atom, project_tags_url(@project, rss_url_options), title: "#{@project.name} tags") = auto_discovery_link_tag(:atom, project_tags_url(@project, rss_url_options), title: "#{@project.name} tags")
...@@ -9,7 +8,7 @@ ...@@ -9,7 +8,7 @@
= s_('TagsPage|Tags give the ability to mark specific points in history as being important') = s_('TagsPage|Tags give the ability to mark specific points in history as being important')
.nav-controls .nav-controls
#js-tags-sort-dropdown{ data: { filter_tags_path: filter_tags_path, sort_options: tags_sort_options_hash.to_json } } #js-tags-sort-dropdown{ data: { filter_tags_path: filter_tags_path(search: @search, sort: @sort), sort_options: tags_sort_options_hash.to_json } }
= link_to project_tags_path(@project, rss_url_options), title: _("Tags feed"), class: 'btn gl-button btn-default btn-icon has-tooltip gl-ml-auto' do = link_to project_tags_path(@project, rss_url_options), title: _("Tags feed"), class: 'btn gl-button btn-default btn-icon has-tooltip gl-ml-auto' do
= sprite_icon('rss', css_class: 'gl-icon qa-rss-icon') = sprite_icon('rss', css_class: 'gl-icon qa-rss-icon')
- if can?(current_user, :admin_tag, @project) - if can?(current_user, :admin_tag, @project)
......
...@@ -1956,6 +1956,15 @@ ...@@ -1956,6 +1956,15 @@
:weight: 1 :weight: 1
:idempotent: :idempotent:
:tags: [] :tags: []
- :name: background_migration_ci_database
:worker_name: BackgroundMigration::CiDatabaseWorker
:feature_category: :database
:has_external_dependencies:
:urgency: :throttled
:resource_boundary: :unknown
:weight: 1
:idempotent:
:tags: []
- :name: bulk_import - :name: bulk_import
:worker_name: BulkImportWorker :worker_name: BulkImportWorker
:feature_category: :importers :feature_category: :importers
......
# frozen_string_literal: true
module BackgroundMigration
class CiDatabaseWorker # rubocop:disable Scalability/IdempotentWorker
include SingleDatabaseWorker
def self.tracking_database
@tracking_database ||= Gitlab::Database::CI_DATABASE_NAME
end
end
end
...@@ -32,10 +32,6 @@ module BackgroundMigration ...@@ -32,10 +32,6 @@ module BackgroundMigration
def tracking_database def tracking_database
raise NotImplementedError, "#{self.name} does not implement #{__method__}" raise NotImplementedError, "#{self.name} does not implement #{__method__}"
end end
def unhealthy_metric_name
raise NotImplementedError, "#{self.name} does not implement #{__method__}"
end
end end
# Performs the background migration. # Performs the background migration.
...@@ -55,8 +51,12 @@ module BackgroundMigration ...@@ -55,8 +51,12 @@ module BackgroundMigration
private private
def tracking_database
self.class.tracking_database
end
def job_coordinator def job_coordinator
@job_coordinator ||= Gitlab::BackgroundMigration.coordinator_for_database(self.class.tracking_database) @job_coordinator ||= Gitlab::BackgroundMigration.coordinator_for_database(tracking_database)
end end
def perform_with_connection(class_name, arguments, lease_attempts) def perform_with_connection(class_name, arguments, lease_attempts)
...@@ -91,7 +91,7 @@ module BackgroundMigration ...@@ -91,7 +91,7 @@ module BackgroundMigration
healthy_db = healthy_database? healthy_db = healthy_database?
perform = lease_obtained && healthy_db perform = lease_obtained && healthy_db
database_unhealthy_counter.increment if lease_obtained && !healthy_db database_unhealthy_counter.increment(db_config_name: tracking_database) if lease_obtained && !healthy_db
# When the DB is unhealthy or the lease can't be obtained after several tries, # When the DB is unhealthy or the lease can't be obtained after several tries,
# then give up on the job and log a warning. Otherwise we could end up in # then give up on the job and log a warning. Otherwise we could end up in
...@@ -140,7 +140,7 @@ module BackgroundMigration ...@@ -140,7 +140,7 @@ module BackgroundMigration
def database_unhealthy_counter def database_unhealthy_counter
Gitlab::Metrics.counter( Gitlab::Metrics.counter(
self.class.unhealthy_metric_name, :background_migration_database_health_reschedules,
'The number of times a background migration is rescheduled because the database is unhealthy.' 'The number of times a background migration is rescheduled because the database is unhealthy.'
) )
end end
......
...@@ -6,8 +6,4 @@ class BackgroundMigrationWorker # rubocop:disable Scalability/IdempotentWorker ...@@ -6,8 +6,4 @@ class BackgroundMigrationWorker # rubocop:disable Scalability/IdempotentWorker
def self.tracking_database def self.tracking_database
@tracking_database ||= Gitlab::BackgroundMigration::DEFAULT_TRACKING_DATABASE @tracking_database ||= Gitlab::BackgroundMigration::DEFAULT_TRACKING_DATABASE
end end
def self.unhealthy_metric_name
@unhealthy_metric_name ||= :background_migration_database_health_reschedules
end
end end
# frozen_string_literal: true # frozen_string_literal: true
module Gitlab
class Experiment
class Configuration
def self.deprecated(*args, version:, stack: 0)
# do nothing here
end
end
end
end
Gitlab::Experiment.configure do |config| Gitlab::Experiment.configure do |config|
# The base experiment class that will be instantiated when using the # The base experiment class that will be instantiated when using the
# `experiment` DSL, is our ApplicationExperiment. If a custom experiment # `experiment` DSL, is our ApplicationExperiment. If a custom experiment
......
...@@ -55,6 +55,8 @@ ...@@ -55,6 +55,8 @@
- 3 - 3
- - background_migration - - background_migration
- 1 - 1
- - background_migration_ci_database
- 1
- - bulk_import - - bulk_import
- 1 - 1
- - bulk_imports_entity - - bulk_imports_entity
......
../../../../../../../../../lib/gitlab/ci/parsers/security/validators/schemas/14.0.0
\ No newline at end of file
../../../../../../../../../lib/gitlab/ci/parsers/security/validators/schemas/14.0.1
\ No newline at end of file
../../../../../../../../../lib/gitlab/ci/parsers/security/validators/schemas/14.0.2
\ No newline at end of file
../../../../../../../../../lib/gitlab/ci/parsers/security/validators/schemas/14.0.3
\ No newline at end of file
../../../../../../../../../lib/gitlab/ci/parsers/security/validators/schemas/14.0.4
\ No newline at end of file
../../../../../../../../../lib/gitlab/ci/parsers/security/validators/schemas/14.0.5
\ No newline at end of file
../../../../../../../../../lib/gitlab/ci/parsers/security/validators/schemas/14.0.6
\ No newline at end of file
../../../../../../../../../lib/gitlab/ci/parsers/security/validators/schemas/14.1.0
\ No newline at end of file
...@@ -10,28 +10,32 @@ module Gitlab ...@@ -10,28 +10,32 @@ module Gitlab
# Also provides a database connection to the correct tracking database. # Also provides a database connection to the correct tracking database.
class JobCoordinator # rubocop:disable Metrics/ClassLength class JobCoordinator # rubocop:disable Metrics/ClassLength
class << self class << self
def for_tracking_database(tracking_database)
worker_class = worker_for_tracking_database[tracking_database]
if worker_class.nil?
raise ArgumentError, "tracking_database must be one of [#{worker_for_tracking_database.keys.join(', ')}]"
end
new(worker_class)
end
private
def worker_classes def worker_classes
@worker_classes ||= [ @worker_classes ||= [
BackgroundMigrationWorker ::BackgroundMigrationWorker,
::BackgroundMigration::CiDatabaseWorker
].freeze ].freeze
end end
def worker_for_tracking_database def worker_for_tracking_database
@worker_for_tracking_database ||= worker_classes @worker_for_tracking_database ||= worker_classes
.select { |worker_class| Gitlab::Database.has_config?(worker_class.tracking_database) }
.index_by(&:tracking_database) .index_by(&:tracking_database)
.with_indifferent_access .with_indifferent_access
.freeze .freeze
end end
def for_tracking_database(tracking_database)
worker_class = worker_for_tracking_database[tracking_database]
if worker_class.nil?
raise ArgumentError, "tracking_database must be one of [#{worker_for_tracking_database.keys.join(', ')}]"
end
new(worker_class)
end
end end
attr_reader :worker_class attr_reader :worker_class
...@@ -146,7 +150,7 @@ module Gitlab ...@@ -146,7 +150,7 @@ module Gitlab
def connection def connection
@connection ||= Gitlab::Database @connection ||= Gitlab::Database
.database_base_models .database_base_models
.fetch(worker_class.tracking_database, Gitlab::Database::PRIMARY_DATABASE_NAME) .fetch(worker_class.tracking_database)
.connection .connection
end end
end end
......
../../../../../../../ee/lib/ee/gitlab/ci/parsers/security/validators/schemas/14.0.0
\ No newline at end of file
../../../../../../../ee/lib/ee/gitlab/ci/parsers/security/validators/schemas/14.0.1
\ No newline at end of file
../../../../../../../ee/lib/ee/gitlab/ci/parsers/security/validators/schemas/14.0.2
\ No newline at end of file
../../../../../../../ee/lib/ee/gitlab/ci/parsers/security/validators/schemas/14.0.3
\ No newline at end of file
../../../../../../../ee/lib/ee/gitlab/ci/parsers/security/validators/schemas/14.0.4
\ No newline at end of file
../../../../../../../ee/lib/ee/gitlab/ci/parsers/security/validators/schemas/14.0.5
\ No newline at end of file
../../../../../../../ee/lib/ee/gitlab/ci/parsers/security/validators/schemas/14.0.6
\ No newline at end of file
../../../../../../../ee/lib/ee/gitlab/ci/parsers/security/validators/schemas/14.1.0
\ No newline at end of file
...@@ -29,7 +29,7 @@ module Gitlab ...@@ -29,7 +29,7 @@ module Gitlab
# The worker classes aren't constants here, because that would force # The worker classes aren't constants here, because that would force
# Application Settings to be loaded earlier causing failures loading # Application Settings to be loaded earlier causing failures loading
# the environment in rake tasks # the environment in rake tasks
EXEMPT_WORKER_NAMES = ["BackgroundMigrationWorker", "Database::BatchedBackgroundMigrationWorker"].to_set EXEMPT_WORKER_NAMES = %w[BackgroundMigrationWorker BackgroundMigration::CiDatabaseWorker Database::BatchedBackgroundMigrationWorker].to_set
JOB_STATUS_KEY = 'size_limiter' JOB_STATUS_KEY = 'size_limiter'
class << self class << self
......
...@@ -32,6 +32,14 @@ RSpec.describe TagsFinder do ...@@ -32,6 +32,14 @@ RSpec.describe TagsFinder do
expect(load_tags(params).first.name).to eq('v1.0.0') expect(load_tags(params).first.name).to eq('v1.0.0')
end end
context 'when sort is not a string' do
it 'ignores sort parameter' do
params = { sort: { 'invalid' => 'string' } }
expect(load_tags(params).first.name).to eq('v1.0.0')
end
end
end end
context 'filter only' do context 'filter only' do
...@@ -70,6 +78,13 @@ RSpec.describe TagsFinder do ...@@ -70,6 +78,13 @@ RSpec.describe TagsFinder do
result = load_tags({ search: 'nope$' }) result = load_tags({ search: 'nope$' })
expect(result.count).to eq(0) expect(result.count).to eq(0)
end end
context 'when search is not a string' do
it 'returns no matches' do
result = load_tags({ search: { 'a' => 'b' } })
expect(result.count).to eq(0)
end
end
end end
context 'filter and sort' do context 'filter and sort' do
......
...@@ -299,7 +299,7 @@ RSpec.describe Gitlab::Database::Migrations::BackgroundMigrationHelpers do ...@@ -299,7 +299,7 @@ RSpec.describe Gitlab::Database::Migrations::BackgroundMigrationHelpers do
before do before do
allow(Gitlab::BackgroundMigration).to receive(:coordinator_for_database) allow(Gitlab::BackgroundMigration).to receive(:coordinator_for_database)
.with('main').and_return(coordinator) .with(tracking_database).and_return(coordinator)
expect(coordinator).to receive(:migration_class_for) expect(coordinator).to receive(:migration_class_for)
.with(job_class_name).at_least(:once) { job_class } .with(job_class_name).at_least(:once) { job_class }
...@@ -403,7 +403,7 @@ RSpec.describe Gitlab::Database::Migrations::BackgroundMigrationHelpers do ...@@ -403,7 +403,7 @@ RSpec.describe Gitlab::Database::Migrations::BackgroundMigrationHelpers do
end end
context 'when a specific coordinator is given' do context 'when a specific coordinator is given' do
let(:coordinator) { Gitlab::BackgroundMigration::JobCoordinator.for_tracking_database('main') } let(:coordinator) { Gitlab::BackgroundMigration::JobCoordinator.for_tracking_database(tracking_database) }
it 'uses that coordinator' do it 'uses that coordinator' do
expect(coordinator).to receive(:perform_in).with(10.minutes, 'Class', 'Hello', 'World').and_call_original expect(coordinator).to receive(:perform_in).with(10.minutes, 'Class', 'Hello', 'World').and_call_original
...@@ -438,6 +438,10 @@ RSpec.describe Gitlab::Database::Migrations::BackgroundMigrationHelpers do ...@@ -438,6 +438,10 @@ RSpec.describe Gitlab::Database::Migrations::BackgroundMigrationHelpers do
it_behaves_like 'helpers that enqueue background migrations', BackgroundMigrationWorker, 'main' it_behaves_like 'helpers that enqueue background migrations', BackgroundMigrationWorker, 'main'
end end
context 'when the migration is running against the ci database', if: Gitlab::Database.has_config?(:ci) do
it_behaves_like 'helpers that enqueue background migrations', BackgroundMigration::CiDatabaseWorker, 'ci'
end
describe '#delete_job_tracking' do describe '#delete_job_tracking' do
let!(:job_class_name) { 'TestJob' } let!(:job_class_name) { 'TestJob' }
......
# frozen_string_literal: true # frozen_string_literal: true
RSpec.shared_examples 'it runs background migration jobs' do |tracking_database, metric_name| RSpec.shared_examples 'it runs background migration jobs' do |tracking_database|
describe 'defining the job attributes' do describe 'defining the job attributes' do
it 'defines the data_consistency as always' do it 'defines the data_consistency as always' do
expect(described_class.get_data_consistency).to eq(:always) expect(described_class.get_data_consistency).to eq(:always)
...@@ -33,16 +33,6 @@ RSpec.shared_examples 'it runs background migration jobs' do |tracking_database, ...@@ -33,16 +33,6 @@ RSpec.shared_examples 'it runs background migration jobs' do |tracking_database,
end end
end end
describe '.unhealthy_metric_name' do
it 'does not raise an error' do
expect { described_class.unhealthy_metric_name }.not_to raise_error
end
it 'overrides the method to return the unhealthy metric name' do
expect(described_class.unhealthy_metric_name).to eq(metric_name)
end
end
describe '.minimum_interval' do describe '.minimum_interval' do
it 'returns 2 minutes' do it 'returns 2 minutes' do
expect(described_class.minimum_interval).to eq(2.minutes.to_i) expect(described_class.minimum_interval).to eq(2.minutes.to_i)
...@@ -189,11 +179,11 @@ RSpec.shared_examples 'it runs background migration jobs' do |tracking_database, ...@@ -189,11 +179,11 @@ RSpec.shared_examples 'it runs background migration jobs' do |tracking_database,
end end
it 'increments the unhealthy counter' do it 'increments the unhealthy counter' do
counter = Gitlab::Metrics.counter(metric_name, 'msg') counter = Gitlab::Metrics.counter(:background_migration_database_health_reschedules, 'msg')
expect(described_class).to receive(:perform_in) expect(described_class).to receive(:perform_in)
expect { worker.perform('Foo', [10, 20]) }.to change { counter.get }.by(1) expect { worker.perform('Foo', [10, 20]) }.to change { counter.get(db_config_name: tracking_database) }.by(1)
end end
context 'when lease_attempts is 0' do context 'when lease_attempts is 0' do
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe BackgroundMigration::CiDatabaseWorker, :clean_gitlab_redis_shared_state, if: Gitlab::Database.has_config?(:ci) do
it_behaves_like 'it runs background migration jobs', 'ci'
end
...@@ -3,5 +3,5 @@ ...@@ -3,5 +3,5 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe BackgroundMigrationWorker, :clean_gitlab_redis_shared_state do RSpec.describe BackgroundMigrationWorker, :clean_gitlab_redis_shared_state do
it_behaves_like 'it runs background migration jobs', 'main', :background_migration_database_health_reschedules it_behaves_like 'it runs background migration jobs', 'main'
end end
...@@ -135,6 +135,7 @@ RSpec.describe 'Every Sidekiq worker' do ...@@ -135,6 +135,7 @@ RSpec.describe 'Every Sidekiq worker' do
'AutoDevops::DisableWorker' => 3, 'AutoDevops::DisableWorker' => 3,
'AutoMergeProcessWorker' => 3, 'AutoMergeProcessWorker' => 3,
'BackgroundMigrationWorker' => 3, 'BackgroundMigrationWorker' => 3,
'BackgroundMigration::CiDatabaseWorker' => 3,
'BuildFinishedWorker' => 3, 'BuildFinishedWorker' => 3,
'BuildHooksWorker' => 3, 'BuildHooksWorker' => 3,
'BuildQueueWorker' => 3, 'BuildQueueWorker' => 3,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment