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
cffee49f
Commit
cffee49f
authored
Apr 06, 2018
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change Redis TTL to 1day. Fixing nitpicks
parent
aaff5e45
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
14 additions
and
13 deletions
+14
-13
app/models/ci/job_trace_chunk.rb
app/models/ci/job_trace_chunk.rb
+5
-5
lib/api/helpers/runner.rb
lib/api/helpers/runner.rb
+0
-1
lib/gitlab/ci/trace/chunked_io.rb
lib/gitlab/ci/trace/chunked_io.rb
+7
-3
spec/lib/gitlab/ci/trace/chunked_io_spec.rb
spec/lib/gitlab/ci/trace/chunked_io_spec.rb
+1
-3
spec/lib/gitlab/ci/trace/stream_spec.rb
spec/lib/gitlab/ci/trace/stream_spec.rb
+1
-1
No files found.
app/models/ci/job_trace_chunk.rb
View file @
cffee49f
...
...
@@ -9,7 +9,7 @@ module Ci
default_value_for
:data_store
,
:redis
CHUNK_SIZE
=
128
.
kilobytes
CHUNK_REDIS_TTL
=
1
.
month
CHUNK_REDIS_TTL
=
1
.
day
enum
data_store:
{
redis:
1
,
...
...
@@ -27,7 +27,7 @@ module Ci
end
def
set_data
(
value
)
raise
'too much data'
if
value
.
bytesize
>
CHUNK_SIZE
raise
ArgumentError
,
'too much data'
if
value
.
bytesize
>
CHUNK_SIZE
if
redis?
redis_set_data
(
value
)
...
...
@@ -46,9 +46,9 @@ module Ci
end
def
append
(
new_data
,
offset
)
current_data
=
self
.
data
||
""
raise
'Offset is out of bound'
if
offset
>
current_data
.
bytesize
||
offset
<
0
raise
'Outside of chunk size'
if
CHUNK_SIZE
<
offset
+
new_data
.
bytesize
current_data
=
self
.
data
.
to_s
raise
ArgumentError
,
'Offset is out of bound'
if
offset
>
current_data
.
bytesize
||
offset
<
0
raise
ArgumentError
,
'Outside of chunk size'
if
CHUNK_SIZE
<
offset
+
new_data
.
bytesize
self
.
set_data
(
current_data
.
byteslice
(
0
,
offset
)
+
new_data
)
end
...
...
lib/api/helpers/runner.rb
View file @
cffee49f
...
...
@@ -52,7 +52,6 @@ module API
end
def
job_token_valid?
(
job
)
# binding.pry
token
=
(
params
[
JOB_TOKEN_PARAM
]
||
env
[
JOB_TOKEN_HEADER
]).
to_s
token
&&
job
.
valid_token?
(
token
)
end
...
...
lib/gitlab/ci/trace/chunked_io.rb
View file @
cffee49f
...
...
@@ -19,7 +19,7 @@ module Gitlab
@job
=
job
@chunks_cache
=
[]
@tell
=
0
@size
=
job_chunks
.
last
.
try
(
&
:end_offset
).
to_i
@size
=
calculate_size
yield
self
if
block_given?
end
...
...
@@ -48,7 +48,7 @@ module Gitlab
-
1
end
raise
'new position is outside of file'
if
new_pos
<
0
||
new_pos
>
size
raise
ArgumentError
,
'new position is outside of file'
if
new_pos
<
0
||
new_pos
>
size
@tell
=
new_pos
end
...
...
@@ -135,7 +135,7 @@ module Gitlab
end
def
truncate
(
offset
)
raise
'Outside of file'
if
offset
>
size
raise
ArgumentError
,
'Outside of file'
if
offset
>
size
@tell
=
offset
@size
=
offset
...
...
@@ -221,6 +221,10 @@ module Gitlab
def
job_chunks
::
Ci
::
JobTraceChunk
.
where
(
job:
job
)
end
def
calculate_size
job_chunks
.
order
(
chunk_index: :desc
).
last
.
try
(
&
:end_offset
).
to_i
end
end
end
end
...
...
spec/lib/gitlab/ci/trace/chunked_io_spec.rb
View file @
cffee49f
...
...
@@ -334,14 +334,12 @@ describe Gitlab::Ci::Trace::ChunkedIO, :clean_gitlab_redis_cache do
end
context
"#truncate"
do
subject
{
chunked_io
.
truncate
(
offset
)
}
let
(
:offset
)
{
10
}
context
'when data does not exist'
do
shared_examples
'truncates a trace'
do
it
do
subject
chunked_io
.
truncate
(
offset
)
chunked_io
.
seek
(
0
,
IO
::
SEEK_SET
)
expect
(
chunked_io
.
read
).
to
eq
(
sample_trace_raw
.
byteslice
(
0
,
offset
))
...
...
spec/lib/gitlab/ci/trace/stream_spec.rb
View file @
cffee49f
...
...
@@ -116,7 +116,7 @@ describe Gitlab::Ci::Trace::Stream, :clean_gitlab_redis_cache do
end
end
context
'when stream is
StringIO
'
do
context
'when stream is
Tempfile
'
do
let
(
:tempfile
)
{
Tempfile
.
new
}
let
(
:stream
)
do
...
...
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