summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2016-09-02 14:31:46 +0000
committerDouwe Maan <douwe@gitlab.com>2016-09-02 14:31:46 +0000
commitece30b70ca3545e396963974aa0f27f37512bf97 (patch)
tree5ba2485156bfbf403a8118bade9fd663f74ea4e9 /app/models
parent4d07696aabac5fe920b9358816a4776b3fddb43a (diff)
parent52fe6098861bf36601be6555d2b39f366795ddd3 (diff)
downloadgitlab-ce-ece30b70ca3545e396963974aa0f27f37512bf97.tar.gz
Merge branch 'fix/handle-raw-trace-error-on-old-builds' into 'master'
Handle error on trace raw download with old builds (DB stored) ## What does this MR do? Handles error on `raw build trace` download action for old builds (which are stored in DB instead of file). ## Are there points in the code the reviewer needs to double check? No. ## Why was this MR needed? At the beginning build traces were stored in database but at some point we moved to store them in files. All trace related actions are aware of this, but not `raw trace download`. ## What are the relevant issue numbers? Fixes #18900 ## Does this MR meet the acceptance criteria? - [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added - [ ] ~~[Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md)~~ - [ ] ~~API support added~~ - Tests - [x] Added for this feature/bug - [x] All builds are passing - [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides) - [x] Branch has no merge conflicts with `master` (if you do - rebase it please) - [ ] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits) See merge request !4822
Diffstat (limited to 'app/models')
-rw-r--r--app/models/ci/build.rb27
1 files changed, 22 insertions, 5 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index 23c8de6f650..61052437318 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -208,22 +208,31 @@ module Ci
end
end
+ def has_trace_file?
+ File.exist?(path_to_trace) || has_old_trace_file?
+ end
+
def has_trace?
raw_trace.present?
end
def raw_trace
- if File.file?(path_to_trace)
- File.read(path_to_trace)
- elsif project.ci_id && File.file?(old_path_to_trace)
- # Temporary fix for build trace data integrity
- File.read(old_path_to_trace)
+ if File.exist?(trace_file_path)
+ File.read(trace_file_path)
else
# backward compatibility
read_attribute :trace
end
end
+ ##
+ # Deprecated
+ #
+ # This is a hotfix for CI build data integrity, see #4246
+ def has_old_trace_file?
+ project.ci_id && File.exist?(old_path_to_trace)
+ end
+
def trace
trace = raw_trace
if project && trace.present? && project.runners_token.present?
@@ -262,6 +271,14 @@ module Ci
end
end
+ def trace_file_path
+ if has_old_trace_file?
+ old_path_to_trace
+ else
+ path_to_trace
+ end
+ end
+
def dir_to_trace
File.join(
Settings.gitlab_ci.builds_path,