The elapsed time in jobs is rendered incorrectly if the time exceeds 60 minutes
Summary
time counters more than 1 hour are cut off in the pipeline console log. Notice the step that shows about 17m below, actually took 7h17m.
Steps to reproduce
- Have a job run longer than 1 hour
- Check the timer
Example Project
What is the current bug behavior?
Any job over an hour renders only the remaining minutes. e.g. 1:23:45
would render as 23:45
Relevant logs and/or screenshots
Possible fixes
In Gitlab::Ci::Ansi2json::Line::Segment#set_section_duration
we're parsing the duration using minutes:seconds
format. We should include the hour
if the duration is longer than one hour.
diff --git a/lib/gitlab/ci/ansi2json/line.rb b/lib/gitlab/ci/ansi2json/line.rb
index 466706384c0..528a3d18b16 100644
--- a/lib/gitlab/ci/ansi2json/line.rb
+++ b/lib/gitlab/ci/ansi2json/line.rb
@@ -77,7 +77,8 @@ def set_as_section_header
end
def set_section_duration(duration)
- @section_duration = Time.at(duration.to_i).utc.strftime('%M:%S')
+ time_format = duration.to_i >= 60.minutes ? '%H:%M:%S' : '%M:%S'
+ @section_duration = Time.at(duration.to_i).utc.strftime(time_format)
end
def flush_current_segment!
How to create collapsible job sections: https://docs.gitlab.com/ee/ci/jobs/#expand-and-collapse-job-log-sections
Edited by Marius Bobin