Skip to content
GitLab
Next
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Primary navigation
Search or go to…
Project
GitLab
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Privacy statement
Keyboard shortcuts
?
What's new
4
Snippets
Groups
Projects
Show more breadcrumbs
GitLab.org
GitLab
Commits
42f59d5c
Verified
Commit
42f59d5c
authored
2 years ago
by
Pedro Pombeiro
Browse files
Options
Downloads
Patches
Plain Diff
Address MR review comments
parent
4d333199
No related branches found
No related tags found
1 merge request
!92000
Use Rails cache for Runner releases fetch
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/gitlab/ci/runner_releases.rb
+11
-2
11 additions, 2 deletions
lib/gitlab/ci/runner_releases.rb
spec/lib/gitlab/ci/runner_releases_spec.rb
+12
-0
12 additions, 0 deletions
spec/lib/gitlab/ci/runner_releases_spec.rb
with
23 additions
and
2 deletions
lib/gitlab/ci/runner_releases.rb
+
11
−
2
View file @
42f59d5c
...
...
@@ -58,13 +58,22 @@ def cache_key
end
def
backoff_active?
return
unless
@backoff_expire_time
return
false
unless
@backoff_expire_time
Time
.
now
.
utc
<
@backoff_expire_time
end
def
extract_releases
(
response
)
response
.
parsed_response
.
map
{
|
release
|
parse_runner_release
(
release
)
}.
sort!
return
unless
response
.
parsed_response
.
is_a?
(
Array
)
releases
=
response
.
parsed_response
.
map
{
|
release
|
parse_runner_release
(
release
)
}
.
select
(
&
:valid?
)
.
sort!
return
if
releases
.
empty?
&&
response
.
parsed_response
.
present?
releases
end
def
parse_runner_release
(
release
)
...
...
This diff is collapsed.
Click to expand it.
spec/lib/gitlab/ci/runner_releases_spec.rb
+
12
−
0
View file @
42f59d5c
...
...
@@ -112,6 +112,18 @@ def releases
it_behaves_like
'requests that follow cache status'
,
1
.
day
end
context
'when response contains unexpected input type'
do
let
(
:response
)
{
'error'
}
it
{
expect
(
releases
).
to
be_nil
}
end
context
'when response contains unexpected input array'
do
let
(
:response
)
{
[
'error'
]
}
it
{
expect
(
releases
).
to
be_nil
}
end
end
describe
'#expired?'
,
:use_clean_rails_memory_store_caching
do
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment