Commit 6697b542 authored by Ash McKenzie's avatar Ash McKenzie

Merge branch...

Merge branch '231268-follow-up-from-consolidate-trigger-build-docs-into-trigger-build' into 'master'

Ensure we use a finite loop in scripts/trigger-build

Closes #231268

See merge request gitlab-org/gitlab!39987
parents 25fa8e4c 152f82ea
...@@ -321,8 +321,6 @@ module Trigger ...@@ -321,8 +321,6 @@ module Trigger
INTERVAL = 60 # seconds INTERVAL = 60 # seconds
MAX_DURATION = 3600 * 3 # 3 hours MAX_DURATION = 3600 * 3 # 3 hours
attr_reader :project, :id
def self.unscoped_class_name def self.unscoped_class_name
name.split('::').last name.split('::').last
end end
...@@ -334,13 +332,11 @@ module Trigger ...@@ -334,13 +332,11 @@ module Trigger
def initialize(project, id) def initialize(project, id)
@project = project @project = project
@id = id @id = id
@start = Time.now.to_i @start_time = Time.now.to_i
end end
def wait! def wait!
loop do (MAX_DURATION / INTERVAL).times do
raise "#{self.class.unscoped_class_name} timed out after waiting for #{duration} minutes!" if timeout?
case status case status
when :created, :pending, :running when :created, :pending, :running
print "." print "."
...@@ -354,14 +350,12 @@ module Trigger ...@@ -354,14 +350,12 @@ module Trigger
STDOUT.flush STDOUT.flush
end end
end
def timeout? raise "#{self.class.unscoped_class_name} timed out after waiting for #{duration} minutes!"
Time.now.to_i > (@start + MAX_DURATION)
end end
def duration def duration
(Time.now.to_i - @start) / 60 (Time.now.to_i - start_time) / 60
end end
def status def status
...@@ -372,6 +366,10 @@ module Trigger ...@@ -372,6 +366,10 @@ module Trigger
# timeout anyway. # timeout anyway.
:running :running
end end
private
attr_reader :project, :id, :start_time
end end
Job = Class.new(Pipeline) Job = Class.new(Pipeline)
......
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