diff options
author | Dylan Griffith <dyl.griffith@gmail.com> | 2018-02-20 04:42:05 +0300 |
---|---|---|
committer | Dylan Griffith <dyl.griffith@gmail.com> | 2018-02-20 04:47:07 +0300 |
commit | ba4114d25f538d198df2f681b9cb08567494207e (patch) | |
tree | 876cf5b44ab81b25cdf30acb9ebd642778800615 /app/workers | |
parent | f0b27f9b406579a03e55fa16cbc7095009dc8c2b (diff) |
Refactor ingress IP address waiting code (#42643)
Diffstat (limited to 'app/workers')
-rw-r--r-- | app/workers/cluster_wait_for_ingress_ip_address_worker.rb | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/app/workers/cluster_wait_for_ingress_ip_address_worker.rb b/app/workers/cluster_wait_for_ingress_ip_address_worker.rb index 829417484cf..0fbb9fb2526 100644 --- a/app/workers/cluster_wait_for_ingress_ip_address_worker.rb +++ b/app/workers/cluster_wait_for_ingress_ip_address_worker.rb @@ -4,11 +4,22 @@ class ClusterWaitForIngressIpAddressWorker include ClusterApplications INTERVAL = 10.seconds - TIMEOUT = 20.minutes def perform(app_name, app_id, retries_remaining) find_application(app_name, app_id) do |app| - Clusters::Applications::CheckIngressIpAddressService.new(app).execute(retries_remaining) + result = Clusters::Applications::CheckIngressIpAddressService.new(app).execute + retry_if_necessary(app_name, app_id, retries_remaining) unless result + end + rescue Clusters::Applications::CheckIngressIpAddressService::Error => e + retry_if_necessary(app_name, app_id, retries_remaining) + raise e + end + + private + + def retry_if_necessary(app_name, app_id, retries_remaining) + if retries_remaining > 0 + self.class.perform_in(INTERVAL, app_name, app_id, retries_remaining - 1) end end end |