Commit c3d04cdc authored by Andy Soiron's avatar Andy Soiron

Merge branch...

Merge branch '331073-feature-flag-rollout-of-use_specialized_worker_for_project_auth_recalculation' into 'master'

Use specialized worker to refresh authorizations on group share removal by default

See merge request gitlab-org/gitlab!69739
parents 9b04d9a5 0a82b838
...@@ -13,19 +13,15 @@ module Projects ...@@ -13,19 +13,15 @@ module Projects
end end
group_link.destroy.tap do |link| group_link.destroy.tap do |link|
if Feature.enabled?(:use_specialized_worker_for_project_auth_recalculation) refresh_project_authorizations_asynchronously(link.project)
refresh_project_authorizations_asynchronously(link.project)
# Until we compare the inconsistency rates of the new specialized worker and # Until we compare the inconsistency rates of the new specialized worker and
# the old approach, we still run AuthorizedProjectsWorker # the old approach, we still run AuthorizedProjectsWorker
# but with some delay and lower urgency as a safety net. # but with some delay and lower urgency as a safety net.
link.group.refresh_members_authorized_projects( link.group.refresh_members_authorized_projects(
blocking: false, blocking: false,
priority: UserProjectAccessChangedService::LOW_PRIORITY priority: UserProjectAccessChangedService::LOW_PRIORITY
) )
else
link.group.refresh_members_authorized_projects
end
end end
end end
......
---
name: use_specialized_worker_for_project_auth_recalculation
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/60904
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/331073
milestone: '14.0'
type: development
group: group::access
default_enabled: false
...@@ -20,54 +20,28 @@ RSpec.describe Projects::GroupLinks::DestroyService, '#execute' do ...@@ -20,54 +20,28 @@ RSpec.describe Projects::GroupLinks::DestroyService, '#execute' do
group.add_maintainer(user) group.add_maintainer(user)
end end
context 'when the feature flag `use_specialized_worker_for_project_auth_recalculation` is enabled' do it 'calls AuthorizedProjectUpdate::ProjectRecalculateWorker to update project authorizations' do
before do expect(AuthorizedProjectUpdate::ProjectRecalculateWorker)
stub_feature_flags(use_specialized_worker_for_project_auth_recalculation: true) .to receive(:perform_async).with(group_link.project.id)
end
it 'calls AuthorizedProjectUpdate::ProjectRecalculateWorker to update project authorizations' do
expect(AuthorizedProjectUpdate::ProjectRecalculateWorker)
.to receive(:perform_async).with(group_link.project.id)
subject.execute(group_link)
end
it 'calls AuthorizedProjectUpdate::UserRefreshFromReplicaWorker with a delay to update project authorizations' do
expect(AuthorizedProjectUpdate::UserRefreshFromReplicaWorker).to(
receive(:bulk_perform_in)
.with(1.hour,
[[user.id]],
batch_delay: 30.seconds, batch_size: 100)
)
subject.execute(group_link)
end
it 'updates project authorizations of users who had access to the project via the group share', :sidekiq_inline do subject.execute(group_link)
expect { subject.execute(group_link) }.to(
change { Ability.allowed?(user, :read_project, project) }
.from(true).to(false))
end
end end
context 'when the feature flag `use_specialized_worker_for_project_auth_recalculation` is disabled' do it 'calls AuthorizedProjectUpdate::UserRefreshFromReplicaWorker with a delay to update project authorizations' do
before do expect(AuthorizedProjectUpdate::UserRefreshFromReplicaWorker).to(
stub_feature_flags(use_specialized_worker_for_project_auth_recalculation: false) receive(:bulk_perform_in)
end .with(1.hour,
[[user.id]],
it 'calls UserProjectAccessChangedService to update project authorizations' do batch_delay: 30.seconds, batch_size: 100)
expect_next_instance_of(UserProjectAccessChangedService, [user.id]) do |service| )
expect(service).to receive(:execute)
end
subject.execute(group_link) subject.execute(group_link)
end end
it 'updates project authorizations of users who had access to the project via the group share' do it 'updates project authorizations of users who had access to the project via the group share', :sidekiq_inline do
expect { subject.execute(group_link) }.to( expect { subject.execute(group_link) }.to(
change { Ability.allowed?(user, :read_project, project) } change { Ability.allowed?(user, :read_project, project) }
.from(true).to(false)) .from(true).to(false))
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