diff options
author | Shinya Maeda <shinya@gitlab.com> | 2018-04-26 10:39:56 +0300 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2018-04-26 10:39:56 +0300 |
commit | 1fb66181db954e529d5da29f747020fac455d14f (patch) | |
tree | a4e55ef1ba7865877ecd0a86a3e1dffdd18072dd /lib/gitlab/ci/trace | |
parent | abde73c0492510a7c6f3d3d412e0971a9df8968d (diff) | |
parent | f819bb7270979cb47a3f5ca97826c9491c983e4d (diff) |
Merge branch 'live-trace-v2' into live-trace-v2-efficient-destroy-all
Diffstat (limited to 'lib/gitlab/ci/trace')
-rw-r--r-- | lib/gitlab/ci/trace/chunked_io.rb | 24 | ||||
-rw-r--r-- | lib/gitlab/ci/trace/stream.rb | 1 |
2 files changed, 12 insertions, 13 deletions
diff --git a/lib/gitlab/ci/trace/chunked_io.rb b/lib/gitlab/ci/trace/chunked_io.rb index 9d4243d152a..1bb8420a220 100644 --- a/lib/gitlab/ci/trace/chunked_io.rb +++ b/lib/gitlab/ci/trace/chunked_io.rb @@ -5,18 +5,18 @@ module Gitlab module Ci class Trace class ChunkedIO - CHUNK_SIZE = ::Ci::JobTraceChunk::CHUNK_SIZE + CHUNK_SIZE = ::Ci::BuildTraceChunk::CHUNK_SIZE FailedToGetChunkError = Class.new(StandardError) - attr_reader :job + attr_reader :build attr_reader :tell, :size attr_reader :chunk, :chunk_range alias_method :pos, :tell - def initialize(job, &block) - @job = job + def initialize(build, &block) + @build = build @chunks_cache = [] @tell = 0 @size = calculate_size @@ -140,10 +140,10 @@ module Gitlab @size = offset # remove all next chunks - job_chunks.where('chunk_index > ?', chunk_index).fast_destroy_all + trace_chunks.where('chunk_index > ?', chunk_index).fast_destroy_all # truncate current chunk - current_chunk.truncate(chunk_offset) if chunk_offset != 0 + current_chunk.truncate(chunk_offset) ensure invalidate_chunk_cache end @@ -157,7 +157,7 @@ module Gitlab end def destroy! - job_chunks.fast_destroy_all + trace_chunks.fast_destroy_all @tell = @size = 0 ensure invalidate_chunk_cache @@ -206,23 +206,23 @@ module Gitlab end def current_chunk - @chunks_cache[chunk_index] ||= job_chunks.find_by(chunk_index: chunk_index) + @chunks_cache[chunk_index] ||= trace_chunks.find_by(chunk_index: chunk_index) end def build_chunk - @chunks_cache[chunk_index] = ::Ci::JobTraceChunk.new(job: job, chunk_index: chunk_index) + @chunks_cache[chunk_index] = ::Ci::BuildTraceChunk.new(build: build, chunk_index: chunk_index) end def ensure_chunk current_chunk || build_chunk end - def job_chunks - ::Ci::JobTraceChunk.where(job: job) + def trace_chunks + ::Ci::BuildTraceChunk.where(build: build) end def calculate_size - job_chunks.order(chunk_index: :desc).first.try(&:end_offset).to_i + trace_chunks.order(chunk_index: :desc).first.try(&:end_offset).to_i end end end diff --git a/lib/gitlab/ci/trace/stream.rb b/lib/gitlab/ci/trace/stream.rb index a71040e5e56..89e36ecbb15 100644 --- a/lib/gitlab/ci/trace/stream.rb +++ b/lib/gitlab/ci/trace/stream.rb @@ -52,7 +52,6 @@ module Gitlab stream.seek(0, IO::SEEK_SET) stream.write(data) - stream.truncate(data.bytesize) stream.flush() end |