Commit fa1d31ee authored by Manoj M J's avatar Manoj M J Committed by Douglas Barbosa Alexandre

Use specialized worker to refresh authorizations on group-share update

With this change, we will be using a specialized
worker to refresh authorizations whenever a
project-group share is updated.

Changelog: performance
parent afdec687
...@@ -20,7 +20,6 @@ module Projects ...@@ -20,7 +20,6 @@ module Projects
attr_reader :group_link attr_reader :group_link
def refresh_authorizations def refresh_authorizations
if Feature.enabled?(:specialized_worker_for_project_share_update_auth_recalculation)
AuthorizedProjectUpdate::ProjectRecalculateWorker.perform_async(project.id) AuthorizedProjectUpdate::ProjectRecalculateWorker.perform_async(project.id)
# Until we compare the inconsistency rates of the new specialized worker and # Until we compare the inconsistency rates of the new specialized worker and
...@@ -30,9 +29,6 @@ module Projects ...@@ -30,9 +29,6 @@ module Projects
blocking: false, blocking: false,
priority: UserProjectAccessChangedService::LOW_PRIORITY priority: UserProjectAccessChangedService::LOW_PRIORITY
) )
else
group_link.group.refresh_members_authorized_projects
end
end end
def requires_authorization_refresh?(params) def requires_authorization_refresh?(params)
......
---
name: specialized_worker_for_project_share_update_auth_recalculation
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/61964
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/334234
milestone: '14.1'
type: development
group: group::access
default_enabled: false
...@@ -34,11 +34,6 @@ RSpec.describe Projects::GroupLinks::UpdateService, '#execute' do ...@@ -34,11 +34,6 @@ RSpec.describe Projects::GroupLinks::UpdateService, '#execute' do
end end
context 'project authorizations update' do context 'project authorizations update' do
context 'when the feature flag `specialized_worker_for_project_share_update_auth_recalculation` is enabled' do
before do
stub_feature_flags(specialized_worker_for_project_share_update_auth_recalculation: true)
end
it 'calls AuthorizedProjectUpdate::ProjectRecalculateWorker to update project authorizations' do it 'calls AuthorizedProjectUpdate::ProjectRecalculateWorker to update project authorizations' do
expect(AuthorizedProjectUpdate::ProjectRecalculateWorker) expect(AuthorizedProjectUpdate::ProjectRecalculateWorker)
.to receive(:perform_async).with(link.project.id) .to receive(:perform_async).with(link.project.id)
...@@ -66,54 +61,13 @@ RSpec.describe Projects::GroupLinks::UpdateService, '#execute' do ...@@ -66,54 +61,13 @@ RSpec.describe Projects::GroupLinks::UpdateService, '#execute' do
end end
end end
context 'when the feature flag `specialized_worker_for_project_share_update_auth_recalculation` is disabled' do
before do
stub_feature_flags(specialized_worker_for_project_share_update_auth_recalculation: false)
end
it 'calls UserProjectAccessChangedService to update project authorizations' do
expect_next_instance_of(UserProjectAccessChangedService, [user.id]) do |service|
expect(service).to receive(:execute)
end
subject
end
it 'updates project authorizations of users who had access to the project via the group share' do
group.add_maintainer(user)
expect { subject }.to(
change { Ability.allowed?(user, :create_release, project) }
.from(true).to(false))
end
end
end
context 'with only param not requiring authorization refresh' do context 'with only param not requiring authorization refresh' do
let(:group_link_params) { { expires_at: Date.tomorrow } } let(:group_link_params) { { expires_at: Date.tomorrow } }
context 'when the feature flag `specialized_worker_for_project_share_update_auth_recalculation` is enabled' do
before do
stub_feature_flags(specialized_worker_for_project_share_update_auth_recalculation: true)
end
it 'does not perform any project authorizations update using `AuthorizedProjectUpdate::ProjectRecalculateWorker`' do it 'does not perform any project authorizations update using `AuthorizedProjectUpdate::ProjectRecalculateWorker`' do
expect(AuthorizedProjectUpdate::ProjectRecalculateWorker).not_to receive(:perform_async) expect(AuthorizedProjectUpdate::ProjectRecalculateWorker).not_to receive(:perform_async)
subject subject
end end
end end
context 'when the feature flag `specialized_worker_for_project_share_update_auth_recalculation` is disabled' do
before do
stub_feature_flags(specialized_worker_for_project_share_update_auth_recalculation: false)
end
it 'does not perform any project authorizations update using `UserProjectAccessChangedService`' do
expect(UserProjectAccessChangedService).not_to receive(:new)
subject
end
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