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
a52eff6c
Commit
a52eff6c
authored
Sep 21, 2017
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent a database update on Geo secondaries
parent
0f4a6d0f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
6 deletions
+27
-6
app/services/keys/last_used_service.rb
app/services/keys/last_used_service.rb
+2
-0
ee/app/services/ee/keys/last_used_service.rb
ee/app/services/ee/keys/last_used_service.rb
+11
-0
spec/ee/spec/services/ee/keys/last_used_service_spec.rb
spec/ee/spec/services/ee/keys/last_used_service_spec.rb
+13
-0
spec/services/keys/last_used_service_spec.rb
spec/services/keys/last_used_service_spec.rb
+1
-6
No files found.
app/services/keys/last_used_service.rb
View file @
a52eff6c
module
Keys
class
LastUsedService
prepend
::
EE
::
Keys
::
LastUsedService
TIMEOUT
=
1
.
day
.
to_i
attr_reader
:key
...
...
ee/app/services/ee/keys/last_used_service.rb
0 → 100644
View file @
a52eff6c
module
EE
module
Keys
module
LastUsedService
def
update?
raise
NotImplementedError
unless
defined?
(
super
)
!::
Gitlab
::
Geo
.
secondary?
&&
super
end
end
end
end
spec/ee/spec/services/ee/keys/last_used_service_spec.rb
0 → 100644
View file @
a52eff6c
require
'spec_helper'
describe
Keys
::
LastUsedService
do
it
'does not run on Geo secondaries'
,
:clean_gitlab_redis_shared_state
do
key
=
create
(
:key
,
last_used_at:
1
.
year
.
ago
)
original_time
=
key
.
last_used_at
allow
(
::
Gitlab
::
Geo
).
to
receive
(
:secondary?
).
and_return
(
true
)
described_class
.
new
(
key
).
execute
expect
(
key
.
reload
.
last_used_at
).
to
be_like_time
(
original_time
)
end
end
spec/services/keys/last_used_service_spec.rb
View file @
a52eff6c
...
...
@@ -26,12 +26,7 @@ describe Keys::LastUsedService do
# make sure we _only_ update last_used_at and not always updated_at.
key
=
create
(
:key
,
last_used_at:
1
.
year
.
ago
)
recorder
=
ActiveRecord
::
QueryRecorder
.
new
do
described_class
.
new
(
key
).
execute
end
expect
(
recorder
.
count
).
to
eq
(
1
)
expect
(
recorder
.
log
[
0
]).
not_to
include
(
'updated_at'
)
expect
{
described_class
.
new
(
key
).
execute
}.
not_to
change
{
key
.
updated_at
}
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