From 9218b7d44938d223344658a4c3ac752bff7b966f Mon Sep 17 00:00:00 2001 From: seamymckenna Date: Mon, 20 Feb 2023 11:16:28 +0000 Subject: [PATCH] Add ENV var for ABS Polling Duration --- tasks/abs.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tasks/abs.rb b/tasks/abs.rb index 2aac288..66cd53f 100755 --- a/tasks/abs.rb +++ b/tasks/abs.rb @@ -34,6 +34,8 @@ def provision(platform, inventory_location, vars) else 'https://litmus_manual' end + poll_duration = ENV['POLL_ABS_TIMEOUT_SECONDS'] || 600 + # Job ID must be unique job_id = "iac-task-pid-#{Process.pid}-#{DateTime.now.strftime('%Q')}" @@ -63,7 +65,7 @@ def provision(platform, inventory_location, vars) raise "Error: #{reply}: #{reply.message}" unless reply.is_a?(Net::HTTPAccepted) # should be a 202 # We want to then poll the API until we get a 200 response, indicating the VMs have been provisioned - timeout = Time.now.to_i + 600 # Let's poll the API for a max of 10 minutes + timeout = Time.now.to_i + poll_duration.to_i # Let's poll the API for a max of poll_duration seconds sleep_time = 1 # 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) sleep_time += 1 end - raise 'Timeout: unable to get a 200 response in 10 minutes' if reply.code != '200' + raise "Timeout: unable to get a 200 response in #{poll_duration} seconds" if reply.code != '200' inventory_full_path = File.join(inventory_location, '/spec/fixtures/litmus_inventory.yaml') inventory_hash = get_inventory_hash(inventory_full_path)