From dcf09d11447c264f4b4028ea80eea2be913c2f5b Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Thu, 31 Aug 2017 03:20:54 +0900 Subject: Implement `failure_reason` on `ci_builds` --- app/models/commit_status.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'app/models/commit_status.rb') diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb index 842c6e5cb50..dae3174ba9b 100644 --- a/app/models/commit_status.rb +++ b/app/models/commit_status.rb @@ -38,6 +38,19 @@ class CommitStatus < ActiveRecord::Base scope :retried_ordered, -> { retried.ordered.includes(project: :namespace) } scope :after_stage, -> (index) { where('stage_idx > ?', index) } + enum failure_reason: { + no_error: nil, + failed_by_script: 1, # TODO: Not used. Should we expand pipeline as well? + failed_by_missing_dependency: 2, # This will be done in the next MR. + failed_by_system: 3, # TODO: Not used. What's this state? + failed_by_failed_job_state: 4, + failed_by_out_of_quota: 5, # TODO: Only EE. How can we detect? + failed_by_stuck_and_timeout: 6, + failed_by_no_runner: 7, # TODO: Not used. How can we detect? + failed_by_api: 8, + failed_by_page: 9 + } + state_machine :status do event :process do transition [:skipped, :manual] => :created @@ -79,6 +92,11 @@ class CommitStatus < ActiveRecord::Base commit_status.finished_at = Time.now end + before_transition any => :failed do |commit_status, transition| + failure_reason = transition.args.first + commit_status.failure_reason = failure_reason + end + after_transition do |commit_status, transition| next if transition.loopback? -- cgit v1.2.1 From b1af1f268b97c8518bf2806bca48f49174a8aead Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Thu, 31 Aug 2017 03:36:15 +0900 Subject: Fix enum wording --- app/models/commit_status.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/models/commit_status.rb') diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb index dae3174ba9b..424f8e49d4d 100644 --- a/app/models/commit_status.rb +++ b/app/models/commit_status.rb @@ -43,7 +43,7 @@ class CommitStatus < ActiveRecord::Base failed_by_script: 1, # TODO: Not used. Should we expand pipeline as well? failed_by_missing_dependency: 2, # This will be done in the next MR. failed_by_system: 3, # TODO: Not used. What's this state? - failed_by_failed_job_state: 4, + failed_by_job_state: 4, failed_by_out_of_quota: 5, # TODO: Only EE. How can we detect? failed_by_stuck_and_timeout: 6, failed_by_no_runner: 7, # TODO: Not used. How can we detect? -- cgit v1.2.1 From 1d7c0390722c96aa66af5b26f5a826b97293dcd6 Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Thu, 31 Aug 2017 22:03:41 +0900 Subject: Fix enum lists --- app/models/commit_status.rb | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'app/models/commit_status.rb') diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb index 424f8e49d4d..1c4088d5af9 100644 --- a/app/models/commit_status.rb +++ b/app/models/commit_status.rb @@ -39,16 +39,10 @@ class CommitStatus < ActiveRecord::Base scope :after_stage, -> (index) { where('stage_idx > ?', index) } enum failure_reason: { - no_error: nil, - failed_by_script: 1, # TODO: Not used. Should we expand pipeline as well? - failed_by_missing_dependency: 2, # This will be done in the next MR. - failed_by_system: 3, # TODO: Not used. What's this state? - failed_by_job_state: 4, - failed_by_out_of_quota: 5, # TODO: Only EE. How can we detect? - failed_by_stuck_and_timeout: 6, - failed_by_no_runner: 7, # TODO: Not used. How can we detect? - failed_by_api: 8, - failed_by_page: 9 + unknown_failure: nil, + job_failure: 1, + api_failure: 2, + stuck_or_timeout_failure: 3, } state_machine :status do -- cgit v1.2.1 From 68f6c61cf621db82ac98d561782590b1866fcf6f Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Fri, 1 Sep 2017 16:52:11 +0900 Subject: - Allow runner API to pass failure_reason - Fix spec --- app/models/commit_status.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/models/commit_status.rb') diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb index 1c4088d5af9..1e8f28b6466 100644 --- a/app/models/commit_status.rb +++ b/app/models/commit_status.rb @@ -42,7 +42,7 @@ class CommitStatus < ActiveRecord::Base unknown_failure: nil, job_failure: 1, api_failure: 2, - stuck_or_timeout_failure: 3, + stuck_or_timeout_failure: 3 } state_machine :status do -- cgit v1.2.1 From 38d9b4d77d85e26f827ff9640243494adc8597ed Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Tue, 5 Sep 2017 15:10:34 +0900 Subject: Use script_failure. Add runner_system_failure. Improve spec. --- app/models/commit_status.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'app/models/commit_status.rb') diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb index 1e8f28b6466..f3888528940 100644 --- a/app/models/commit_status.rb +++ b/app/models/commit_status.rb @@ -40,9 +40,10 @@ class CommitStatus < ActiveRecord::Base enum failure_reason: { unknown_failure: nil, - job_failure: 1, + script_failure: 1, api_failure: 2, - stuck_or_timeout_failure: 3 + stuck_or_timeout_failure: 3, + runner_system_failure: 4 } state_machine :status do -- cgit v1.2.1