summaryrefslogtreecommitdiff
path: root/qa/qa/runtime/ip_address.rb
diff options
context:
space:
mode:
Diffstat (limited to 'qa/qa/runtime/ip_address.rb')
-rw-r--r--qa/qa/runtime/ip_address.rb13
1 files changed, 10 insertions, 3 deletions
diff --git a/qa/qa/runtime/ip_address.rb b/qa/qa/runtime/ip_address.rb
index fcb6db750bb..ae83d10ffb5 100644
--- a/qa/qa/runtime/ip_address.rb
+++ b/qa/qa/runtime/ip_address.rb
@@ -8,16 +8,17 @@ module QA
HostUnreachableError = Class.new(StandardError)
LOOPBACK_ADDRESS = '127.0.0.1'
- PUBLIC_IP_ADDRESS_API = "https://api.ipify.org"
+ PUBLIC_IP_ADDRESS_API = 'https://api.ipify.org'
def fetch_current_ip_address
# When running on CI against a live environment such as staging.gitlab.com,
# we use the public facing IP address
- non_test_host = !URI.parse(Scenario.gitlab_address).host.include?('.test')
+ non_test_host = !URI.parse(Scenario.gitlab_address).host.include?('.test') # rubocop:disable Rails/NegateInclude
has_no_public_ip = Env.running_in_ci? || Env.use_public_ip_api?
ip_address = if has_no_public_ip && non_test_host
- response = get(PUBLIC_IP_ADDRESS_API)
+ response = get_public_ip_address
+
raise HostUnreachableError, "#{PUBLIC_IP_ADDRESS_API} is unreachable" unless response.code == Support::API::HTTP_STATUS_OK
response.body
@@ -31,6 +32,12 @@ module QA
ip_address
end
+
+ def get_public_ip_address
+ Support::Retrier.retry_on_exception(sleep_interval: 1) do
+ get(PUBLIC_IP_ADDRESS_API)
+ end
+ end
end
end
end