summaryrefslogtreecommitdiff
path: root/app/services/clusters
diff options
context:
space:
mode:
authorDylan Griffith <dyl.griffith@gmail.com>2018-02-12 14:22:15 +1100
committerDylan Griffith <dyl.griffith@gmail.com>2018-02-15 17:01:11 +1100
commitc1828eaed56159998d1eaafdaa135f1b3480549b (patch)
tree8cd903c910454bfdbc2bfdb1b1e9709eaa5583f1 /app/services/clusters
parent5ca692b0b04b4f349fb5a08b9dcc7d87c774934e (diff)
downloadgitlab-ce-c1828eaed56159998d1eaafdaa135f1b3480549b.tar.gz
Persist external IP of ingress controller created for GKE (#42643)
Diffstat (limited to 'app/services/clusters')
-rw-r--r--app/services/clusters/applications/check_ingress_ip_address_service.rb37
-rw-r--r--app/services/clusters/applications/check_installation_progress_service.rb1
2 files changed, 38 insertions, 0 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
new file mode 100644
index 00000000000..cf132676aa6
--- /dev/null
+++ b/app/services/clusters/applications/check_ingress_ip_address_service.rb
@@ -0,0 +1,37 @@
+module Clusters
+ module Applications
+ class CheckIngressIpAddressService < BaseHelmService
+ def execute(retries_remaining)
+ return if app.external_ip
+
+ service = get_service
+
+ if service.status.loadBalancer.ingress
+ resolve_external_ip(service)
+ else
+ retry_if_necessary(retries_remaining)
+ end
+
+ rescue KubeException
+ retry_if_necessary(retries_remaining)
+ end
+
+ private
+
+ def resolve_external_ip(service)
+ 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 bde090eaeec..7dcddc1c3f7 100644
--- a/app/services/clusters/applications/check_installation_progress_service.rb
+++ b/app/services/clusters/applications/check_installation_progress_service.rb
@@ -20,6 +20,7 @@ module Clusters
def on_success
app.make_installed!
+ app.post_install
ensure
remove_installation_pod
end