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
26fec9d4
Commit
26fec9d4
authored
Apr 05, 2018
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #read to increament tell correctly
parent
e790cc7a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
12 deletions
+20
-12
app/models/ci/job_trace_chunk.rb
app/models/ci/job_trace_chunk.rb
+1
-1
lib/gitlab/ci/trace/chunked_io.rb
lib/gitlab/ci/trace/chunked_io.rb
+19
-11
No files found.
app/models/ci/job_trace_chunk.rb
View file @
26fec9d4
...
@@ -8,7 +8,7 @@ module Ci
...
@@ -8,7 +8,7 @@ module Ci
default_value_for
:data_store
,
:redis
default_value_for
:data_store
,
:redis
CHUNK_SIZE
=
8
CHUNK_SIZE
=
32
.
kilobytes
CHUNK_REDIS_TTL
=
1
.
month
CHUNK_REDIS_TTL
=
1
.
month
enum
data_store:
{
enum
data_store:
{
...
...
lib/gitlab/ci/trace/chunked_io.rb
View file @
26fec9d4
...
@@ -15,11 +15,12 @@ module Gitlab
...
@@ -15,11 +15,12 @@ module Gitlab
alias_method
:pos
,
:tell
alias_method
:pos
,
:tell
def
initialize
(
job
)
def
initialize
(
job
,
&
block
)
@job
=
job
@job
=
job
@chunks_cache
=
[]
@chunks_cache
=
[]
@tell
=
0
@tell
=
0
@size
=
job_chunks
.
last
.
try
(
&
:end_offset
).
to_i
@size
=
job_chunks
.
last
.
try
(
&
:end_offset
).
to_i
yield
self
if
block_given?
end
end
def
close
def
close
...
@@ -73,18 +74,25 @@ module Gitlab
...
@@ -73,18 +74,25 @@ module Gitlab
end
end
end
end
def
read
(
length
=
nil
)
def
read
(
length
=
(
size
-
tell
),
outbuf
=
""
)
out
=
""
out
=
""
end_tell
=
[
tell
+
length
,
size
].
min
until
e
of?
||
(
length
&&
out
.
length
>=
length
)
until
e
nd_tell
<=
tell
data
=
chunk_slice_from_offset
data
=
chunk_slice_from_offset
break
if
data
.
empty?
break
if
data
.
empty?
data
=
data
[
0
,
(
length
%
CHUNK_SIZE
)]
if
data
.
bytesize
+
tell
>=
end_tell
out
<<
data
out
<<
data
@tell
+=
data
.
bytesize
@tell
+=
data
.
bytesize
end
end
out
=
out
[
0
,
length
]
if
length
&&
out
.
length
>
length
# TODO: If we support `IO::copy_stream`, outbuf must be handled properly
# if outbuf
# outbuf.slice!(/.*/)
# outbuf << out
# end
out
out
end
end
...
@@ -110,19 +118,19 @@ module Gitlab
...
@@ -110,19 +118,19 @@ module Gitlab
end
end
def
write
(
data
)
def
write
(
data
)
start_pos
=
@
tell
start_pos
=
tell
while
@
tell
<
start_pos
+
data
.
bytesize
while
tell
<
start_pos
+
data
.
bytesize
# get slice from current offset till the end where it falls into chunk
# get slice from current offset till the end where it falls into chunk
chunk_bytes
=
CHUNK_SIZE
-
chunk_offset
chunk_bytes
=
CHUNK_SIZE
-
chunk_offset
chunk_data
=
data
.
byteslice
(
@
tell
-
start_pos
,
chunk_bytes
)
chunk_data
=
data
.
byteslice
(
tell
-
start_pos
,
chunk_bytes
)
# append data to chunk, overwriting from that point
# append data to chunk, overwriting from that point
ensure_chunk
.
append
(
chunk_data
,
chunk_offset
)
ensure_chunk
.
append
(
chunk_data
,
chunk_offset
)
# move offsets within buffer
# move offsets within buffer
@tell
+=
chunk_bytes
@tell
+=
chunk_bytes
@size
=
[
@size
,
@
tell
].
max
@size
=
[
size
,
tell
].
max
end
end
end
end
...
@@ -172,7 +180,7 @@ module Gitlab
...
@@ -172,7 +180,7 @@ module Gitlab
end
end
end
end
@chunk
.
byteslice
(
chunk_offset
,
CHUNK_SIZE
)
@chunk
[
chunk_offset
..
CHUNK_SIZE
]
end
end
def
chunk_offset
def
chunk_offset
...
@@ -200,7 +208,7 @@ module Gitlab
...
@@ -200,7 +208,7 @@ module Gitlab
end
end
def
build_chunk
def
build_chunk
@chunks_cache
[
chunk_index
]
=
Ci
::
JobTraceChunk
.
new
(
job:
job
,
chunk_index:
chunk_index
)
@chunks_cache
[
chunk_index
]
=
::
Ci
::
JobTraceChunk
.
new
(
job:
job
,
chunk_index:
chunk_index
)
end
end
def
ensure_chunk
def
ensure_chunk
...
@@ -208,7 +216,7 @@ module Gitlab
...
@@ -208,7 +216,7 @@ module Gitlab
end
end
def
job_chunks
def
job_chunks
Ci
::
JobTraceChunk
.
where
(
job:
job
)
::
Ci
::
JobTraceChunk
.
where
(
job:
job
)
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