Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
5190ef57
Commit
5190ef57
authored
Feb 15, 2018
by
Dylan Griffith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure CheckIngressIpAddressService obtains exclusive lease per ingress controller (#42643)
parent
c1828eae
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
0 deletions
+28
-0
app/services/clusters/applications/check_ingress_ip_address_service.rb
...clusters/applications/check_ingress_ip_address_service.rb
+9
-0
spec/services/clusters/applications/check_ingress_ip_address_service_spec.rb
...ers/applications/check_ingress_ip_address_service_spec.rb
+19
-0
No files found.
app/services/clusters/applications/check_ingress_ip_address_service.rb
View file @
5190ef57
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
...
...
spec/services/clusters/applications/check_ingress_ip_address_service_spec.rb
View file @
5190ef57
...
...
@@ -16,9 +16,14 @@ describe Clusters::Applications::CheckIngressIpAddressService do
end
let
(
:kubeclient
)
{
double
(
::
Kubeclient
::
Client
,
get_service:
kube_service
)
}
let
(
:ingress
)
{
[{
ip:
'111.222.111.222'
}]
}
let
(
:exclusive_lease
)
{
instance_double
(
Gitlab
::
ExclusiveLease
,
try_obtain:
true
)
}
before
do
allow
(
application
.
cluster
).
to
receive
(
:kubeclient
).
and_return
(
kubeclient
)
allow
(
Gitlab
::
ExclusiveLease
)
.
to
receive
(
:new
)
.
with
(
"check_ingress_ip_address_service:
#{
application
.
id
}
"
,
timeout:
3
.
seconds
.
to_i
)
.
and_return
(
exclusive_lease
)
end
describe
'#execute'
do
...
...
@@ -52,6 +57,20 @@ describe Clusters::Applications::CheckIngressIpAddressService do
end
end
context
'when the exclusive lease cannot be obtained'
do
before
do
allow
(
exclusive_lease
)
.
to
receive
(
:try_obtain
)
.
and_return
(
false
)
end
it
'does not call kubeclient'
do
expect
(
kubeclient
).
not_to
receive
(
:get_service
)
service
.
execute
(
1
)
end
end
context
'when there is already an external_ip'
do
let
(
:application
)
{
create
(
:clusters_applications_ingress
,
:installed
,
external_ip:
'001.111.002.111'
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment