summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2018-07-20 14:27:54 +0900
committerShinya Maeda <shinya@gitlab.com>2018-07-20 14:27:54 +0900
commit9ecaee914defba5f12a7a06375ea2876b4328d7f (patch)
tree0d51627e8247ac46a8cbc3a65ab2373b2d279d19
parent34ea9610ab9a249a576ee435f365b9e1fcca7f00 (diff)
downloadgitlab-ce-9ecaee914defba5f12a7a06375ea2876b4328d7f.tar.gz
Introduce ARCHIVE_LEGACY_TRACES_MIGRATION_VERSION check
-rw-r--r--app/models/ci/job_artifact.rb6
-rw-r--r--lib/api/runner.rb2
-rw-r--r--lib/gitlab/ci/trace.rb30
3 files changed, 30 insertions, 8 deletions
diff --git a/app/models/ci/job_artifact.rb b/app/models/ci/job_artifact.rb
index c9ce042a1c5..e31662efae3 100644
--- a/app/models/ci/job_artifact.rb
+++ b/app/models/ci/job_artifact.rb
@@ -9,7 +9,7 @@ module Ci
mount_uploader :file, JobArtifactUploader
- validates :file_format, presence: true, on: :create
+ validates :file_format, presence: true, unless: :ignore_schema, on: :create
before_save :set_size, if: :file_changed?
after_save :update_project_statistics_after_save, if: :size_changed?
after_destroy :update_project_statistics_after_destroy, unless: :project_destroyed?
@@ -41,6 +41,10 @@ module Ci
gzip: 3
}
+ def ignore_schema
+ ActiveRecord::Migrator.current_version <= ::Gitlab::Ci::Trace::ARCHIVE_LEGACY_TRACES_MIGRATION_VERSION
+ end
+
def update_file_store
# The file.object_store is set during `uploader.store!`
# which happens after object is inserted/updated
diff --git a/lib/api/runner.rb b/lib/api/runner.rb
index 80a12788714..a7d3db57bac 100644
--- a/lib/api/runner.rb
+++ b/lib/api/runner.rb
@@ -275,7 +275,7 @@ module API
job.job_artifacts.build(
project: job.project,
file: metadata,
- file_type: "#{params['artifact_type']}_metadata",
+ file_type: :metadata,
file_format: :gzip,
file_sha256: metadata.sha256,
expire_in: expire_in)
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