diff options
Diffstat (limited to 'lib/gitlab/ci/trace.rb')
-rw-r--r-- | lib/gitlab/ci/trace.rb | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/lib/gitlab/ci/trace.rb b/lib/gitlab/ci/trace.rb index 769d998227c..ee0adc790d8 100644 --- a/lib/gitlab/ci/trace.rb +++ b/lib/gitlab/ci/trace.rb @@ -162,14 +162,32 @@ module Gitlab end end + ## + # NOTE: + # In 11.0, we shipped a post migration to archive legacy traces. In the migration script, + # `Trace#archive!` method was directly used for simplying the migration logic. + # In 11.2, we created a new column in `ci_job_artifacts` table and started saving a value to the column, + # however, this brought up a problem that if users bump their GitLab instance version from 10.7 to 11.2, + # then their legacy trace migrations are going to require the new column to be present, even though 11.2's migration has not run yet. + # https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/20390#note_89084352 + ARCHIVE_LEGACY_TRACES_MIGRATION_VERSION = 20180529152628 + def create_build_trace!(job, path) File.open(path) do |stream| - job.create_job_artifacts_trace!( - project: job.project, - file_type: :trace, - file_format: :raw, - file: stream, - file_sha256: Digest::SHA256.file(path).hexdigest) + if ActiveRecord::Migrator.current_version <= ARCHIVE_LEGACY_TRACES_MIGRATION_VERSION + job.create_job_artifacts_trace!( + project: job.project, + file_type: :trace, + file: stream, + file_sha256: Digest::SHA256.file(path).hexdigest) + else + job.create_job_artifacts_trace!( + project: job.project, + file_type: :trace, + file_format: :raw, + file: stream, + file_sha256: Digest::SHA256.file(path).hexdigest) + end end end |