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
Tatuya Kamada
gitlab-ce
Commits
dd29283a
Commit
dd29283a
authored
Apr 09, 2016
by
Tomasz Maczukin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure that appending is done on a valid length
parent
360bd831
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
6 deletions
+17
-6
app/models/ci/build.rb
app/models/ci/build.rb
+5
-4
lib/ci/api/builds.rb
lib/ci/api/builds.rb
+11
-1
spec/requests/ci/api/builds_spec.rb
spec/requests/ci/api/builds_spec.rb
+1
-1
No files found.
app/models/ci/build.rb
View file @
dd29283a
...
@@ -231,10 +231,10 @@ module Ci
...
@@ -231,10 +231,10 @@ module Ci
end
end
def
trace_length
def
trace_length
unless
trace
.
present?
if
raw_trace
0
raw_trace
.
length
else
else
trace
.
length
0
end
end
end
end
...
@@ -250,9 +250,10 @@ module Ci
...
@@ -250,9 +250,10 @@ module Ci
end
end
private
:recreate_trace_dir
private
:recreate_trace_dir
def
append_trace
(
trace_part
)
def
append_trace
(
trace_part
,
offset
)
recreate_trace_dir
recreate_trace_dir
File
.
truncate
(
path_to_trace
,
offset
)
File
.
open
(
path_to_trace
,
'a'
)
do
|
f
|
File
.
open
(
path_to_trace
,
'a'
)
do
|
f
|
f
.
write
(
trace_part
)
f
.
write
(
trace_part
)
end
end
...
...
lib/ci/api/builds.rb
View file @
dd29283a
...
@@ -50,6 +50,16 @@ module Ci
...
@@ -50,6 +50,16 @@ module Ci
end
end
end
end
# Send incremental log update - Runners only
#
# Parameters:
# id (required) - The ID of a build
# Body:
# content of logs to append
# Headers:
# Content-Range: range of conntent that was sent
# Example Request:
# PATCH /builds/:id/trace.txt
patch
":id/trace.txt"
do
patch
":id/trace.txt"
do
build
=
Ci
::
Build
.
find_by_id
(
params
[
:id
])
build
=
Ci
::
Build
.
find_by_id
(
params
[
:id
])
not_found!
unless
build
not_found!
unless
build
...
@@ -64,7 +74,7 @@ module Ci
...
@@ -64,7 +74,7 @@ module Ci
return
error!
(
'416 Range Not Satisfiable'
,
416
,
{
'Range'
=>
"0-
#{
build
.
trace_length
}
"
})
return
error!
(
'416 Range Not Satisfiable'
,
416
,
{
'Range'
=>
"0-
#{
build
.
trace_length
}
"
})
end
end
build
.
append_trace
(
request
.
body
.
read
)
build
.
append_trace
(
request
.
body
.
read
,
content_range
[
0
].
to_i
)
status
202
status
202
header
'Build-Status'
,
build
.
status
header
'Build-Status'
,
build
.
status
...
...
spec/requests/ci/api/builds_spec.rb
View file @
dd29283a
...
@@ -195,7 +195,7 @@ describe Ci::API::API do
...
@@ -195,7 +195,7 @@ describe Ci::API::API do
it
{
expect
(
response
.
status
).
to
eq
400
}
it
{
expect
(
response
.
status
).
to
eq
400
}
end
end
context
'when build has been erased'
do
context
'when build has been er
r
ased'
do
let
(
:build
)
{
create
(
:ci_build
,
runner_id:
runner
.
id
,
erased_at:
Time
.
now
)
}
let
(
:build
)
{
create
(
:ci_build
,
runner_id:
runner
.
id
,
erased_at:
Time
.
now
)
}
it
{
expect
(
response
.
status
).
to
eq
403
}
it
{
expect
(
response
.
status
).
to
eq
403
}
...
...
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