Commit 3913fc27 authored by Gabriel Mazetto's avatar Gabriel Mazetto

Merge branch '262639-feature-flag-cleanup' into 'master'

Remove the `container_expiration_policies_historic_entry` feature flag

See merge request gitlab-org/gitlab!80826
parents 73ddf654 2a1259f2
......@@ -25,8 +25,7 @@ module ContainerExpirationPoliciesHelper
end
end
def container_expiration_policies_historic_entry_enabled?(project)
Gitlab::CurrentSettings.container_expiration_policies_enable_historic_entries ||
Feature.enabled?(:container_expiration_policies_historic_entry, project)
def container_expiration_policies_historic_entry_enabled?
Gitlab::CurrentSettings.container_expiration_policies_enable_historic_entries
end
end
......@@ -50,8 +50,6 @@ module PackagesHelper
Gitlab.com? &&
Gitlab.config.registry.enabled &&
project.feature_available?(:container_registry, current_user) &&
!Gitlab::CurrentSettings.container_expiration_policies_enable_historic_entries &&
Feature.enabled?(:container_expiration_policies_historic_entry, project) &&
project.container_expiration_policy.nil? &&
project.container_repositories.exists?
end
......
......@@ -9,7 +9,7 @@
older_than_options: older_than_options.to_json,
is_admin: current_user&.admin.to_s,
admin_settings_path: ci_cd_admin_application_settings_path(anchor: 'js-registry-settings'),
enable_historic_entries: container_expiration_policies_historic_entry_enabled?(@project).to_s,
enable_historic_entries: container_expiration_policies_historic_entry_enabled?.to_s,
help_page_path: help_page_path('user/packages/container_registry/reduce_container_registry_storage', anchor: 'cleanup-policy'),
show_cleanup_policy_on_alert: show_cleanup_policy_on_alert(@project).to_s,
tags_regex_help_page_path: help_page_path('user/packages/container_registry/reduce_container_registry_storage', anchor: 'regex-pattern-examples') } }
---
name: container_expiration_policies_historic_entry
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/44444
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/262639
milestone: '13.5'
type: development
group: group::package
default_enabled: false
......@@ -49,20 +49,6 @@ Cleanup policies can be run on all projects, with these exceptions:
There are performance risks with enabling it for all projects, especially if you
are using an [external registry](#use-with-external-container-registries).
- For self-managed GitLab instances, you can enable or disable the cleanup policy for a specific
project.
To enable it:
```ruby
Feature.enable(:container_expiration_policies_historic_entry, Project.find(<project id>))
```
To disable it:
```ruby
Feature.disable(:container_expiration_policies_historic_entry, Project.find(<project id>))
```
WARNING:
For performance reasons, enabled cleanup policies are automatically disabled for projects on
......
......@@ -3,8 +3,6 @@
require 'spec_helper'
RSpec.describe 'Project > Settings > CI/CD > Container registry tag expiration policy', :js do
using RSpec::Parameterized::TableSyntax
let_it_be(:user) { create(:user) }
let_it_be(:project, reload: true) { create(:project, namespace: user.namespace) }
......@@ -63,31 +61,34 @@ RSpec.describe 'Project > Settings > CI/CD > Container registry tag expiration p
end
context 'with a project without expiration policy' do
where(:application_setting, :feature_flag, :result) do
true | true | :available_section
true | false | :available_section
false | true | :available_section
false | false | :disabled_message
before do
project.container_expiration_policy.destroy!
end
context 'with container_expiration_policies_enable_historic_entries enabled' do
before do
stub_application_setting(container_expiration_policies_enable_historic_entries: true)
end
it 'displays the related section' do
subject
within '[data-testid="registry-settings-app"]' do
expect(find('[data-testid="enable-toggle"]')).to have_content('Disabled - Tags will not be automatically deleted.')
end
end
end
with_them do
context 'with container_expiration_policies_enable_historic_entries disabled' do
before do
project.container_expiration_policy.destroy!
stub_feature_flags(container_expiration_policies_historic_entry: false)
stub_application_setting(container_expiration_policies_enable_historic_entries: application_setting)
stub_feature_flags(container_expiration_policies_historic_entry: project) if feature_flag
stub_application_setting(container_expiration_policies_enable_historic_entries: false)
end
it 'displays the expected result' do
it 'does not display the related section' do
subject
within '[data-testid="registry-settings-app"]' do
case result
when :available_section
expect(find('[data-testid="enable-toggle"]')).to have_content('Disabled - Tags will not be automatically deleted.')
when :disabled_message
expect(find('.gl-alert-title')).to have_content('Cleanup policy for tags is disabled')
end
expect(find('.gl-alert-title')).to have_content('Cleanup policy for tags is disabled')
end
end
end
......
......@@ -3,8 +3,6 @@
require 'spec_helper'
RSpec.describe ContainerExpirationPoliciesHelper do
using RSpec::Parameterized::TableSyntax
describe '#keep_n_options' do
it 'returns keep_n options formatted for dropdown usage' do
expected_result = [
......@@ -51,23 +49,22 @@ RSpec.describe ContainerExpirationPoliciesHelper do
describe '#container_expiration_policies_historic_entry_enabled?' do
let_it_be(:project) { build_stubbed(:project) }
subject { helper.container_expiration_policies_historic_entry_enabled?(project) }
subject { helper.container_expiration_policies_historic_entry_enabled? }
context 'when the application setting is enabled' do
before do
stub_application_setting(container_expiration_policies_enable_historic_entries: true)
end
where(:application_setting, :feature_flag, :expected_result) do
true | true | true
true | false | true
false | true | true
false | false | false
it { is_expected.to be_truthy }
end
with_them do
context 'when the application setting is disabled' do
before do
stub_feature_flags(container_expiration_policies_historic_entry: false)
stub_application_setting(container_expiration_policies_enable_historic_entries: application_setting)
stub_feature_flags(container_expiration_policies_historic_entry: project) if feature_flag
stub_application_setting(container_expiration_policies_enable_historic_entries: false)
end
it { is_expected.to eq(expected_result) }
it { is_expected.to be_falsey }
end
end
end
This diff is collapsed.
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