Commit 60b8b509 authored by huzaifaiftikhar1's avatar huzaifaiftikhar1 Committed by Huzaifa Iftikhar

Add application settings to support inactive project deletion feature

To support the inactive project deletion feature we need to store the
following settings for the GitLab instance.
- Enable/disable inactive project deletion.
- Minimum size of the repository in MB that should be considered
for inactive project deletion.
- Time in months after which we need to send a warning email to the
project maintainers saying that their project will be deleted
because of inactivity.
- Time in months after which the project needs to be deleted
because of inactivity.

Changelog: added
parent 4f6be856
......@@ -223,6 +223,7 @@ module ApplicationSettingsHelper
:default_project_visibility,
:default_projects_limit,
:default_snippet_visibility,
:delete_inactive_projects,
:disable_feed_token,
:disabled_oauth_sign_in_sources,
:domain_denylist,
......@@ -273,6 +274,9 @@ module ApplicationSettingsHelper
:html_emails_enabled,
:import_sources,
:in_product_marketing_emails_enabled,
:inactive_projects_delete_after,
:inactive_projects_min_size_mb,
:inactive_projects_send_warning_email_after,
:invisible_captcha_enabled,
:max_artifacts_size,
:max_attachment_size,
......
......@@ -578,6 +578,15 @@ class ApplicationSetting < ApplicationRecord
validates :public_runner_releases_url, addressable_url: true, presence: true
validates :inactive_projects_min_size_mb,
numericality: { only_integer: true, greater_than_or_equal_to: 0 }
validates :inactive_projects_delete_after,
numericality: { only_integer: true, greater_than: 0 }
validates :inactive_projects_send_warning_email_after,
numericality: { only_integer: true, greater_than: 0, less_than: :inactive_projects_delete_after }
attr_encrypted :asset_proxy_secret_key,
mode: :per_attribute_iv,
key: Settings.attr_encrypted_db_key_base_truncated,
......
# frozen_string_literal: true
class AddInactiveProjectDeletionToApplicationSettings < Gitlab::Database::Migration[1.0]
def change
add_column :application_settings, :delete_inactive_projects, :boolean, default: false, null: false
add_column :application_settings, :inactive_projects_delete_after, :integer, default: 2, null: false
add_column :application_settings, :inactive_projects_min_size_mb, :integer, default: 0, null: false
add_column :application_settings, :inactive_projects_send_warning_email_after, :integer, default: 1, null: false
end
end
161ba8db7400c12dc0550246af8db86487e811803eaecedcb2761f4a8349920b
\ No newline at end of file
......@@ -11257,6 +11257,10 @@ CREATE TABLE application_settings (
database_grafana_api_url text,
database_grafana_tag text,
public_runner_releases_url text DEFAULT 'https://gitlab.com/api/v4/projects/gitlab-org%2Fgitlab-runner/releases'::text NOT NULL,
delete_inactive_projects boolean DEFAULT false NOT NULL,
inactive_projects_delete_after integer DEFAULT 2 NOT NULL,
inactive_projects_min_size_mb integer DEFAULT 0 NOT NULL,
inactive_projects_send_warning_email_after integer DEFAULT 1 NOT NULL,
CONSTRAINT app_settings_container_reg_cleanup_tags_max_list_size_positive CHECK ((container_registry_cleanup_tags_service_max_list_size >= 0)),
CONSTRAINT app_settings_dep_proxy_ttl_policies_worker_capacity_positive CHECK ((dependency_proxy_ttl_group_policy_worker_capacity >= 0)),
CONSTRAINT app_settings_ext_pipeline_validation_service_url_text_limit CHECK ((char_length(external_pipeline_validation_service_url) <= 255)),
......@@ -274,6 +274,7 @@ listed in the descriptions of the relevant settings.
| `default_projects_limit` | integer | no | Project limit per user. Default is `100000`. |
| `default_snippet_visibility` | string | no | What visibility level new snippets receive. Can take `private`, `internal` and `public` as a parameter. Default is `private`. |
| `delayed_project_deletion` **(PREMIUM SELF)** | boolean | no | Enable delayed project deletion by default in new groups. Default is `false`. |
| `delete_inactive_projects` | boolean | no | Enable inactive project deletion feature. Default is `false`. |
| `deletion_adjourned_period` **(PREMIUM SELF)** | integer | no | The number of days to wait before deleting a project or group that is marked for deletion. Value must be between 0 and 90.
| `diff_max_patch_bytes` | integer | no | Maximum [diff patch size](../user/admin_area/diff_limits.md), in bytes. |
| `diff_max_files` | integer | no | Maximum [files in a diff](../user/admin_area/diff_limits.md). |
......@@ -350,6 +351,9 @@ listed in the descriptions of the relevant settings.
| `html_emails_enabled` | boolean | no | Enable HTML emails. |
| `import_sources` | array of strings | no | Sources to allow project import from, possible values: `github`, `bitbucket`, `bitbucket_server`, `gitlab`, `fogbugz`, `git`, `gitlab_project`, `gitea`, `manifest`, and `phabricator`. |
| `in_product_marketing_emails_enabled` | boolean | no | Enable [in-product marketing emails](../user/profile/notifications.md#global-notification-settings). Enabled by default. |
| `inactive_projects_delete_after` | integer | no | Delete projects that are inactive for this time in months. |
| `inactive_projects_min_size_mb` | integer | no | Delete inactive projects that exceed this size in MB. |
| `inactive_projects_send_warning_email_after` | integer | no | Send email to maintainers after project is inactive for this time in months. |
| `invisible_captcha_enabled` | boolean | no | Enable Invisible CAPTCHA spam detection during sign-up. Disabled by default. |
| `issues_create_limit` | integer | no | Max number of issue creation requests per minute per user. Disabled by default.|
| `keep_latest_artifact` | boolean | no | Prevent the deletion of the artifacts from the most recent successful jobs, regardless of the expiry time. Enabled by default. |
......
......@@ -1322,4 +1322,19 @@ RSpec.describe ApplicationSetting do
end
end
end
context "inactive project deletion" do
it "validates that inactive_projects_send_warning_email_after is less than inactive_projects_delete_after" do
subject[:inactive_projects_delete_after] = 3
subject[:inactive_projects_send_warning_email_after] = 6
expect(subject).to be_invalid
end
it { is_expected.to validate_numericality_of(:inactive_projects_send_warning_email_after).is_greater_than(0) }
it { is_expected.to validate_numericality_of(:inactive_projects_delete_after).is_greater_than(0) }
it { is_expected.to validate_numericality_of(:inactive_projects_min_size_mb).is_greater_than_or_equal_to(0) }
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