diff options
author | Dylan Griffith <dyl.griffith@gmail.com> | 2018-02-15 17:24:59 +1100 |
---|---|---|
committer | Dylan Griffith <dyl.griffith@gmail.com> | 2018-02-15 17:24:59 +1100 |
commit | 5190ef57a3c5a4333020a5281904e56c00519e91 (patch) | |
tree | 1141906cc5e931b8177926f54deb83d30bba62f6 /app | |
parent | c1828eaed56159998d1eaafdaa135f1b3480549b (diff) | |
download | gitlab-ce-5190ef57a3c5a4333020a5281904e56c00519e91.tar.gz |
Ensure CheckIngressIpAddressService obtains exclusive lease per ingress controller (#42643)
Diffstat (limited to 'app')
-rw-r--r-- | app/services/clusters/applications/check_ingress_ip_address_service.rb | 9 |
1 files changed, 9 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 index cf132676aa6..3262aa59a90 100644 --- a/app/services/clusters/applications/check_ingress_ip_address_service.rb +++ b/app/services/clusters/applications/check_ingress_ip_address_service.rb @@ -1,8 +1,11 @@ module Clusters module Applications class CheckIngressIpAddressService < BaseHelmService + LEASE_TIMEOUT = 3.seconds.to_i + def execute(retries_remaining) return if app.external_ip + return unless try_obtain_lease service = get_service @@ -18,6 +21,12 @@ module Clusters private + def try_obtain_lease + Gitlab::ExclusiveLease + .new("check_ingress_ip_address_service:#{app.id}", timeout: LEASE_TIMEOUT) + .try_obtain + end + def resolve_external_ip(service) app.update!( external_ip: service.status.loadBalancer.ingress[0].ip) end |