diff --git a/app/models/concerns/project_features_compatibility.rb b/app/models/concerns/project_features_compatibility.rb index c70100c03c8c6f9d3440a4072dbdf1d5a6976453..1d687b29b022755a5bae4c4928efad7f20b3aa4e 100644 --- a/app/models/concerns/project_features_compatibility.rb +++ b/app/models/concerns/project_features_compatibility.rb @@ -118,6 +118,10 @@ def model_experiments_access_level=(value) write_feature_attribute_string(:model_experiments_access_level, value) end + def model_registry_access_level=(value) + write_feature_attribute_string(:model_registry_access_level, value) + end + # TODO: Remove this method after we drop support for project create/edit APIs to set the # container_registry_enabled attribute. They can instead set the container_registry_access_level # attribute. diff --git a/app/models/project.rb b/app/models/project.rb index 655ca2095a5723b8be7be8fdd319726926f4b231..d0f0bd7c46cea435c1d0e163f829be2db5ab7b8b 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -499,7 +499,7 @@ def self.integration_association_name(name) accepts_nested_attributes_for :prometheus_integration, update_only: true accepts_nested_attributes_for :alerting_setting, update_only: true - delegate :merge_requests_access_level, :forking_access_level, :issues_access_level, :wiki_access_level, :snippets_access_level, :builds_access_level, :repository_access_level, :package_registry_access_level, :pages_access_level, :metrics_dashboard_access_level, :analytics_access_level, :operations_access_level, :security_and_compliance_access_level, :container_registry_access_level, :environments_access_level, :feature_flags_access_level, :monitor_access_level, :releases_access_level, :infrastructure_access_level, :model_experiments_access_level, to: :project_feature, allow_nil: true + delegate :merge_requests_access_level, :forking_access_level, :issues_access_level, :wiki_access_level, :snippets_access_level, :builds_access_level, :repository_access_level, :package_registry_access_level, :pages_access_level, :metrics_dashboard_access_level, :analytics_access_level, :operations_access_level, :security_and_compliance_access_level, :container_registry_access_level, :environments_access_level, :feature_flags_access_level, :monitor_access_level, :releases_access_level, :infrastructure_access_level, :model_experiments_access_level, :model_registry_access_level, to: :project_feature, allow_nil: true delegate :name, to: :owner, allow_nil: true, prefix: true delegate :jira_dvcs_server_last_sync_at, to: :feature_usage delegate :last_pipeline, to: :commit, allow_nil: true diff --git a/app/models/project_feature.rb b/app/models/project_feature.rb index 36f1e09b2bad621c12010604c40a78b3150bd722..c8287628716af77e81838c24db698f45cfadb79a 100644 --- a/app/models/project_feature.rb +++ b/app/models/project_feature.rb @@ -27,6 +27,7 @@ class ProjectFeature < ApplicationRecord releases infrastructure model_experiments + model_registry ].freeze EXPORTABLE_FEATURES = (FEATURES - [:security_and_compliance, :pages]).freeze @@ -81,6 +82,7 @@ def required_minimum_access_level_for_private_project(feature) attribute :feature_flags_access_level, default: ENABLED attribute :environments_access_level, default: ENABLED attribute :model_experiments_access_level, default: ENABLED + attribute :model_registry_access_level, default: ENABLED attribute :package_registry_access_level, default: -> do if ::Gitlab.config.packages.enabled diff --git a/config/audit_events/types/project_feature_model_registry_access_level_updated.yml b/config/audit_events/types/project_feature_model_registry_access_level_updated.yml new file mode 100644 index 0000000000000000000000000000000000000000..2be827cfcadcba06ded8f57e4deb8b37a36e081d --- /dev/null +++ b/config/audit_events/types/project_feature_model_registry_access_level_updated.yml @@ -0,0 +1,9 @@ +--- +name: project_feature_model_registry_access_level_updated +description: Model registry access level was updated +introduced_by_issue: https://gitlab.com/gitlab-org/gitlab/-/issues/412734 +introduced_by_mr: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/138399 +feature_category: mlops +milestone: '16.7' +saved_to_database: true +streamed: true diff --git a/db/migrate/20231130195635_add_model_registry_access_level_to_project_feature.rb b/db/migrate/20231130195635_add_model_registry_access_level_to_project_feature.rb new file mode 100644 index 0000000000000000000000000000000000000000..95675a1f82af41ed7cc75ceab676b6a644c4cbbc --- /dev/null +++ b/db/migrate/20231130195635_add_model_registry_access_level_to_project_feature.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class AddModelRegistryAccessLevelToProjectFeature < Gitlab::Database::Migration[2.2] + OPERATIONS_DEFAULT_VALUE = 20 + + enable_lock_retries! + milestone '16.7' + + def change + add_column :project_features, + :model_registry_access_level, + :integer, + null: false, + default: OPERATIONS_DEFAULT_VALUE + end +end diff --git a/db/schema_migrations/20231130195635 b/db/schema_migrations/20231130195635 new file mode 100644 index 0000000000000000000000000000000000000000..5e8d8232feb302664bac72a8acf0005f3800dcec --- /dev/null +++ b/db/schema_migrations/20231130195635 @@ -0,0 +1 @@ +5c9d89f5d5401d6a7082d5790cb12ee610a0a06138cf3608534a09685c812ea8 \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index be9eee3f9af6c47a75f7986e66d6c88c60a8212d..15d2875b02d6fb66acc845abf472d7b4c0e07fbd 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -21897,7 +21897,8 @@ CREATE TABLE project_features ( feature_flags_access_level integer DEFAULT 20 NOT NULL, environments_access_level integer DEFAULT 20 NOT NULL, releases_access_level integer DEFAULT 20 NOT NULL, - model_experiments_access_level integer DEFAULT 20 NOT NULL + model_experiments_access_level integer DEFAULT 20 NOT NULL, + model_registry_access_level integer DEFAULT 20 NOT NULL ); CREATE SEQUENCE project_features_id_seq diff --git a/doc/administration/audit_event_streaming/audit_event_types.md b/doc/administration/audit_event_streaming/audit_event_types.md index fa89074ad53faf85dd113f783a540c98187ef935..cc396a6345cf399790c518808c2955dc750f5d1d 100644 --- a/doc/administration/audit_event_streaming/audit_event_types.md +++ b/doc/administration/audit_event_streaming/audit_event_types.md @@ -313,6 +313,7 @@ Audit event types belong to the following product categories. | Name | Description | Saved to database | Streamed | Introduced in | |:-----|:------------|:------------------|:---------|:--------------| | [`project_feature_model_experiments_access_level_updated`](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/121027) | Model experiments access level was updated| **{check-circle}** Yes | **{check-circle}** Yes | GitLab [16.1](https://gitlab.com/gitlab-org/gitlab/-/issues/412384) | +| [`project_feature_model_registry_access_level_updated`](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/138399) | Model registry access level was updated| **{check-circle}** Yes | **{check-circle}** Yes | GitLab [16.7](https://gitlab.com/gitlab-org/gitlab/-/issues/412734) | ### Not categorized diff --git a/ee/lib/audit/project_feature_changes_auditor.rb b/ee/lib/audit/project_feature_changes_auditor.rb index 4a2ce47154056219a13e1ac511086f8cfddb1236..3fcada86b6ff5abb212a30b3bdca4775f73e251e 100644 --- a/ee/lib/audit/project_feature_changes_auditor.rb +++ b/ee/lib/audit/project_feature_changes_auditor.rb @@ -25,7 +25,8 @@ class ProjectFeatureChangesAuditor < BaseChangesAuditor feature_flags_access_level: 'project_feature_feature_flags_access_level_updated', environments_access_level: 'project_feature_environments_access_level_updated', releases_access_level: 'project_feature_releases_access_level_updated', - model_experiments_access_level: 'project_feature_model_experiments_access_level_updated' + model_experiments_access_level: 'project_feature_model_experiments_access_level_updated', + model_registry_access_level: 'project_feature_model_registry_access_level_updated' }.freeze def initialize(current_user, model, project) diff --git a/lib/gitlab/import_export/project/import_export.yml b/lib/gitlab/import_export/project/import_export.yml index 6f3601e9a2189ab51cfc6b10e96740f231a2c54a..e38930ed5480eb34f5f3da7718c8756ae5c42b2f 100644 --- a/lib/gitlab/import_export/project/import_export.yml +++ b/lib/gitlab/import_export/project/import_export.yml @@ -318,6 +318,7 @@ included_attributes: - :releases_access_level - :infrastructure_access_level - :model_experiments_access_level + - :model_registry_access_level prometheus_metrics: - :created_at - :updated_at @@ -738,6 +739,7 @@ included_attributes: - :releases_access_level - :infrastructure_access_level - :model_experiments_access_level + - :model_registry_access_level - :auto_devops_deploy_strategy - :auto_devops_enabled - :container_registry_enabled diff --git a/rubocop/cop/gitlab/feature_available_usage.rb b/rubocop/cop/gitlab/feature_available_usage.rb index 307ff7ea6f66de2706fcb0f262e805c3d2cad93c..0b1c4367eae7b373545b3189a2a66d78e52d8954 100644 --- a/rubocop/cop/gitlab/feature_available_usage.rb +++ b/rubocop/cop/gitlab/feature_available_usage.rb @@ -29,6 +29,7 @@ class FeatureAvailableUsage < RuboCop::Cop::Base releases infrastructure model_experiments + model_registry ].freeze EE_FEATURES = %i[requirements].freeze ALL_FEATURES = (FEATURES + EE_FEATURES).freeze diff --git a/spec/factories/projects.rb b/spec/factories/projects.rb index a1d56194ba5a63a9b71b8fd5ab0f7e55041e068b..82fdeea95575564ff08ac20c6be4290a93e0158d 100644 --- a/spec/factories/projects.rb +++ b/spec/factories/projects.rb @@ -43,6 +43,7 @@ releases_access_level { ProjectFeature::ENABLED } infrastructure_access_level { ProjectFeature::ENABLED } model_experiments_access_level { ProjectFeature::ENABLED } + model_registry_access_level { ProjectFeature::ENABLED } # we can't assign the delegated `#ci_cd_settings` attributes directly, as the # `#ci_cd_settings` relation needs to be created first diff --git a/spec/lib/gitlab/import_export/safe_model_attributes.yml b/spec/lib/gitlab/import_export/safe_model_attributes.yml index e0efa1bfd38ac79738ba6abb0ebd8098ccfe6b88..3efa33d8879fff3c903bb14c7e2885a3119754c5 100644 --- a/spec/lib/gitlab/import_export/safe_model_attributes.yml +++ b/spec/lib/gitlab/import_export/safe_model_attributes.yml @@ -706,6 +706,7 @@ ProjectFeature: - monitor_access_level - infrastructure_access_level - model_experiments_access_level +- model_registry_access_level - created_at - updated_at ProtectedBranch::MergeAccessLevel: diff --git a/spec/models/project_feature_spec.rb b/spec/models/project_feature_spec.rb index c0a78ff2f53ab6f2852846916181b0e6ac03b57c..149b0d4df8ce9a443c70a3c813b93899e064f2fa 100644 --- a/spec/models/project_feature_spec.rb +++ b/spec/models/project_feature_spec.rb @@ -31,6 +31,7 @@ specify { expect(subject.package_registry_access_level).to eq(ProjectFeature::ENABLED) } specify { expect(subject.container_registry_access_level).to eq(ProjectFeature::ENABLED) } specify { expect(subject.model_experiments_access_level).to eq(ProjectFeature::ENABLED) } + specify { expect(subject.model_registry_access_level).to eq(ProjectFeature::ENABLED) } end describe 'PRIVATE_FEATURES_MIN_ACCESS_LEVEL_FOR_PRIVATE_PROJECT' do diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index e458a086bcce2152df45d3428e2b4b7184a7247e..9c7902e0240942f5d8ecf69a39a8cb3106b36d42 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -1128,6 +1128,7 @@ it { is_expected.to delegate_method(:container_registry_access_level).to(:project_feature) } it { is_expected.to delegate_method(:environments_access_level).to(:project_feature) } it { is_expected.to delegate_method(:model_experiments_access_level).to(:project_feature) } + it { is_expected.to delegate_method(:model_registry_access_level).to(:project_feature) } it { is_expected.to delegate_method(:feature_flags_access_level).to(:project_feature) } it { is_expected.to delegate_method(:releases_access_level).to(:project_feature) } it { is_expected.to delegate_method(:infrastructure_access_level).to(:project_feature) } diff --git a/spec/requests/api/project_attributes.yml b/spec/requests/api/project_attributes.yml index bab5bd2b6acf09e0dbcf0aec59b639e0ddadb6cd..ab03df84cd5b983acbb9b1a1c016f33d20a5c175 100644 --- a/spec/requests/api/project_attributes.yml +++ b/spec/requests/api/project_attributes.yml @@ -133,6 +133,7 @@ project_feature: - project_id - updated_at - operations_access_level + - model_registry_access_level computed_attributes: - issues_enabled - jobs_enabled