Commit 3cd38afa authored by David Fernandez's avatar David Fernandez Committed by Bob Van Landuyt

Enable cleanup policies throttling by default

Changelog: changed
parent 256b36a7
......@@ -2,8 +2,7 @@
module ContainerRegistryHelper
def container_registry_expiration_policies_throttling?
Feature.enabled?(:container_registry_expiration_policies_throttling) &&
ContainerRegistry::Client.supports_tag_delete?
Feature.enabled?(:container_registry_expiration_policies_throttling, default_enabled: :yaml)
end
def container_repository_gid_prefix
......
......@@ -152,7 +152,7 @@ module Projects
end
def throttling_enabled?
Feature.enabled?(:container_registry_expiration_policies_throttling)
Feature.enabled?(:container_registry_expiration_policies_throttling, default_enabled: :yaml)
end
def max_list_size
......
......@@ -54,7 +54,7 @@ module Projects
def throttling_enabled?
strong_memoize(:feature_flag) do
Feature.enabled?(:container_registry_expiration_policies_throttling)
Feature.enabled?(:container_registry_expiration_policies_throttling, default_enabled: :yaml)
end
end
......
......@@ -123,7 +123,7 @@ module ContainerExpirationPolicies
end
def throttling_enabled?
Feature.enabled?(:container_registry_expiration_policies_throttling)
Feature.enabled?(:container_registry_expiration_policies_throttling, default_enabled: :yaml)
end
def max_cleanup_execution_time
......
......@@ -99,7 +99,7 @@ class ContainerExpirationPolicyWorker # rubocop:disable Scalability/IdempotentWo
end
def throttling_enabled?
Feature.enabled?(:container_registry_expiration_policies_throttling)
Feature.enabled?(:container_registry_expiration_policies_throttling, default_enabled: :yaml)
end
def lease_timeout
......
......@@ -5,4 +5,4 @@ rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/238190
milestone: '13.4'
type: development
group: group::package
default_enabled: false
default_enabled: true
......@@ -157,11 +157,13 @@ Here are examples of regex patterns you may want to use:
### Set cleanup limits to conserve resources
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/288812) in GitLab 13.9.
> - It's [deployed behind a feature flag](../../feature_flags.md), disabled by default.
> - It's enabled on GitLab.com.
> - It's not recommended for production use.
> - To use it in GitLab self-managed instances, ask a GitLab administrator to [enable it](#enable-or-disable-cleanup-policy-limits).
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/288812) in GitLab 13.9 [with a flag](../../../administration/feature_flags.md) named `container_registry_expiration_policies_throttling`. Disabled by default.
> - [Enabled by default](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/80815) in GitLab 14.9.
FLAG:
By default this feature is available in GitLab 14.9. To disable the feature, an administrator can
[disable the feature flag](../../../administration/feature_flags.md)
named `container_registry_expiration_policies_throttling`.
Cleanup policies are executed as a background process. This process is complex, and depending on the number of tags to delete,
the process can take time to finish.
......@@ -188,31 +190,11 @@ For self-managed instances, those settings can be updated in the [Rails console]
ApplicationSetting.last.update(container_registry_expiration_policies_worker_capacity: 3)
```
Alternatively, once the limits are [enabled](#enable-or-disable-cleanup-policy-limits),
they are available in the [administrator area](../../admin_area/index.md):
They are also available in the [administrator area](../../admin_area/index.md):
1. On the top bar, select **Menu > Admin**.
1. Go to **Settings > CI/CD > Container Registry**.
#### Enable or disable cleanup policy limits
The cleanup policies limits are under development and not ready for production use. They are
deployed behind a feature flag that is **disabled by default**.
[GitLab administrators with access to the GitLab Rails console](../../../administration/feature_flags.md)
can enable it.
To enable it:
```ruby
Feature.enable(:container_registry_expiration_policies_throttling)
```
To disable it:
```ruby
Feature.disable(:container_registry_expiration_policies_throttling)
```
### Use the cleanup policy API
You can set, update, and disable the cleanup policies using the GitLab API.
......
......@@ -394,26 +394,16 @@ RSpec.describe 'Admin updates settings' do
%i[container_registry_delete_tags_service_timeout container_registry_expiration_policies_worker_capacity container_registry_cleanup_tags_service_max_list_size].each do |setting|
context "for container registry setting #{setting}" do
context 'with feature flag enabled' do
context 'with client supporting tag delete' do
it 'changes the setting' do
visit ci_cd_admin_application_settings_path
page.within('.as-registry') do
fill_in "application_setting_#{setting}", with: 400
click_button 'Save changes'
end
expect(current_settings.public_send(setting)).to eq(400)
expect(page).to have_content "Application settings saved successfully"
end
end
context 'with client not supporting tag delete' do
let(:client_support) { false }
it 'changes the setting' do
visit ci_cd_admin_application_settings_path
it_behaves_like 'not having container registry setting', setting
page.within('.as-registry') do
fill_in "application_setting_#{setting}", with: 400
click_button 'Save changes'
end
expect(current_settings.public_send(setting)).to eq(400)
expect(page).to have_content "Application settings saved successfully"
end
context 'with feature flag disabled' do
......@@ -425,28 +415,18 @@ RSpec.describe 'Admin updates settings' do
end
context 'for container registry setting container_registry_expiration_policies_caching' do
context 'with feature flag enabled' do
context 'with client supporting tag delete' do
it 'updates container_registry_expiration_policies_caching' do
old_value = current_settings.container_registry_expiration_policies_caching
it 'updates container_registry_expiration_policies_caching' do
old_value = current_settings.container_registry_expiration_policies_caching
visit ci_cd_admin_application_settings_path
page.within('.as-registry') do
find('#application_setting_container_registry_expiration_policies_caching.form-check-input').click
click_button 'Save changes'
end
visit ci_cd_admin_application_settings_path
expect(current_settings.container_registry_expiration_policies_caching).to eq(!old_value)
expect(page).to have_content "Application settings saved successfully"
end
page.within('.as-registry') do
find('#application_setting_container_registry_expiration_policies_caching.form-check-input').click
click_button 'Save changes'
end
context 'with client not supporting tag delete' do
let(:client_support) { false }
it_behaves_like 'not having container registry setting', :container_registry_expiration_policies_caching
end
expect(current_settings.container_registry_expiration_policies_caching).to eq(!old_value)
expect(page).to have_content "Application settings saved successfully"
end
context 'with feature flag disabled' do
......
......@@ -3,25 +3,17 @@
require 'spec_helper'
RSpec.describe ContainerRegistryHelper do
using RSpec::Parameterized::TableSyntax
describe '#container_registry_expiration_policies_throttling?' do
subject { helper.container_registry_expiration_policies_throttling? }
where(:feature_flag_enabled, :client_support, :expected_result) do
true | true | true
true | false | false
false | true | false
false | false | false
end
it { is_expected.to eq(true) }
with_them do
context 'with container_registry_expiration_policies_throttling disabled' do
before do
stub_feature_flags(container_registry_expiration_policies_throttling: feature_flag_enabled)
allow(ContainerRegistry::Client).to receive(:supports_tag_delete?).and_return(client_support)
stub_feature_flags(container_registry_expiration_policies_throttling: false)
end
it { is_expected.to eq(expected_result) }
it { is_expected.to eq(false) }
end
end
end
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