diff options
author | Shinya Maeda <shinya@gitlab.com> | 2018-10-26 08:01:28 +0000 |
---|---|---|
committer | Kamil TrzciĆski <ayufan@ayufan.eu> | 2018-10-26 08:01:28 +0000 |
commit | 0c9ad4826a79fa6d1cbbf8c4b1e12af9e4443515 (patch) | |
tree | 5f394df7397dbebc146514340955165fc8450a75 | |
parent | 2bbfca8240c605e3b1c4aed18cadda4f6403e138 (diff) | |
download | gitlab-ce-0c9ad4826a79fa6d1cbbf8c4b1e12af9e4443515.tar.gz |
Support backward compatibility when introduce new failure reason
-rw-r--r-- | app/models/commit_status.rb | 2 | ||||
-rw-r--r-- | changelogs/unreleased/avoid-lock-when-introduce-new-failure-reason.yml | 5 | ||||
-rw-r--r-- | lib/api/runner.rb | 3 | ||||
-rw-r--r-- | spec/requests/api/runner_spec.rb | 9 |
4 files changed, 16 insertions, 3 deletions
diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb index 06507345fe8..344f091c872 100644 --- a/app/models/commit_status.rb +++ b/app/models/commit_status.rb @@ -109,7 +109,7 @@ class CommitStatus < ActiveRecord::Base before_transition any => :failed do |commit_status, transition| failure_reason = transition.args.first - commit_status.failure_reason = failure_reason + commit_status.failure_reason = CommitStatus.failure_reasons[failure_reason] end after_transition do |commit_status, transition| diff --git a/changelogs/unreleased/avoid-lock-when-introduce-new-failure-reason.yml b/changelogs/unreleased/avoid-lock-when-introduce-new-failure-reason.yml new file mode 100644 index 00000000000..30b9ae032d4 --- /dev/null +++ b/changelogs/unreleased/avoid-lock-when-introduce-new-failure-reason.yml @@ -0,0 +1,5 @@ +--- +title: Support backward compatibility when introduce new failure reason +merge_request: 22566 +author: +type: changed diff --git a/lib/api/runner.rb b/lib/api/runner.rb index d8768a54986..2f15f3a7d76 100644 --- a/lib/api/runner.rb +++ b/lib/api/runner.rb @@ -142,8 +142,7 @@ module API requires :id, type: Integer, desc: %q(Job's ID) optional :trace, type: String, desc: %q(Job's full trace) optional :state, type: String, desc: %q(Job's status: success, failed) - optional :failure_reason, type: String, values: CommitStatus.failure_reasons.keys, - desc: %q(Job's failure_reason) + optional :failure_reason, type: String, desc: %q(Job's failure_reason) end put '/:id' do job = authenticate_job! diff --git a/spec/requests/api/runner_spec.rb b/spec/requests/api/runner_spec.rb index 43ceb332cfb..c0d5a3ad74b 100644 --- a/spec/requests/api/runner_spec.rb +++ b/spec/requests/api/runner_spec.rb @@ -797,6 +797,15 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it { expect(job).to be_runner_system_failure } end + + context 'when failure_reason is unrecognized value' do + before do + update_job(state: 'failed', failure_reason: 'what_is_this') + job.reload + end + + it { expect(job).to be_unknown_failure } + end end context 'when trace is given' do |