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
# rubocop: disable CodeReuse/ActiveRecord
def index
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)
@tags_pipelines = @project.ci_pipelines.latest_successful_for_refs(tag_names)
......@@ -100,6 +101,10 @@ class Projects::TagsController < Projects::ApplicationController
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
def find_evidence_pipeline
evidence_pipeline_sha = @project.repository.commit(params[:ref])&.sha
......
......@@ -11,11 +11,11 @@ class GitRefsFinder
attr_reader :repository, :params
def search
@params[:search].presence
@params[:search].to_s.presence
end
def sort
@params[:sort].presence || 'name'
@params[:sort].to_s.presence || 'name'
end
def by_search(refs)
......
......@@ -6,12 +6,6 @@ module TagsHelper
end
def filter_tags_path(options = {})
exist_opts = {
search: params[:search],
sort: params[:sort]
}
options = exist_opts.merge(options)
project_tags_path(@project, @id, options)
end
......
- @sort ||= sort_value_recently_updated
- page_title s_('TagsPage|Tags')
= content_for :meta_tags do
= auto_discovery_link_tag(:atom, project_tags_url(@project, rss_url_options), title: "#{@project.name} tags")
......@@ -9,7 +8,7 @@
= s_('TagsPage|Tags give the ability to mark specific points in history as being important')
.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
= sprite_icon('rss', css_class: 'gl-icon qa-rss-icon')
- if can?(current_user, :admin_tag, @project)
......
......@@ -1956,6 +1956,15 @@
:weight: 1
:idempotent:
: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
:worker_name: BulkImportWorker
: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
def tracking_database
raise NotImplementedError, "#{self.name} does not implement #{__method__}"
end
def unhealthy_metric_name
raise NotImplementedError, "#{self.name} does not implement #{__method__}"
end
end
# Performs the background migration.
......@@ -55,8 +51,12 @@ module BackgroundMigration
private
def tracking_database
self.class.tracking_database
end
def job_coordinator
@job_coordinator ||= Gitlab::BackgroundMigration.coordinator_for_database(self.class.tracking_database)
@job_coordinator ||= Gitlab::BackgroundMigration.coordinator_for_database(tracking_database)
end
def perform_with_connection(class_name, arguments, lease_attempts)
......@@ -91,7 +91,7 @@ module BackgroundMigration
healthy_db = healthy_database?
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,
# then give up on the job and log a warning. Otherwise we could end up in
......@@ -140,7 +140,7 @@ module BackgroundMigration
def database_unhealthy_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.'
)
end
......
......@@ -6,8 +6,4 @@ class BackgroundMigrationWorker # rubocop:disable Scalability/IdempotentWorker
def self.tracking_database
@tracking_database ||= Gitlab::BackgroundMigration::DEFAULT_TRACKING_DATABASE
end
def self.unhealthy_metric_name
@unhealthy_metric_name ||= :background_migration_database_health_reschedules
end
end
# 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|
# The base experiment class that will be instantiated when using the
# `experiment` DSL, is our ApplicationExperiment. If a custom experiment
......
......@@ -55,6 +55,8 @@
- 3
- - background_migration
- 1
- - background_migration_ci_database
- 1
- - bulk_import
- 1
- - 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
# Also provides a database connection to the correct tracking database.
class JobCoordinator # rubocop:disable Metrics/ClassLength
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
@worker_classes ||= [
BackgroundMigrationWorker
::BackgroundMigrationWorker,
::BackgroundMigration::CiDatabaseWorker
].freeze
end
def worker_for_tracking_database
@worker_for_tracking_database ||= worker_classes
.select { |worker_class| Gitlab::Database.has_config?(worker_class.tracking_database) }
.index_by(&:tracking_database)
.with_indifferent_access
.freeze
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
attr_reader :worker_class
......@@ -146,7 +150,7 @@ module Gitlab
def connection
@connection ||= Gitlab::Database
.database_base_models
.fetch(worker_class.tracking_database, Gitlab::Database::PRIMARY_DATABASE_NAME)
.fetch(worker_class.tracking_database)
.connection
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
# The worker classes aren't constants here, because that would force
# Application Settings to be loaded earlier causing failures loading
# 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'
class << self
......
......@@ -32,6 +32,14 @@ RSpec.describe TagsFinder do
expect(load_tags(params).first.name).to eq('v1.0.0')
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
context 'filter only' do
......@@ -70,6 +78,13 @@ RSpec.describe TagsFinder do
result = load_tags({ search: 'nope$' })
expect(result.count).to eq(0)
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
context 'filter and sort' do
......
......@@ -299,7 +299,7 @@ RSpec.describe Gitlab::Database::Migrations::BackgroundMigrationHelpers do
before do
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)
.with(job_class_name).at_least(:once) { job_class }
......@@ -403,7 +403,7 @@ RSpec.describe Gitlab::Database::Migrations::BackgroundMigrationHelpers do
end
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
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
it_behaves_like 'helpers that enqueue background migrations', BackgroundMigrationWorker, 'main'
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
let!(:job_class_name) { 'TestJob' }
......
# 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
it 'defines the data_consistency as always' do
expect(described_class.get_data_consistency).to eq(:always)
......@@ -33,16 +33,6 @@ RSpec.shared_examples 'it runs background migration jobs' do |tracking_database,
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
it 'returns 2 minutes' do
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,
end
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 { 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
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 @@
require 'spec_helper'
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
......@@ -135,6 +135,7 @@ RSpec.describe 'Every Sidekiq worker' do
'AutoDevops::DisableWorker' => 3,
'AutoMergeProcessWorker' => 3,
'BackgroundMigrationWorker' => 3,
'BackgroundMigration::CiDatabaseWorker' => 3,
'BuildFinishedWorker' => 3,
'BuildHooksWorker' => 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