Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
3d3d09fa
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
3d3d09fa
编写于
2月 20, 2018
作者:
D
Dylan Griffith
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Schedule Ingress IP address fetch from K8s after clusters page load (#42643)
上级
ba4114d2
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
53 addition
and
0 deletion
+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
未找到文件。
app/controllers/projects/clusters_controller.rb
浏览文件 @
3d3d09fa
...
@@ -4,6 +4,7 @@ class Projects::ClustersController < Projects::ApplicationController
...
@@ -4,6 +4,7 @@ class Projects::ClustersController < Projects::ApplicationController
before_action
:authorize_create_cluster!
,
only:
[
:new
]
before_action
:authorize_create_cluster!
,
only:
[
:new
]
before_action
:authorize_update_cluster!
,
only:
[
:update
]
before_action
:authorize_update_cluster!
,
only:
[
:update
]
before_action
:authorize_admin_cluster!
,
only:
[
:destroy
]
before_action
:authorize_admin_cluster!
,
only:
[
:destroy
]
before_action
:sync_application_details
,
only:
[
:status
]
STATUS_POLLING_INTERVAL
=
10_000
STATUS_POLLING_INTERVAL
=
10_000
...
@@ -114,4 +115,8 @@ class Projects::ClustersController < Projects::ApplicationController
...
@@ -114,4 +115,8 @@ class Projects::ClustersController < Projects::ApplicationController
def
authorize_admin_cluster!
def
authorize_admin_cluster!
access_denied!
unless
can?
(
current_user
,
:admin_cluster
,
cluster
)
access_denied!
unless
can?
(
current_user
,
:admin_cluster
,
cluster
)
end
end
def
sync_application_details
@cluster
.
applications
.
each
(
&
:sync_details
)
end
end
end
app/models/clusters/applications/ingress.rb
浏览文件 @
3d3d09fa
...
@@ -36,6 +36,14 @@ module Clusters
...
@@ -36,6 +36,14 @@ module Clusters
def
install_command
def
install_command
Gitlab
::
Kubernetes
::
Helm
::
InstallCommand
.
new
(
name
,
chart:
chart
,
chart_values_file:
chart_values_file
)
Gitlab
::
Kubernetes
::
Helm
::
InstallCommand
.
new
(
name
,
chart:
chart
,
chart_values_file:
chart_values_file
)
end
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
end
end
end
app/models/clusters/concerns/application_core.rb
浏览文件 @
3d3d09fa
...
@@ -23,6 +23,11 @@ module Clusters
...
@@ -23,6 +23,11 @@ module Clusters
def
name
def
name
self
.
class
.
application_name
self
.
class
.
application_name
end
end
def
sync_details
# Override if you need extra data synchronized
# from K8s after installation
end
end
end
end
end
end
end
...
...
spec/controllers/projects/clusters_controller_spec.rb
浏览文件 @
3d3d09fa
...
@@ -91,6 +91,12 @@ describe Projects::ClustersController do
...
@@ -91,6 +91,12 @@ describe Projects::ClustersController do
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
match_response_schema
(
'cluster_status'
)
expect
(
response
).
to
match_response_schema
(
'cluster_status'
)
end
end
it
'invokes sync_details on each application'
do
expect_any_instance_of
(
Clusters
::
Applications
::
Ingress
).
to
receive
(
:sync_details
)
go
end
end
end
describe
'security'
do
describe
'security'
do
...
...
spec/models/clusters/applications/ingress_spec.rb
浏览文件 @
3d3d09fa
...
@@ -22,4 +22,33 @@ describe Clusters::Applications::Ingress do
...
@@ -22,4 +22,33 @@ describe Clusters::Applications::Ingress do
.
with
(
ClusterWaitForIngressIpAddressWorker
::
INTERVAL
,
'ingress'
,
application
.
id
,
3
)
.
with
(
ClusterWaitForIngressIpAddressWorker
::
INTERVAL
,
'ingress'
,
application
.
id
,
3
)
end
end
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
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录