Commit 8e432f68 authored by James Fargher's avatar James Fargher

Merge branch 'queue-selector-not-experimental' into 'master'

Mark Sidekiq queue selector as no longer experimental

See merge request gitlab-org/gitlab!46562
parents 9ae8443a 38c9612e
---
title: Mark Sidekiq queue selector as no longer experimental
merge_request: 46562
author:
type: changed
......@@ -110,29 +110,21 @@ you list:
sudo gitlab-ctl reconfigure
```
## Queue selector (experimental)
## Queue selector
> - [Introduced](https://gitlab.com/gitlab-com/gl-infra/scalability/-/issues/45) in [GitLab Starter](https://about.gitlab.com/pricing/) 12.8.
> - [Sidekiq cluster including queue selector moved](https://gitlab.com/groups/gitlab-com/gl-infra/-/epics/181) to GitLab [Core](https://about.gitlab.com/pricing/#self-managed) in GitLab 12.10.
> - [Marked as supported](https://gitlab.com/gitlab-com/gl-infra/scalability/-/issues/147) in GitLab [Core](https://about.gitlab.com/pricing/#self-managed) in GitLab 13.6. Renamed from `experimental_queue_selector` to `queue_selector`.
CAUTION: **Caution:**
As this is marked as **experimental**, it is subject to change at any
time, including **breaking backwards compatibility**. This is so that we
can react to changes we need for our GitLab.com deployment. We have a
tracking issue open to [remove the experimental
designation](https://gitlab.com/gitlab-com/gl-infra/scalability/-/issues/147)
from this feature; please comment there if you are interested in using
this in your own deployment.
In addition to selecting queues by name, as above, the
`experimental_queue_selector` option allows queue groups to be selected
in a more general way using the following components:
In addition to selecting queues by name, as above, the `queue_selector`
option allows queue groups to be selected in a more general way using
the following components:
- Attributes that can be selected.
- Operators used to construct a query.
When `experimental_queue_selector` is set, all `queue_groups` must be in
the queue selector syntax.
When `queue_selector` is set, all `queue_groups` must be in the queue
selector syntax.
### Available attributes
......@@ -140,8 +132,7 @@ the queue selector syntax.
From the [list of all available
attributes](https://gitlab.com/gitlab-org/gitlab/-/blob/master/app/workers/all_queues.yml),
`experimental_queue_selector` allows selecting of queues by the
following attributes:
`queue_selector` allows selecting of queues by the following attributes:
- `feature_category` - the [GitLab feature
category](https://about.gitlab.com/direction/maturity/#category-maturity) the
......@@ -173,8 +164,8 @@ neither of those tags.
### Available operators
`experimental_queue_selector` supports the following operators, listed
from highest to lowest precedence:
`queue_selector` supports the following operators, listed from highest
to lowest precedence:
- `|` - the logical OR operator. For example, `query_a|query_b` (where `query_a`
and `query_b` are queries made up of the other operators here) will include
......@@ -205,7 +196,7 @@ In `/etc/gitlab/gitlab.rb`:
```ruby
sidekiq['enable'] = true
sidekiq['experimental_queue_selector'] = true
sidekiq['queue_selector'] = true
sidekiq['queue_groups'] = [
# Run all non-CPU-bound queues that are high urgency
'resource_boundary!=cpu&urgency=high',
......@@ -234,7 +225,7 @@ All of the aforementioned configuration options for `sidekiq`
are available. By default, they will be configured as follows:
```ruby
sidekiq['experimental_queue_selector'] = false
sidekiq['queue_selector'] = false
sidekiq['interval'] = nil
sidekiq['max_concurrency'] = 50
sidekiq['min_concurrency'] = nil
......
......@@ -47,16 +47,24 @@ module Gitlab
option_parser.parse!(argv)
# Remove with https://gitlab.com/gitlab-com/gl-infra/scalability/-/issues/646
if @queue_selector && @experimental_queue_selector
raise CommandError,
'You cannot specify --queue-selector and --experimental-queue-selector together'
end
all_queues = SidekiqConfig::CliMethods.all_queues(@rails_path)
queue_names = SidekiqConfig::CliMethods.worker_queues(@rails_path)
queue_groups = argv.map do |queues|
next queue_names if queues == '*'
# When using the experimental queue query syntax, we treat
# each queue group as a worker attribute query, and resolve
# the queues for the queue group using this query.
if @experimental_queue_selector
# When using the queue query syntax, we treat each queue group
# as a worker attribute query, and resolve the queues for the
# queue group using this query.
# Simplify with https://gitlab.com/gitlab-com/gl-infra/scalability/-/issues/646
if @queue_selector || @experimental_queue_selector
SidekiqConfig::CliMethods.query_workers(queues, all_queues)
else
SidekiqConfig::CliMethods.expand_queues(queues.split(','), queue_names)
......@@ -182,7 +190,12 @@ module Gitlab
@rails_path = path
end
opt.on('--experimental-queue-selector', 'EXPERIMENTAL: Run workers based on the provided selector') do |experimental_queue_selector|
opt.on('--queue-selector', 'Run workers based on the provided selector') do |queue_selector|
@queue_selector = queue_selector
end
# Remove with https://gitlab.com/gitlab-com/gl-infra/scalability/-/issues/646
opt.on('--experimental-queue-selector', 'DEPRECATED: use --queue-selector-instead') do |experimental_queue_selector|
@experimental_queue_selector = experimental_queue_selector
end
......
......@@ -9,6 +9,8 @@ RSpec.describe 'bin/sidekiq-cluster' do
context 'when selecting some queues and excluding others' do
where(:args, :included, :excluded) do
%w[--negate cronjob] | '-qdefault,1' | '-qcronjob,1'
%w[--queue-selector resource_boundary=cpu] | '-qupdate_merge_requests,1' | '-qdefault,1'
# Remove with https://gitlab.com/gitlab-com/gl-infra/scalability/-/issues/646
%w[--experimental-queue-selector resource_boundary=cpu] | '-qupdate_merge_requests,1' | '-qdefault,1'
end
......@@ -29,6 +31,8 @@ RSpec.describe 'bin/sidekiq-cluster' do
context 'when selecting all queues' do
[
%w[*],
%w[--queue-selector *],
# Remove with https://gitlab.com/gitlab-com/gl-infra/scalability/-/issues/646
%w[--experimental-queue-selector *]
].each do |args|
it "runs successfully with `#{args}`", :aggregate_failures do
......
......@@ -108,7 +108,19 @@ RSpec.describe Gitlab::SidekiqCluster::CLI do
end
end
context 'with --experimental-queue-selector' do
# Remove with https://gitlab.com/gitlab-com/gl-infra/scalability/-/issues/646
context 'with --queue-selector and --experimental-queue-selector' do
it 'errors' do
expect(Gitlab::SidekiqCluster).not_to receive(:start)
expect { cli.run(%w(--queue-selector name=foo --experimental-queue-selector name=bar)) }
.to raise_error(described_class::CommandError)
end
end
# Simplify with https://gitlab.com/gitlab-com/gl-infra/scalability/-/issues/646
['--queue-selector', '--experimental-queue-selector'].each do |flag|
context "with #{flag}" do
where do
{
'memory-bound queues' => {
......@@ -154,7 +166,7 @@ RSpec.describe Gitlab::SidekiqCluster::CLI do
[]
end
cli.run(%W(--experimental-queue-selector #{query}))
cli.run(%W(#{flag} #{query}))
end
it 'works when negated' do
......@@ -166,7 +178,7 @@ RSpec.describe Gitlab::SidekiqCluster::CLI do
[]
end
cli.run(%W(--negate --experimental-queue-selector #{query}))
cli.run(%W(--negate #{flag} #{query}))
end
end
......@@ -176,7 +188,7 @@ RSpec.describe Gitlab::SidekiqCluster::CLI do
.with([['chat_notification'], ['project_export']], default_options)
.and_return([])
cli.run(%w(--experimental-queue-selector feature_category=chatops&has_external_dependencies=true resource_boundary=memory&feature_category=importers))
cli.run(%W(#{flag} feature_category=chatops&has_external_dependencies=true resource_boundary=memory&feature_category=importers))
end
it 'allows the special * selector' do
......@@ -188,25 +200,26 @@ RSpec.describe Gitlab::SidekiqCluster::CLI do
expect(Gitlab::SidekiqCluster)
.to receive(:start).with([worker_queues], default_options)
cli.run(%w(--experimental-queue-selector *))
cli.run(%W(#{flag} *))
end
it 'errors when the selector matches no queues' do
expect(Gitlab::SidekiqCluster).not_to receive(:start)
expect { cli.run(%w(--experimental-queue-selector has_external_dependencies=true&has_external_dependencies=false)) }
expect { cli.run(%W(#{flag} has_external_dependencies=true&has_external_dependencies=false)) }
.to raise_error(described_class::CommandError)
end
it 'errors on an invalid query multiple queue groups correctly' do
expect(Gitlab::SidekiqCluster).not_to receive(:start)
expect { cli.run(%w(--experimental-queue-selector unknown_field=chatops)) }
expect { cli.run(%W(#{flag} unknown_field=chatops)) }
.to raise_error(Gitlab::SidekiqConfig::CliMethods::QueryError)
end
end
end
end
end
describe '#write_pid' do
context 'when a PID is specified' do
......
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