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
Boxiang Sun
gitlab-ce
Commits
3d3d09fa
Commit
3d3d09fa
authored
Feb 20, 2018
by
Dylan Griffith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Schedule Ingress IP address fetch from K8s after clusters page load (#42643)
parent
ba4114d2
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
53 additions
and
0 deletions
+53
-0
app/controllers/projects/clusters_controller.rb
app/controllers/projects/clusters_controller.rb
+5
-0
app/models/clusters/applications/ingress.rb
app/models/clusters/applications/ingress.rb
+8
-0
app/models/clusters/concerns/application_core.rb
app/models/clusters/concerns/application_core.rb
+5
-0
spec/controllers/projects/clusters_controller_spec.rb
spec/controllers/projects/clusters_controller_spec.rb
+6
-0
spec/models/clusters/applications/ingress_spec.rb
spec/models/clusters/applications/ingress_spec.rb
+29
-0
No files found.
app/controllers/projects/clusters_controller.rb
View file @
3d3d09fa
...
...
@@ -4,6 +4,7 @@ class Projects::ClustersController < Projects::ApplicationController
before_action
:authorize_create_cluster!
,
only:
[
:new
]
before_action
:authorize_update_cluster!
,
only:
[
:update
]
before_action
:authorize_admin_cluster!
,
only:
[
:destroy
]
before_action
:sync_application_details
,
only:
[
:status
]
STATUS_POLLING_INTERVAL
=
10_000
...
...
@@ -114,4 +115,8 @@ class Projects::ClustersController < Projects::ApplicationController
def
authorize_admin_cluster!
access_denied!
unless
can?
(
current_user
,
:admin_cluster
,
cluster
)
end
def
sync_application_details
@cluster
.
applications
.
each
(
&
:sync_details
)
end
end
app/models/clusters/applications/ingress.rb
View file @
3d3d09fa
...
...
@@ -36,6 +36,14 @@ module Clusters
def
install_command
Gitlab
::
Kubernetes
::
Helm
::
InstallCommand
.
new
(
name
,
chart:
chart
,
chart_values_file:
chart_values_file
)
end
def
sync_details
return
unless
installed?
return
if
external_ip
ClusterWaitForIngressIpAddressWorker
.
perform_in
(
ClusterWaitForIngressIpAddressWorker
::
INTERVAL
,
name
,
id
,
IP_ADDRESS_FETCH_RETRIES
)
end
end
end
end
app/models/clusters/concerns/application_core.rb
View file @
3d3d09fa
...
...
@@ -23,6 +23,11 @@ module Clusters
def
name
self
.
class
.
application_name
end
def
sync_details
# Override if you need extra data synchronized
# from K8s after installation
end
end
end
end
...
...
spec/controllers/projects/clusters_controller_spec.rb
View file @
3d3d09fa
...
...
@@ -91,6 +91,12 @@ describe Projects::ClustersController do
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'cluster_status'
)
end
it
'invokes sync_details on each application'
do
expect_any_instance_of
(
Clusters
::
Applications
::
Ingress
).
to
receive
(
:sync_details
)
go
end
end
describe
'security'
do
...
...
spec/models/clusters/applications/ingress_spec.rb
View file @
3d3d09fa
...
...
@@ -22,4 +22,33 @@ describe Clusters::Applications::Ingress do
.
with
(
ClusterWaitForIngressIpAddressWorker
::
INTERVAL
,
'ingress'
,
application
.
id
,
3
)
end
end
describe
'#sync_details'
do
let
(
:application
)
{
create
(
:clusters_applications_ingress
,
:installed
)
}
before
do
application
.
sync_details
end
it
'schedules a ClusterWaitForIngressIpAddressWorker'
do
expect
(
ClusterWaitForIngressIpAddressWorker
).
to
have_received
(
:perform_in
)
.
with
(
ClusterWaitForIngressIpAddressWorker
::
INTERVAL
,
'ingress'
,
application
.
id
,
3
)
end
context
'when the application is not installed'
do
let
(
:application
)
{
create
(
:clusters_applications_ingress
,
:installing
)
}
it
'does not schedule a ClusterWaitForIngressIpAddressWorker'
do
expect
(
ClusterWaitForIngressIpAddressWorker
).
not_to
have_received
(
:perform_in
)
end
end
context
'when there is already an external_ip'
do
let
(
:application
)
{
create
(
:clusters_applications_ingress
,
:installed
,
external_ip:
'111.222.222.111'
)
}
it
'does not schedule a ClusterWaitForIngressIpAddressWorker'
do
expect
(
ClusterWaitForIngressIpAddressWorker
).
not_to
have_received
(
:perform_in
)
end
end
end
end
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