Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
42dea18d
Commit
42dea18d
authored
May 27, 2021
by
Thong Kuah
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move LB use_primary! call in worker to Core
parent
7ff1e6f8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
55 deletions
+17
-55
app/workers/authorized_project_update/user_refresh_over_user_range_worker.rb
...zed_project_update/user_refresh_over_user_range_worker.rb
+3
-3
ee/app/workers/ee/authorized_project_update/user_refresh_over_user_range_worker.rb
...zed_project_update/user_refresh_over_user_range_worker.rb
+0
-18
ee/spec/workers/authorized_project_update/user_refresh_over_user_range_worker_spec.rb
...roject_update/user_refresh_over_user_range_worker_spec.rb
+0
-33
spec/workers/authorized_project_update/user_refresh_over_user_range_worker_spec.rb
...roject_update/user_refresh_over_user_range_worker_spec.rb
+14
-1
No files found.
app/workers/authorized_project_update/user_refresh_over_user_range_worker.rb
View file @
42dea18d
...
...
@@ -40,7 +40,9 @@ module AuthorizedProjectUpdate
private
def
use_primary_database
# no-op in CE, overriden in EE
if
::
Gitlab
::
Database
::
LoadBalancing
.
enable?
::
Gitlab
::
Database
::
LoadBalancing
::
Session
.
current
.
use_primary!
end
end
def
project_authorizations_needs_refresh?
(
user
)
...
...
@@ -54,5 +56,3 @@ module AuthorizedProjectUpdate
end
end
end
AuthorizedProjectUpdate
::
UserRefreshOverUserRangeWorker
.
prepend_mod_with
(
'AuthorizedProjectUpdate::UserRefreshOverUserRangeWorker'
)
ee/app/workers/ee/authorized_project_update/user_refresh_over_user_range_worker.rb
deleted
100644 → 0
View file @
7ff1e6f8
# frozen_string_literal: true
module
EE
module
AuthorizedProjectUpdate
module
UserRefreshOverUserRangeWorker
# rubocop:disable Scalability/IdempotentWorker
extend
::
Gitlab
::
Utils
::
Override
private
override
:use_primary_database
def
use_primary_database
if
::
Gitlab
::
Database
::
LoadBalancing
.
enable?
::
Gitlab
::
Database
::
LoadBalancing
::
Session
.
current
.
use_primary!
end
end
end
end
end
ee/spec/workers/authorized_project_update/user_refresh_over_user_range_worker_spec.rb
deleted
100644 → 0
View file @
7ff1e6f8
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
AuthorizedProjectUpdate
::
UserRefreshOverUserRangeWorker
do
let_it_be
(
:project
)
{
create
(
:project
)
}
let
(
:user
)
{
project
.
namespace
.
owner
}
let
(
:start_user_id
)
{
user
.
id
}
let
(
:end_user_id
)
{
start_user_id
}
let
(
:execute_worker
)
{
subject
.
perform
(
start_user_id
,
end_user_id
)
}
describe
'#perform'
do
context
'when the feature flag `periodic_project_authorization_update_via_replica` is disabled'
do
before
do
stub_feature_flags
(
periodic_project_authorization_update_via_replica:
false
)
end
context
'when load balancing is enabled'
do
before
do
allow
(
Gitlab
::
Database
::
LoadBalancing
).
to
receive
(
:enable?
).
and_return
(
true
)
end
it
'reads from the primary database'
do
expect
(
Gitlab
::
Database
::
LoadBalancing
::
Session
.
current
)
.
to
receive
(
:use_primary!
)
execute_worker
end
end
end
end
end
spec/workers/authorized_project_update/user_refresh_over_user_range_worker_spec.rb
View file @
42dea18d
...
...
@@ -3,7 +3,8 @@
require
'spec_helper'
RSpec
.
describe
AuthorizedProjectUpdate
::
UserRefreshOverUserRangeWorker
do
let
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:project
)
{
create
(
:project
)
}
let
(
:user
)
{
project
.
namespace
.
owner
}
let
(
:start_user_id
)
{
user
.
id
}
let
(
:end_user_id
)
{
start_user_id
}
...
...
@@ -64,6 +65,18 @@ RSpec.describe AuthorizedProjectUpdate::UserRefreshOverUserRangeWorker do
execute_worker
end
context
'when load balancing is enabled'
do
before
do
allow
(
Gitlab
::
Database
::
LoadBalancing
).
to
receive
(
:enable?
).
and_return
(
true
)
end
it
'reads from the primary database'
do
expect
(
Gitlab
::
Database
::
LoadBalancing
::
Session
.
current
).
to
receive
(
:use_primary!
)
execute_worker
end
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment