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