diff --git a/app/helpers/application_settings_helper.rb b/app/helpers/application_settings_helper.rb index 242bde1fb697478a04e997d2f1ea2fcf4200444c..2e680d502becc908550a1d8aed4c033c558174bd 100644 --- a/app/helpers/application_settings_helper.rb +++ b/app/helpers/application_settings_helper.rb @@ -511,6 +511,7 @@ def visible_attributes :deactivation_email_additional_text, :projects_api_rate_limit_unauthenticated, :gitlab_dedicated_instance, + :gitlab_environment_toolkit_instance, :ci_max_includes, :allow_account_deletion, :gitlab_shell_operation_limit, diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb index c44d9f9d8a57c3f97c6fdd7ee8a8341faaae2977..959000af9ed86f2ba375bc544d83f8ce2cc05f47 100644 --- a/app/models/application_setting.rb +++ b/app/models/application_setting.rb @@ -610,6 +610,9 @@ def self.kroki_formats_attributes concurrent_bitbucket_import_jobs_limit: [:integer, { default: 100 }], concurrent_bitbucket_server_import_jobs_limit: [:integer, { default: 100 }] + jsonb_accessor :service_ping_settings, + gitlab_environment_toolkit_instance: [:boolean, { default: false }] + validates :rate_limits, json_schema: { filename: "application_setting_rate_limits" } validates :search_rate_limit_allowlist, @@ -767,6 +770,8 @@ def self.kroki_formats_attributes allow_nil: false, inclusion: { in: [true, false], message: N_('must be a boolean value') } + validates :service_ping_settings, json_schema: { filename: 'application_setting_service_ping_settings' } + validates :math_rendering_limits_enabled, inclusion: { in: [true, false], message: N_('must be a boolean value') } diff --git a/app/models/application_setting_implementation.rb b/app/models/application_setting_implementation.rb index d3aecfbd04c1f64ef4e55831ad384cca993f9208..e715bc86693027be22dc871a99a6912541f4f684 100644 --- a/app/models/application_setting_implementation.rb +++ b/app/models/application_setting_implementation.rb @@ -274,6 +274,7 @@ def defaults # rubocop:disable Metrics/AbcSize user_defaults_to_private_profile: false, projects_api_rate_limit_unauthenticated: 400, gitlab_dedicated_instance: false, + gitlab_environment_toolkit_instance: false, ci_max_includes: 150, allow_account_deletion: true, gitlab_shell_operation_limit: 600, diff --git a/app/validators/json_schemas/application_setting_service_ping_settings.json b/app/validators/json_schemas/application_setting_service_ping_settings.json new file mode 100644 index 0000000000000000000000000000000000000000..7711e19699b57ffe156eb7a2e80cbe6820c805c9 --- /dev/null +++ b/app/validators/json_schemas/application_setting_service_ping_settings.json @@ -0,0 +1,12 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "description": "Application service ping settings", + "type": "object", + "additionalProperties": false, + "properties": { + "gitlab_environment_toolkit_instance": { + "type": "boolean", + "description": "Indicates whether the instance was provisioned with the GitLab Environment Toolkit for Service Ping reporting." + } + } +} diff --git a/db/migrate/20240402150229_add_service_ping_settings_json_column_to_application_settings.rb b/db/migrate/20240402150229_add_service_ping_settings_json_column_to_application_settings.rb new file mode 100644 index 0000000000000000000000000000000000000000..f42184e5e106003131ba926b3d08379b5c3461e8 --- /dev/null +++ b/db/migrate/20240402150229_add_service_ping_settings_json_column_to_application_settings.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class AddServicePingSettingsJsonColumnToApplicationSettings < Gitlab::Database::Migration[2.2] + milestone '16.11' + + disable_ddl_transaction! + + def up + add_column :application_settings, :service_ping_settings, :jsonb, default: {}, null: false + + add_check_constraint( + :application_settings, + "(jsonb_typeof(service_ping_settings) = 'object')", + 'check_application_settings_service_ping_settings_is_hash' + ) + end + + def down + remove_column :application_settings, :service_ping_settings + end +end diff --git a/db/schema_migrations/20240402150229 b/db/schema_migrations/20240402150229 new file mode 100644 index 0000000000000000000000000000000000000000..ba4b54f28f972cd7b760d51a61c718904c74a00f --- /dev/null +++ b/db/schema_migrations/20240402150229 @@ -0,0 +1 @@ +9a7d516a066dfd80bc5b772b95920c4a08a7871e0abf2629d36e8c2513ec7633 \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 99e44af747956eec9958a0743984ea3a592bccdd..5deb5598d1f8d45e0f4af0d0d1a5738c8283f8bc 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -4266,6 +4266,7 @@ CREATE TABLE application_settings ( clickhouse jsonb DEFAULT '{}'::jsonb NOT NULL, include_optional_metrics_in_service_ping boolean DEFAULT true NOT NULL, zoekt_settings jsonb DEFAULT '{}'::jsonb NOT NULL, + service_ping_settings jsonb DEFAULT '{}'::jsonb 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_container_registry_pre_import_tags_rate_positive CHECK ((container_registry_pre_import_tags_rate >= (0)::numeric)), CONSTRAINT app_settings_dep_proxy_ttl_policies_worker_capacity_positive CHECK ((dependency_proxy_ttl_group_policy_worker_capacity >= 0)), @@ -4318,6 +4319,7 @@ CREATE TABLE application_settings ( CONSTRAINT check_app_settings_sentry_clientside_traces_sample_rate_range CHECK (((sentry_clientside_traces_sample_rate >= (0)::double precision) AND (sentry_clientside_traces_sample_rate <= (1)::double precision))), CONSTRAINT check_application_settings_clickhouse_is_hash CHECK ((jsonb_typeof(clickhouse) = 'object'::text)), CONSTRAINT check_application_settings_rate_limits_is_hash CHECK ((jsonb_typeof(rate_limits) = 'object'::text)), + CONSTRAINT check_application_settings_service_ping_settings_is_hash CHECK ((jsonb_typeof(service_ping_settings) = 'object'::text)), CONSTRAINT check_b8c74ea5b3 CHECK ((char_length(deactivation_email_additional_text) <= 1000)), CONSTRAINT check_cdfbd99405 CHECK ((char_length(security_txt_content) <= 2048)), CONSTRAINT check_d03919528d CHECK ((char_length(container_registry_vendor) <= 255)), diff --git a/doc/api/settings.md b/doc/api/settings.md index d325b16750e99e0a2ff33d73ed15869f474d2cc2..69e717fa5d59423fe42506c3b7fa346ea8725d46 100644 --- a/doc/api/settings.md +++ b/doc/api/settings.md @@ -471,6 +471,7 @@ listed in the descriptions of the relevant settings. | `gitaly_timeout_fast` | integer | no | Gitaly fast operation timeout, in seconds. Some Gitaly operations are expected to be fast. If they exceed this threshold, there may be a problem with a storage shard and 'failing fast' can help maintain the stability of the GitLab instance. Set to `0` to disable timeouts. | | `gitaly_timeout_medium` | integer | no | Medium Gitaly timeout, in seconds. This should be a value between the Fast and the Default timeout. Set to `0` to disable timeouts. | | `gitlab_dedicated_instance` | boolean | no | Indicates whether the instance was provisioned for GitLab Dedicated. | +| `gitlab_environment_toolkit_instance` | boolean | no | Indicates whether the instance was provisioned with the GitLab Environment Toolkit for Service Ping reporting. | | `gitlab_shell_operation_limit` | integer | no | Maximum number of Git operations per minute a user can perform. Default: `600`. [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/412088) in GitLab 16.2. | | `grafana_enabled` | boolean | no | Enable Grafana. | | `grafana_url` | string | no | Grafana URL. | diff --git a/spec/helpers/application_settings_helper_spec.rb b/spec/helpers/application_settings_helper_spec.rb index 43075a75d1ca1f025626be5bb0fa958f6fb52735..2afe8c97127e5adc6972c1c794e52cb80d18d798 100644 --- a/spec/helpers/application_settings_helper_spec.rb +++ b/spec/helpers/application_settings_helper_spec.rb @@ -79,6 +79,13 @@ expect(helper.visible_attributes).to include(:namespace_aggregation_schedule_lease_duration_in_seconds) end + it 'contains service ping settings' do + expect(helper.visible_attributes).to include( + *%i[ + gitlab_environment_toolkit_instance + ]) + end + context 'when on SaaS', :saas do it 'does not contain :deactivate_dormant_users' do expect(helper.visible_attributes).not_to include(:deactivate_dormant_users) diff --git a/spec/models/application_setting_spec.rb b/spec/models/application_setting_spec.rb index 09d8743304b67677582b1e6a0d279d0ce118fff7..55d78e13cc1365dea68a5ddaf4a8b77649c5c585 100644 --- a/spec/models/application_setting_spec.rb +++ b/spec/models/application_setting_spec.rb @@ -66,6 +66,8 @@ it { expect(described_class).to validate_jsonb_schema(['application_setting_rate_limits']) } + it { expect(described_class).to validate_jsonb_schema(['application_setting_service_ping_settings']) } + it { is_expected.to allow_value(nil).for(:home_page_url) } it { is_expected.to allow_value(http).for(:home_page_url) } it { is_expected.to allow_value(https).for(:home_page_url) }