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
1667b65c
Commit
1667b65c
authored
Jul 06, 2018
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use AlreadyArchivedError if it's the case
parent
9c9bb49b
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
8 deletions
+8
-8
app/workers/ci/archive_traces_cron_worker.rb
app/workers/ci/archive_traces_cron_worker.rb
+1
-2
lib/gitlab/ci/trace.rb
lib/gitlab/ci/trace.rb
+3
-3
spec/requests/api/runner_spec.rb
spec/requests/api/runner_spec.rb
+1
-0
spec/support/shared_examples/ci_trace_shared_examples.rb
spec/support/shared_examples/ci_trace_shared_examples.rb
+3
-3
No files found.
app/workers/ci/archive_traces_cron_worker.rb
View file @
1667b65c
...
@@ -12,9 +12,8 @@ module Ci
...
@@ -12,9 +12,8 @@ module Ci
Ci
::
Build
.
finished
.
with_live_trace
.
find_each
(
batch_size:
100
)
do
|
build
|
Ci
::
Build
.
finished
.
with_live_trace
.
find_each
(
batch_size:
100
)
do
|
build
|
begin
begin
build
.
trace
.
archive!
build
.
trace
.
archive!
rescue
::
Gitlab
::
Ci
::
Trace
::
AlreadyArchivedError
rescue
=>
e
rescue
=>
e
next
if
e
.
message
.
include?
(
'Already archived'
)
failed_archive_counter
.
increment
failed_archive_counter
.
increment
Rails
.
logger
.
error
"Failed to archive stale live trace. id:
#{
build
.
id
}
message:
#{
e
.
message
}
"
Rails
.
logger
.
error
"Failed to archive stale live trace. id:
#{
build
.
id
}
message:
#{
e
.
message
}
"
end
end
...
...
lib/gitlab/ci/trace.rb
View file @
1667b65c
...
@@ -6,7 +6,7 @@ module Gitlab
...
@@ -6,7 +6,7 @@ module Gitlab
LEASE_TIMEOUT
=
1
.
hour
LEASE_TIMEOUT
=
1
.
hour
ArchiveError
=
Class
.
new
(
StandardError
)
ArchiveError
=
Class
.
new
(
StandardError
)
Write
Error
=
Class
.
new
(
StandardError
)
AlreadyArchived
Error
=
Class
.
new
(
StandardError
)
attr_reader
:job
attr_reader
:job
...
@@ -83,7 +83,7 @@ module Gitlab
...
@@ -83,7 +83,7 @@ module Gitlab
def
write
(
mode
)
def
write
(
mode
)
stream
=
Gitlab
::
Ci
::
Trace
::
Stream
.
new
do
stream
=
Gitlab
::
Ci
::
Trace
::
Stream
.
new
do
if
trace_artifact
if
trace_artifact
raise
WriteError
,
'Already archived
'
raise
AlreadyArchivedError
,
'Could not write to the archived trace
'
elsif
current_path
elsif
current_path
File
.
open
(
current_path
,
mode
)
File
.
open
(
current_path
,
mode
)
elsif
Feature
.
enabled?
(
'ci_enable_live_trace'
)
elsif
Feature
.
enabled?
(
'ci_enable_live_trace'
)
...
@@ -120,7 +120,7 @@ module Gitlab
...
@@ -120,7 +120,7 @@ module Gitlab
private
private
def
unsafe_archive!
def
unsafe_archive!
raise
A
rchiveError
,
'Already archived
'
if
trace_artifact
raise
A
lreadyArchivedError
,
'Could not archive again
'
if
trace_artifact
raise
ArchiveError
,
'Job is not finished yet'
unless
job
.
complete?
raise
ArchiveError
,
'Job is not finished yet'
unless
job
.
complete?
if
job
.
trace_chunks
.
any?
if
job
.
trace_chunks
.
any?
...
...
spec/requests/api/runner_spec.rb
View file @
1667b65c
...
@@ -851,6 +851,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
...
@@ -851,6 +851,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
it
'does not update job status and job trace'
do
it
'does not update job status and job trace'
do
update_job
(
state:
'success'
,
trace:
'BUILD TRACE UPDATED'
)
update_job
(
state:
'success'
,
trace:
'BUILD TRACE UPDATED'
)
job
.
reload
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
expect
(
response
.
header
[
'Job-Status'
]).
to
eq
'failed'
expect
(
response
.
header
[
'Job-Status'
]).
to
eq
'failed'
expect
(
job
.
trace
.
raw
).
to
eq
'Job failed'
expect
(
job
.
trace
.
raw
).
to
eq
'Job failed'
...
...
spec/support/shared_examples/ci_trace_shared_examples.rb
View file @
1667b65c
...
@@ -155,7 +155,7 @@ shared_examples_for 'common trace features' do
...
@@ -155,7 +155,7 @@ shared_examples_for 'common trace features' do
end
end
it
'raises an error'
do
it
'raises an error'
do
expect
{
subject
}.
to
raise_error
(
'Already archived'
)
expect
{
subject
}.
to
raise_error
(
Gitlab
::
Ci
::
Trace
::
AlreadyArchivedError
)
end
end
end
end
end
end
...
@@ -596,7 +596,7 @@ shared_examples_for 'trace with disabled live trace feature' do
...
@@ -596,7 +596,7 @@ shared_examples_for 'trace with disabled live trace feature' do
it
'does not archive'
do
it
'does not archive'
do
expect_any_instance_of
(
described_class
).
not_to
receive
(
:archive_stream!
)
expect_any_instance_of
(
described_class
).
not_to
receive
(
:archive_stream!
)
expect
{
subject
}.
to
raise_error
(
'Already archived'
)
expect
{
subject
}.
to
raise_error
(
Gitlab
::
Ci
::
Trace
::
AlreadyArchivedError
)
expect
(
build
.
job_artifacts_trace
.
file
.
exists?
).
to
be_truthy
expect
(
build
.
job_artifacts_trace
.
file
.
exists?
).
to
be_truthy
end
end
end
end
...
@@ -783,7 +783,7 @@ shared_examples_for 'trace with enabled live trace feature' do
...
@@ -783,7 +783,7 @@ shared_examples_for 'trace with enabled live trace feature' do
it
'does not archive'
do
it
'does not archive'
do
expect_any_instance_of
(
described_class
).
not_to
receive
(
:archive_stream!
)
expect_any_instance_of
(
described_class
).
not_to
receive
(
:archive_stream!
)
expect
{
subject
}.
to
raise_error
(
'Already archived'
)
expect
{
subject
}.
to
raise_error
(
Gitlab
::
Ci
::
Trace
::
AlreadyArchivedError
)
expect
(
build
.
job_artifacts_trace
.
file
.
exists?
).
to
be_truthy
expect
(
build
.
job_artifacts_trace
.
file
.
exists?
).
to
be_truthy
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