diff options
author | Dylan Griffith <dyl.griffith@gmail.com> | 2018-02-20 12:42:05 +1100 |
---|---|---|
committer | Dylan Griffith <dyl.griffith@gmail.com> | 2018-02-20 12:47:07 +1100 |
commit | ba4114d25f538d198df2f681b9cb08567494207e (patch) | |
tree | 876cf5b44ab81b25cdf30acb9ebd642778800615 /app/services | |
parent | f0b27f9b406579a03e55fa16cbc7095009dc8c2b (diff) | |
download | gitlab-ce-ba4114d25f538d198df2f681b9cb08567494207e.tar.gz |
Refactor ingress IP address waiting code (#42643)
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/clusters/applications/check_ingress_ip_address_service.rb | 23 | ||||
-rw-r--r-- | app/services/clusters/applications/check_installation_progress_service.rb | 1 |
2 files changed, 9 insertions, 15 deletions
diff --git a/app/services/clusters/applications/check_ingress_ip_address_service.rb b/app/services/clusters/applications/check_ingress_ip_address_service.rb index 3262aa59a90..300b7ed522c 100644 --- a/app/services/clusters/applications/check_ingress_ip_address_service.rb +++ b/app/services/clusters/applications/check_ingress_ip_address_service.rb @@ -1,22 +1,24 @@ module Clusters module Applications class CheckIngressIpAddressService < BaseHelmService + Error = Class.new(StandardError) + LEASE_TIMEOUT = 3.seconds.to_i - def execute(retries_remaining) - return if app.external_ip - return unless try_obtain_lease + def execute + return true if app.external_ip + return true unless try_obtain_lease service = get_service if service.status.loadBalancer.ingress resolve_external_ip(service) else - retry_if_necessary(retries_remaining) + false end - rescue KubeException - retry_if_necessary(retries_remaining) + rescue KubeException => e + raise Error, "#{e.class}: #{e.message}" end private @@ -28,19 +30,12 @@ module Clusters end def resolve_external_ip(service) - app.update!( external_ip: service.status.loadBalancer.ingress[0].ip) + app.update!(external_ip: service.status.loadBalancer.ingress[0].ip) end def get_service kubeclient.get_service('ingress-nginx-ingress-controller', Gitlab::Kubernetes::Helm::NAMESPACE) end - - def retry_if_necessary(retries_remaining) - if retries_remaining > 0 - ClusterWaitForIngressIpAddressWorker.perform_in( - ClusterWaitForIngressIpAddressWorker::INTERVAL, app.name, app.id, retries_remaining - 1) - end - end end end end diff --git a/app/services/clusters/applications/check_installation_progress_service.rb b/app/services/clusters/applications/check_installation_progress_service.rb index 7dcddc1c3f7..bde090eaeec 100644 --- a/app/services/clusters/applications/check_installation_progress_service.rb +++ b/app/services/clusters/applications/check_installation_progress_service.rb @@ -20,7 +20,6 @@ module Clusters def on_success app.make_installed! - app.post_install ensure remove_installation_pod end |