-
Notifications
You must be signed in to change notification settings - Fork 1
/
elasticsearch_indexed_namespaces.rb
45 lines (37 loc) · 2.12 KB
/
elasticsearch_indexed_namespaces.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# frozen_string_literal: true
module API
class ElasticsearchIndexedNamespaces < Grape::API::Instance
before { authenticated_as_admin! }
resource :elasticsearch_indexed_namespaces do
desc 'Rollout namespaces to be indexed up to n%' do
detail <<~END
This feature was introduced in GitLab 12.7.
This will only ever increase the number of indexed namespaces. Providing a value lower than the current rolled out percentage will have no effect.
This percentage is never persisted but is used to calculate the number of new namespaces to rollout.
If the same percentage is applied again at a later time, due to possible new namespaces being created during the period, some of them will also be indexed. Therefore you may expect that setting this to 10%, then waiting a month and setting to 10% again will trigger new namespaces to be added (i.e. 10% of the number of newly created namespaces in the last month within the given plan).
END
end
params do
requires :percentage, type: Integer, values: 0..100
requires :plan, type: String, values: Plan::ALL_HOSTED_PLANS
end
put 'rollout' do
ElasticNamespaceRolloutWorker.perform_async(params[:plan], params[:percentage], ElasticNamespaceRolloutWorker::ROLLOUT) # rubocop:disable CodeReuse/Worker
end
desc 'Rollback namespaces to be indexed down to n%' do
detail <<~END
This feature was introduced in GitLab 12.7.
This will only ever decrease the number of indexed namespaces. Providing a value higher than the current rolled out percentage will have no effect.
This percentage is never persisted but is used to calculate the number of namespaces to rollback.
END
end
params do
requires :percentage, type: Integer, values: 0..100
requires :plan, type: String, values: Plan::ALL_HOSTED_PLANS
end
put 'rollback' do
ElasticNamespaceRolloutWorker.perform_async(params[:plan], params[:percentage], ElasticNamespaceRolloutWorker::ROLLBACK) # rubocop:disable CodeReuse/Worker
end
end
end
end