Skip to content

Commit 4d16069

Browse files
authored
Merge pull request #201 from puppetlabs/add_env_for_abs_polling_duration
Add ENV var for ABS Polling Duration
2 parents 5cce550 + 9218b7d commit 4d16069

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tasks/abs.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ def provision(platform, inventory_location, vars)
3434
else
3535
'https://litmus_manual'
3636
end
37+
poll_duration = ENV['POLL_ABS_TIMEOUT_SECONDS'] || 600
38+
3739
# Job ID must be unique
3840
job_id = "iac-task-pid-#{Process.pid}-#{DateTime.now.strftime('%Q')}"
3941

@@ -63,7 +65,7 @@ def provision(platform, inventory_location, vars)
6365
raise "Error: #{reply}: #{reply.message}" unless reply.is_a?(Net::HTTPAccepted) # should be a 202
6466

6567
# We want to then poll the API until we get a 200 response, indicating the VMs have been provisioned
66-
timeout = Time.now.to_i + 600 # Let's poll the API for a max of 10 minutes
68+
timeout = Time.now.to_i + poll_duration.to_i # Let's poll the API for a max of poll_duration seconds
6769
sleep_time = 1
6870

6971
# Progressively increase the sleep time by 1 second. When we hit 10 seconds, start querying every 30 seconds until we
@@ -80,7 +82,7 @@ def provision(platform, inventory_location, vars)
8082
sleep_time += 1
8183
end
8284

83-
raise 'Timeout: unable to get a 200 response in 10 minutes' if reply.code != '200'
85+
raise "Timeout: unable to get a 200 response in #{poll_duration} seconds" if reply.code != '200'
8486

8587
inventory_full_path = File.join(inventory_location, '/spec/fixtures/litmus_inventory.yaml')
8688
inventory_hash = get_inventory_hash(inventory_full_path)

0 commit comments

Comments
 (0)