summaryrefslogtreecommitdiff
path: root/app/models/ci
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2016-09-21 16:12:32 +0800
committerLin Jen-Shin <godfat@godfat.org>2016-09-21 16:12:32 +0800
commit63e03dada7e754a92ca088c683f4189424ab34b1 (patch)
treeb1fa43c9dbf6bffd05c42eced7c943bcc6f3cfd7 /app/models/ci
parent5869fb201459f0e44c4544076758e02299fa9227 (diff)
downloadgitlab-ce-63e03dada7e754a92ca088c683f4189424ab34b1.tar.gz
Make various trace methods take last_lines argument:
So that we could read last few lines rather than read the entire file which could be huge.
Diffstat (limited to 'app/models/ci')
-rw-r--r--app/models/ci/build.rb20
1 files changed, 11 insertions, 9 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index f9aa1984c1f..13f101cbecb 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -128,13 +128,14 @@ module Ci
latest_builds.where('stage_idx < ?', stage_idx)
end
- def trace_html
- trace_with_state[:html] || ''
+ def trace_html(**args)
+ trace_with_state(**args)[:html] || ''
end
- def trace_with_state(state = nil)
- if trace.present?
- Ci::Ansi2html.convert(trace, state)
+ def trace_with_state(state: nil, last_lines: nil)
+ trace_ansi = trace(last_lines)
+ if trace_ansi.present?
+ Ci::Ansi2html.convert(trace_ansi, state)
else
{}
end
@@ -220,9 +221,10 @@ module Ci
raw_trace.present?
end
- def raw_trace
+ def raw_trace(last_lines: nil)
if File.exist?(trace_file_path)
- File.read(trace_file_path)
+ Gitlab::Ci::TraceReader.new(trace_file_path).
+ read(last_lines: last_lines)
else
# backward compatibility
read_attribute :trace
@@ -237,8 +239,8 @@ module Ci
project.ci_id && File.exist?(old_path_to_trace)
end
- def trace
- result = raw_trace
+ def trace(last_lines: nil)
+ result = raw_trace(last_lines)
if project && result.present? && project.runners_token.present?
result.gsub(project.runners_token, 'xxxxxx')
else