Commit 5682320f authored by Robert Speicher's avatar Robert Speicher Committed by Yorick Peterse

Merge branch 'fix-ci-charts-error-500' into 'master'

Fix Error 500 in CI charts by gracefully handling commits with no durations

## What does this MR do?

In the CI charts, this MR reports the duration of a commit to 0 if it is `nil`.

## Are there points in the code the reviewer needs to double check?

Should we omit this commit from the chart or set it to some other value?

## Why was this MR needed?

We were getting an Error 500 here: https://gitlab.com/gitlab-org/gitlab-ce/graphs/master/ci

## What are the relevant issue numbers?

#17730 


See merge request !4245
parent 8a494ecd
...@@ -5,6 +5,7 @@ v 8.8.2 ...@@ -5,6 +5,7 @@ v 8.8.2
- Fix access to Pipelines by Anonymous user. !4233 - Fix access to Pipelines by Anonymous user. !4233
v 8.8.2 (unreleased) v 8.8.2 (unreleased)
- Fix Error 500 when accessing application settings due to nil disabled OAuth sign-in sources - Fix Error 500 when accessing application settings due to nil disabled OAuth sign-in sources
- Fix Error 500 in CI charts by gracefully handling commits with no durations
v 8.8.1 v 8.8.1
- Add documentation for the "Health Check" feature - Add documentation for the "Health Check" feature
......
...@@ -64,7 +64,8 @@ module Ci ...@@ -64,7 +64,8 @@ module Ci
commits.each do |commit| commits.each do |commit|
@labels << commit.short_sha @labels << commit.short_sha
@build_times << (commit.duration / 60) duration = commit.duration || 0
@build_times << (duration / 60)
end end
end end
end end
......
...@@ -12,5 +12,12 @@ describe Ci::Charts, lib: true do ...@@ -12,5 +12,12 @@ describe Ci::Charts, lib: true do
chart = Ci::Charts::BuildTime.new(@commit.project) chart = Ci::Charts::BuildTime.new(@commit.project)
expect(chart.build_times).to eq([2]) expect(chart.build_times).to eq([2])
end end
it 'should handle nil build times' do
create(:ci_commit, duration: nil, project: @commit.project)
chart = Ci::Charts::BuildTime.new(@commit.project)
expect(chart.build_times).to eq([2, 0])
end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment