diff options
author | Shinya Maeda <shinya@gitlab.com> | 2019-04-02 15:40:07 +0700 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2019-04-05 15:50:26 +0700 |
commit | 5ac7d2df7a9893d4c98662b639abfb27900481ef (patch) | |
tree | b3c4ff6224f781034a18b679be02f5822f6a3e7d | |
parent | 9646e451a8d7006d2c77ca90e6ff93674b99c9cc (diff) | |
download | gitlab-ce-disable-support-for-legacy-traces.tar.gz |
Disable support for legacy tracesdisable-support-for-legacy-traces
Legacy traces are not generated for long time in favor of live trace,
etc. Disabling legacy trace support helps us to investigate the usage
of the legacy deprecated traces, and eventually we remove the related
code completely.
-rw-r--r-- | app/models/ci/build.rb | 4 | ||||
-rw-r--r-- | app/models/project.rb | 4 | ||||
-rw-r--r-- | changelogs/unreleased/disable-support-for-legacy-traces.yml | 5 | ||||
-rw-r--r-- | doc/administration/job_traces.md | 4 | ||||
-rw-r--r-- | lib/gitlab/ci/trace.rb | 2 | ||||
-rw-r--r-- | spec/models/ci/build_spec.rb | 18 |
6 files changed, 36 insertions, 1 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index b8a76e662b0..c9b5231e791 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -548,7 +548,7 @@ module Ci end def has_old_trace? - old_trace.present? + project.legacy_traces_enabled? && old_trace.present? end def trace=(data) @@ -556,6 +556,8 @@ module Ci end def old_trace + return unless project.legacy_traces_enabled? + read_attribute(:trace) end diff --git a/app/models/project.rb b/app/models/project.rb index e2869fc2ad5..ba21d4969eb 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -2139,6 +2139,10 @@ class Project < ApplicationRecord pool_repository.present? end + def legacy_traces_enabled? + Feature.enabled?(:ci_enable_legacy_traces, self) + end + private def merge_requests_allowing_collaboration(source_branch = nil) diff --git a/changelogs/unreleased/disable-support-for-legacy-traces.yml b/changelogs/unreleased/disable-support-for-legacy-traces.yml new file mode 100644 index 00000000000..2e54b70225f --- /dev/null +++ b/changelogs/unreleased/disable-support-for-legacy-traces.yml @@ -0,0 +1,5 @@ +--- +title: Disable support for legacy traces +merge_request: 26848 +author: +type: deprecated diff --git a/doc/administration/job_traces.md b/doc/administration/job_traces.md index 63945506f3c..7d66323346f 100644 --- a/doc/administration/job_traces.md +++ b/doc/administration/job_traces.md @@ -86,6 +86,10 @@ To archive those legacy job traces, please follow the instruction below. If the count becomes zero, the archiving processes are done +NOTE: **NOTE** As of GitLab 11.10, those legacy traces are deprecated and will be +removed in the next major version update. You can preserve those legacy traces by enabling a feature flag +`Feature.enable(:ci_enable_legacy_traces)` and archiving it according to the above steps. + ## How to migrate archived job traces to object storage > [Introduced][ce-21193] in GitLab 11.3. diff --git a/lib/gitlab/ci/trace.rb b/lib/gitlab/ci/trace.rb index bf5f2a31f0e..e52e1e01fcc 100644 --- a/lib/gitlab/ci/trace.rb +++ b/lib/gitlab/ci/trace.rb @@ -228,6 +228,8 @@ module Gitlab end def deprecated_path + return unless job.project.legacy_traces_enabled? + File.join( Settings.gitlab_ci.builds_path, job.created_at.utc.strftime("%Y_%m"), diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index 697fe3fda06..2a1872dd7d8 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -776,6 +776,14 @@ describe Ci::Build do end it { is_expected.to be_truthy } + + context 'when ci_enable_legacy_traces feature flag is disabled' do + before do + stub_feature_flags(ci_enable_legacy_traces: false) + end + + it { is_expected.to be_falsy } + end end context 'when old trace does not exist' do @@ -799,6 +807,16 @@ describe Ci::Build do it "expect to receive data from database" do is_expected.to eq('old trace') end + + context 'when ci_enable_legacy_traces feature flag is disabled' do + before do + stub_feature_flags(ci_enable_legacy_traces: false) + end + + it 'does not return old trace' do + is_expected.to be_nil + end + end end describe '#erase_old_trace!' do |