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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
36fbe142
Commit
36fbe142
authored
May 28, 2018
by
Kamil Trzciński
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not validate cached data
parent
3571b97e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
12 deletions
+25
-12
app/models/ci/runner.rb
app/models/ci/runner.rb
+2
-4
changelogs/unreleased/optimise-runner-update-cached-info.yml
changelogs/unreleased/optimise-runner-update-cached-info.yml
+5
-0
spec/models/ci/runner_spec.rb
spec/models/ci/runner_spec.rb
+18
-8
No files found.
app/models/ci/runner.rb
View file @
36fbe142
...
...
@@ -219,10 +219,8 @@ module Ci
cache_attributes
(
values
)
if
persist_cached_data?
self
.
assign_attributes
(
values
)
self
.
save
if
self
.
changed?
end
# We save data without validation, it will always change due to `contacted_at`
self
.
update_columns
(
values
)
if
persist_cached_data?
end
def
pick_build!
(
build
)
...
...
changelogs/unreleased/optimise-runner-update-cached-info.yml
0 → 100644
View file @
36fbe142
---
title
:
Update runner cached informations without performing validations
merge_request
:
author
:
type
:
performance
spec/models/ci/runner_spec.rb
View file @
36fbe142
...
...
@@ -549,7 +549,7 @@ describe Ci::Runner do
end
describe
'#update_cached_info'
do
let
(
:runner
)
{
create
(
:ci_runner
)
}
let
(
:runner
)
{
create
(
:ci_runner
,
:project
)
}
subject
{
runner
.
update_cached_info
(
architecture:
'18-bit'
)
}
...
...
@@ -570,17 +570,22 @@ describe Ci::Runner do
runner
.
contacted_at
=
2
.
hours
.
ago
end
it
'updates database'
do
expect_redis_update
context
'with invalid runner'
do
before
do
runner
.
projects
=
[]
end
it
'still updates redis cache and database'
do
expect
(
runner
).
to
be_invalid
expect
{
subject
}.
to
change
{
runner
.
reload
.
read_attribute
(
:contacted_at
)
}
.
and
change
{
runner
.
reload
.
read_attribute
(
:architecture
)
}
expect_redis_update
does_db_update
end
end
it
'updates
cach
e'
do
it
'updates
redis cache and databas
e'
do
expect_redis_update
subject
does_db_update
end
end
...
...
@@ -590,6 +595,11 @@ describe Ci::Runner do
expect
(
redis
).
to
receive
(
:set
).
with
(
redis_key
,
anything
,
any_args
)
end
end
def
does_db_update
expect
{
subject
}.
to
change
{
runner
.
reload
.
read_attribute
(
:contacted_at
)
}
.
and
change
{
runner
.
reload
.
read_attribute
(
:architecture
)
}
end
end
describe
'#destroy'
do
...
...
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