Commit 864168c9 authored by Markus Koller's avatar Markus Koller

Merge branch '238190-sane-defaults' into 'master'

Update cleanup policy parameters

See merge request gitlab-org/gitlab!80809
parents 0c5cf75b 40398dff
......@@ -218,7 +218,8 @@ module ApplicationSettingImplementation
valid_runner_registrars: VALID_RUNNER_REGISTRAR_TYPES,
wiki_page_max_content_bytes: 50.megabytes,
container_registry_delete_tags_service_timeout: 250,
container_registry_expiration_policies_worker_capacity: 0,
container_registry_expiration_policies_worker_capacity: 4,
container_registry_cleanup_tags_service_max_list_size: 200,
container_registry_import_max_tags_count: 100,
container_registry_import_max_retries: 3,
container_registry_import_start_max_retries: 50,
......
# frozen_string_literal: true
class UpdateApplicationSettingsContainerRegistryExpPolWorkerCapacityDefault < Gitlab::Database::Migration[1.0]
class Settings < ActiveRecord::Base
self.table_name = 'application_settings'
end
def up
change_column_default(:application_settings, :container_registry_expiration_policies_worker_capacity, from: 0, to: 4)
current_settings = Settings.first
if current_settings&.container_registry_expiration_policies_worker_capacity == 0
current_settings.update!(container_registry_expiration_policies_worker_capacity: 4)
end
end
def down
change_column_default(:application_settings, :container_registry_expiration_policies_worker_capacity, from: 4, to: 0)
end
end
af6d142b77bc2787a520f8cbc63c287823a7a65a2edb3eb488e4f0f4efde9fa8
\ No newline at end of file
......@@ -10552,7 +10552,7 @@ CREATE TABLE application_settings (
automatic_purchased_storage_allocation boolean DEFAULT false NOT NULL,
encrypted_ci_jwt_signing_key text,
encrypted_ci_jwt_signing_key_iv text,
container_registry_expiration_policies_worker_capacity integer DEFAULT 0 NOT NULL,
container_registry_expiration_policies_worker_capacity integer DEFAULT 4 NOT NULL,
elasticsearch_analyzers_smartcn_enabled boolean DEFAULT false NOT NULL,
elasticsearch_analyzers_smartcn_search boolean DEFAULT false NOT NULL,
elasticsearch_analyzers_kuromoji_enabled boolean DEFAULT false NOT NULL,
......@@ -182,11 +182,16 @@ the process can take time to finish.
To prevent server resource starvation, the following application settings are available:
- `container_registry_expiration_policies_worker_capacity`. The maximum number of cleanup workers running concurrently. This must be greater than `1`.
We recommend starting with a low number and increasing it after monitoring the resources used by the background workers.
- `container_registry_delete_tags_service_timeout`. The maximum time, in seconds, that the cleanup process can take to delete a batch of tags.
- `container_registry_cleanup_tags_service_max_list_size`. The maximum number of tags that can be deleted in a single execution. Additional tags must be deleted in another execution.
We recommend starting with a low number, like `100`, and increasing it after monitoring that container images are properly deleted.
- `container_registry_expiration_policies_worker_capacity`: the maximum number of cleanup workers
running concurrently. This must be greater than or equal to `0`. We recommend starting with a low
number and increasing it after monitoring the resources used by the background workers. To remove
all workers and not execute the cleanup policies, set this to `0`. The default value is `4`.
- `container_registry_delete_tags_service_timeout`: the maximum time (in seconds) that the cleanup
process can take to delete a batch of tags. The default value is `250`.
- `container_registry_cleanup_tags_service_max_list_size`: the maximum number of tags that can be
deleted in a single execution. Additional tags must be deleted in another execution. We recommend
starting with a low number and increasing it after monitoring that container images are properly
deleted. The default value is `200`.
For self-managed instances, those settings can be updated in the [Rails console](../../../administration/operations/rails_console.md#starting-a-rails-console-session):
......
# frozen_string_literal: true
require 'spec_helper'
require_migration!
RSpec.describe UpdateApplicationSettingsContainerRegistryExpPolWorkerCapacityDefault do
let(:settings) { table(:application_settings) }
context 'with no rows in the application_settings table' do
it 'does not insert a row' do
expect { migrate! }.to not_change { settings.count }
end
end
context 'with a row in the application_settings table' do
before do
settings.create!(container_registry_expiration_policies_worker_capacity: capacity)
end
context 'with container_registry_expiration_policy_worker_capacity set to a value different than 0' do
let(:capacity) { 1 }
it 'does not update the row' do
expect { migrate! }
.to not_change { settings.count }
.and not_change { settings.first.container_registry_expiration_policies_worker_capacity }
end
end
context 'with container_registry_expiration_policy_worker_capacity set to 0' do
let(:capacity) { 0 }
it 'updates the existing row' do
expect { migrate! }
.to not_change { settings.count }
.and change { settings.first.container_registry_expiration_policies_worker_capacity }.from(0).to(4)
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