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
40644815
Commit
40644815
authored
Jun 01, 2018
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename find_stale_in_batches to find_builds_from_stale_live_trace. Fix comments
parent
2522691e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
14 deletions
+12
-14
app/models/ci/build_trace_chunk.rb
app/models/ci/build_trace_chunk.rb
+2
-2
app/workers/ci/rescue_stale_live_trace_worker.rb
app/workers/ci/rescue_stale_live_trace_worker.rb
+4
-6
spec/models/ci/build_trace_chunk_spec.rb
spec/models/ci/build_trace_chunk_spec.rb
+6
-6
No files found.
app/models/ci/build_trace_chunk.rb
View file @
40644815
...
@@ -52,13 +52,13 @@ module Ci
...
@@ -52,13 +52,13 @@ module Ci
end
end
# Find stale live traces and return their build ids
# Find stale live traces and return their build ids
def
find_
stale_in_batches
(
finished_before:
1
.
hour
.
ago
)
def
find_
builds_from_stale_live_trace
include
(
EachBatch
)
include
(
EachBatch
)
.
select
(
:build_id
)
.
select
(
:build_id
)
.
group
(
:build_id
)
.
group
(
:build_id
)
.
joins
(
:build
)
.
joins
(
:build
)
.
merge
(
Ci
::
Build
.
finished
)
.
merge
(
Ci
::
Build
.
finished
)
.
where
(
'ci_builds.finished_at < ?'
,
finished_before
)
.
where
(
'ci_builds.finished_at < ?'
,
1
.
hour
.
ago
)
.
each_batch
(
column: :build_id
)
do
|
chunks
|
.
each_batch
(
column: :build_id
)
do
|
chunks
|
build_ids
=
chunks
.
map
{
|
chunk
|
chunk
.
build_id
}
build_ids
=
chunks
.
map
{
|
chunk
|
chunk
.
build_id
}
...
...
app/workers/ci/rescue_stale_live_trace_worker.rb
View file @
40644815
...
@@ -4,12 +4,10 @@ module Ci
...
@@ -4,12 +4,10 @@ module Ci
include
CronjobQueue
include
CronjobQueue
def
perform
def
perform
# Reschedule to archive live traces
# Archive live traces which still resides in redis or database
#
# This could happen when sidekiq-jobs for archivements are lost by SIGKILL
# The targets are jobs with the following conditions
# Issue: https://gitlab.com/gitlab-org/gitlab-ce/issues/36791
# - Jobs had been finished 1 hour ago, but they don't have an archived trace yet
Ci
::
BuildTraceChunk
.
find_builds_from_stale_live_trace
do
|
build_ids
|
# This could happen when their sidekiq-jobs are lost by SIGKILL
Ci
::
BuildTraceChunk
.
find_stale_in_batches
(
finished_before:
1
.
hour
.
ago
)
do
|
build_ids
|
Ci
::
Build
.
where
(
id:
build_ids
).
find_each
do
|
build
|
Ci
::
Build
.
where
(
id:
build_ids
).
find_each
do
|
build
|
begin
begin
build
.
trace
.
archive!
build
.
trace
.
archive!
...
...
spec/models/ci/build_trace_chunk_spec.rb
View file @
40644815
...
@@ -35,8 +35,8 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
...
@@ -35,8 +35,8 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
end
end
end
end
describe
'.find_
stale_in_batches
'
do
describe
'.find_
builds_from_stale_live_trace
'
do
subject
{
described_class
.
find_
stale_in_batches
}
subject
{
described_class
.
find_
builds_from_stale_live_trace
}
context
'when build status is finished'
do
context
'when build status is finished'
do
context
'when build finished 2 days ago'
do
context
'when build finished 2 days ago'
do
...
@@ -44,7 +44,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
...
@@ -44,7 +44,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
let!
(
:build
)
{
create
(
:ci_build
,
:success
,
:trace_artifact
,
finished_at:
2
.
days
.
ago
)
}
let!
(
:build
)
{
create
(
:ci_build
,
:success
,
:trace_artifact
,
finished_at:
2
.
days
.
ago
)
}
it
'does not yield build id'
do
it
'does not yield build id'
do
expect
{
|
b
|
described_class
.
find_
stale_in_batches
(
&
b
)
}.
not_to
yield_control
expect
{
|
b
|
described_class
.
find_
builds_from_stale_live_trace
(
&
b
)
}.
not_to
yield_control
end
end
end
end
...
@@ -52,7 +52,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
...
@@ -52,7 +52,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
let!
(
:build
)
{
create
(
:ci_build
,
:success
,
:trace_live
,
finished_at:
2
.
days
.
ago
)
}
let!
(
:build
)
{
create
(
:ci_build
,
:success
,
:trace_live
,
finished_at:
2
.
days
.
ago
)
}
it
'yields build id'
do
it
'yields build id'
do
expect
{
|
b
|
described_class
.
find_
stale_in_batches
(
&
b
)
}.
to
yield_with_args
([
build
.
id
])
expect
{
|
b
|
described_class
.
find_
builds_from_stale_live_trace
(
&
b
)
}.
to
yield_with_args
([
build
.
id
])
end
end
end
end
end
end
...
@@ -61,7 +61,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
...
@@ -61,7 +61,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
let!
(
:build
)
{
create
(
:ci_build
,
:success
,
:trace_live
,
finished_at:
10
.
minutes
.
ago
)
}
let!
(
:build
)
{
create
(
:ci_build
,
:success
,
:trace_live
,
finished_at:
10
.
minutes
.
ago
)
}
it
'does not yield build id'
do
it
'does not yield build id'
do
expect
{
|
b
|
described_class
.
find_
stale_in_batches
(
&
b
)
}.
not_to
yield_control
expect
{
|
b
|
described_class
.
find_
builds_from_stale_live_trace
(
&
b
)
}.
not_to
yield_control
end
end
end
end
end
end
...
@@ -70,7 +70,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
...
@@ -70,7 +70,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
let!
(
:build
)
{
create
(
:ci_build
,
:running
,
:trace_live
)
}
let!
(
:build
)
{
create
(
:ci_build
,
:running
,
:trace_live
)
}
it
'does not yield build id'
do
it
'does not yield build id'
do
expect
{
|
b
|
described_class
.
find_
stale_in_batches
(
&
b
)
}.
not_to
yield_control
expect
{
|
b
|
described_class
.
find_
builds_from_stale_live_trace
(
&
b
)
}.
not_to
yield_control
end
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