From ccfee23ee6969f9ac702c2b128c2d68680774bcb Mon Sep 17 00:00:00 2001 From: Rutvik Chandla <rutvik.c@browserstack.com> Date: Tue, 29 Oct 2024 23:35:19 +0530 Subject: [PATCH 1/4] Create separate feature flag for require_organization for Project Model --- app/models/application_record.rb | 6 ------ app/models/namespace.rb | 6 ++++++ app/models/project.rb | 6 ++++++ .../require_organization_on_project.yml | 9 +++++++++ spec/models/project_spec.rb | 2 +- 5 files changed, 22 insertions(+), 7 deletions(-) create mode 100644 config/feature_flags/gitlab_com_derisk/require_organization_on_project.yml diff --git a/app/models/application_record.rb b/app/models/application_record.rb index 70b60743bae6f4..78274f1d258bee 100644 --- a/app/models/application_record.rb +++ b/app/models/application_record.rb @@ -138,12 +138,6 @@ def self.nullable_column?(column_name) !not_null_check?(column_name) end - def require_organization? - return false unless Feature.enabled?(:require_organization, Feature.current_request) - - Gitlab::SafeRequestStore.fetch(:require_organization) { true } # rubocop:disable Style/RedundantFetchBlock -- This fetch has a different interface - end - def readable_by?(user) Ability.allowed?(user, "read_#{to_ability_name}".to_sym, self) end diff --git a/app/models/namespace.rb b/app/models/namespace.rb index 55de4fac24b27a..2d1094470691bb 100644 --- a/app/models/namespace.rb +++ b/app/models/namespace.rb @@ -739,6 +739,12 @@ def service_desk_alias_address private + def require_organization? + return false unless Feature.enabled?(:require_organization, Feature.current_request) + + Gitlab::SafeRequestStore.fetch(:require_organization) { true } # rubocop:disable Style/RedundantFetchBlock -- This fetch has a different interface + end + def parent_organization_match return unless parent return if parent.organization_id == organization_id diff --git a/app/models/project.rb b/app/models/project.rb index 9e7afa31f76805..89d4f29a38ea95 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -3412,6 +3412,12 @@ def refresh_lfs_file_locks_changed_epoch private + def require_organization? + return false unless Feature.enabled?(:require_organization_on_project, Feature.current_request) + + Gitlab::SafeRequestStore.fetch(:require_organization_on_project) { true } # rubocop:disable Style/RedundantFetchBlock -- This fetch has a different interface + end + def with_redis(&block) Gitlab::Redis::Cache.with(&block) end diff --git a/config/feature_flags/gitlab_com_derisk/require_organization_on_project.yml b/config/feature_flags/gitlab_com_derisk/require_organization_on_project.yml new file mode 100644 index 00000000000000..1e1b82699c4deb --- /dev/null +++ b/config/feature_flags/gitlab_com_derisk/require_organization_on_project.yml @@ -0,0 +1,9 @@ +--- +name: require_organization_on_project +feature_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/501257 +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/TBD +rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/TBD +milestone: '17.6' +group: group::tenant scale +type: gitlab_com_derisk +default_enabled: false diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index b474a74b19de5a..0bbf9bd897ae5b 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -713,7 +713,7 @@ context 'when require_organization feature is disabled' do before do - stub_feature_flags(require_organization: false) + stub_feature_flags(require_organization_on_project: false) end it { is_expected.not_to validate_presence_of(:organization) } -- GitLab From 010bb5658c3fe6972ff09f350dcdd73d47f916d8 Mon Sep 17 00:00:00 2001 From: Rutvik Chandla <rutvik.c@browserstack.com> Date: Tue, 29 Oct 2024 23:42:24 +0530 Subject: [PATCH 2/4] Update MR and rollout link --- .../gitlab_com_derisk/require_organization_on_project.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/feature_flags/gitlab_com_derisk/require_organization_on_project.yml b/config/feature_flags/gitlab_com_derisk/require_organization_on_project.yml index 1e1b82699c4deb..4bcb5da789ae0f 100644 --- a/config/feature_flags/gitlab_com_derisk/require_organization_on_project.yml +++ b/config/feature_flags/gitlab_com_derisk/require_organization_on_project.yml @@ -1,8 +1,8 @@ --- name: require_organization_on_project feature_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/501257 -introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/TBD -rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/TBD +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/171016 +rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/501257 milestone: '17.6' group: group::tenant scale type: gitlab_com_derisk -- GitLab From c71ae0d87cdbd336429554ce32e5d30b11d969ac Mon Sep 17 00:00:00 2001 From: Rutvik Chandla <rutvik.c@browserstack.com> Date: Wed, 30 Oct 2024 22:54:35 +0530 Subject: [PATCH 3/4] Update rollout link and spec description --- .../gitlab_com_derisk/require_organization_on_project.yml | 2 +- spec/models/project_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/feature_flags/gitlab_com_derisk/require_organization_on_project.yml b/config/feature_flags/gitlab_com_derisk/require_organization_on_project.yml index 4bcb5da789ae0f..affac4a1b3f0b9 100644 --- a/config/feature_flags/gitlab_com_derisk/require_organization_on_project.yml +++ b/config/feature_flags/gitlab_com_derisk/require_organization_on_project.yml @@ -2,7 +2,7 @@ name: require_organization_on_project feature_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/501257 introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/171016 -rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/501257 +rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/501373 milestone: '17.6' group: group::tenant scale type: gitlab_com_derisk diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 0bbf9bd897ae5b..f83ce8927f9682 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -711,7 +711,7 @@ it { is_expected.to validate_numericality_of(:max_artifacts_size).only_integer.is_greater_than(0) } it { is_expected.to validate_length_of(:suggestion_commit_message).is_at_most(255) } - context 'when require_organization feature is disabled' do + context 'when require_organization_on_project feature is disabled' do before do stub_feature_flags(require_organization_on_project: false) end -- GitLab From 8433dbda6448fa0e3352d5afa95102011a43e59b Mon Sep 17 00:00:00 2001 From: Rutvik Chandla <rutvik.c@browserstack.com> Date: Thu, 31 Oct 2024 17:01:09 +0530 Subject: [PATCH 4/4] Fix failing UT --- spec/services/resource_access_tokens/create_service_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/services/resource_access_tokens/create_service_spec.rb b/spec/services/resource_access_tokens/create_service_spec.rb index 930cee21499eba..0e62447bb641de 100644 --- a/spec/services/resource_access_tokens/create_service_spec.rb +++ b/spec/services/resource_access_tokens/create_service_spec.rb @@ -422,7 +422,7 @@ context 'when require_organization feature is disabled' do before_all do - stub_feature_flags(require_organization: false) + stub_feature_flags(require_organization_on_project: false) end context 'when resource organization is not set', :enable_admin_mode do -- GitLab