Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
86d85317
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,发现更多精彩内容 >>
未验证
提交
86d85317
编写于
11月 07, 2017
作者:
A
Alessio Caiazza
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove Clusters::Applications::FinalizeInstallationService
上级
a46d3241
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
36 addition
and
54 deletion
+36
-54
app/services/clusters/applications/check_installation_progress_service.rb
...sters/applications/check_installation_progress_service.rb
+23
-7
app/services/clusters/applications/finalize_installation_service.rb
...es/clusters/applications/finalize_installation_service.rb
+0
-11
spec/services/clusters/applications/check_installation_progress_service_spec.rb
.../applications/check_installation_progress_service_spec.rb
+13
-4
spec/services/clusters/applications/finalize_installation_service_spec.rb
...usters/applications/finalize_installation_service_spec.rb
+0
-32
未找到文件。
app/services/clusters/applications/check_installation_progress_service.rb
浏览文件 @
86d85317
...
...
@@ -6,7 +6,7 @@ module Clusters
case
installation_phase
when
Gitlab
::
Kubernetes
::
Pod
::
SUCCEEDED
finalize_installation
on_success
when
Gitlab
::
Kubernetes
::
Pod
::
FAILED
on_failed
else
...
...
@@ -18,23 +18,39 @@ module Clusters
private
def
on_success
app
.
make_installed!
ensure
remove_installation_pod
end
def
on_failed
app
.
make_errored!
(
installation_errors
||
'Installation silently failed'
)
finalize_installation
ensure
remove_installation_pod
end
def
check_timeout
if
Time
.
now
.
utc
-
app
.
updated_at
.
to_time
.
utc
>
ClusterWaitForAppInstallationWorker
::
TIMEOUT
app
.
make_errored!
(
'Installation timeouted'
)
finalize_installation
if
timeouted?
begin
app
.
make_errored!
(
'Installation timeouted'
)
ensure
remove_installation_pod
end
else
ClusterWaitForAppInstallationWorker
.
perform_in
(
ClusterWaitForAppInstallationWorker
::
INTERVAL
,
app
.
name
,
app
.
id
)
end
end
def
finalize_installation
FinalizeInstallationService
.
new
(
app
).
execute
def
timeouted?
Time
.
now
.
utc
-
app
.
updated_at
.
to_time
.
utc
>
ClusterWaitForAppInstallationWorker
::
TIMEOUT
end
def
remove_installation_pod
helm_api
.
delete_installation_pod!
(
app
)
rescue
# no-op
end
def
installation_phase
...
...
app/services/clusters/applications/finalize_installation_service.rb
已删除
100644 → 0
浏览文件 @
a46d3241
module
Clusters
module
Applications
class
FinalizeInstallationService
<
BaseHelmService
def
execute
helm_api
.
delete_installation_pod!
(
app
)
app
.
make_installed!
if
app
.
installing?
end
end
end
end
spec/services/clusters/applications/check_installation_progress_service_spec.rb
浏览文件 @
86d85317
...
...
@@ -9,8 +9,8 @@ describe Clusters::Applications::CheckInstallationProgressService do
let
(
:errors
)
{
nil
}
shared_examples
'a terminated installation'
do
it
'
finalize the installation
'
do
expect
(
service
).
to
receive
(
:
finalize_installation
).
once
it
'
removes the installation POD
'
do
expect
(
service
).
to
receive
(
:
remove_installation_pod
).
once
service
.
execute
end
...
...
@@ -23,7 +23,7 @@ describe Clusters::Applications::CheckInstallationProgressService do
context
'when not timeouted'
do
it
'reschedule a new check'
do
expect
(
ClusterWaitForAppInstallationWorker
).
to
receive
(
:perform_in
).
once
expect
(
service
).
not_to
receive
(
:
finalize_installation
)
expect
(
service
).
not_to
receive
(
:
remove_installation_pod
)
service
.
execute
...
...
@@ -53,7 +53,7 @@ describe Clusters::Applications::CheckInstallationProgressService do
expect
(
service
).
to
receive
(
:installation_phase
).
once
.
and_return
(
phase
)
allow
(
service
).
to
receive
(
:installation_errors
).
and_return
(
errors
)
allow
(
service
).
to
receive
(
:
finalize_installation
).
and_return
(
nil
)
allow
(
service
).
to
receive
(
:
remove_installation_pod
).
and_return
(
nil
)
end
describe
'#execute'
do
...
...
@@ -61,6 +61,15 @@ describe Clusters::Applications::CheckInstallationProgressService do
let
(
:phase
)
{
Gitlab
::
Kubernetes
::
Pod
::
SUCCEEDED
}
it_behaves_like
'a terminated installation'
it
'make the application installed'
do
expect
(
ClusterWaitForAppInstallationWorker
).
not_to
receive
(
:perform_in
)
service
.
execute
expect
(
application
).
to
be_installed
expect
(
application
.
status_reason
).
to
be_nil
end
end
context
'when installation POD failed'
do
...
...
spec/services/clusters/applications/finalize_installation_service_spec.rb
已删除
100644 → 0
浏览文件 @
a46d3241
require
'spec_helper'
describe
Clusters
::
Applications
::
FinalizeInstallationService
do
describe
'#execute'
do
let
(
:application
)
{
create
(
:applications_helm
,
:installing
)
}
let
(
:service
)
{
described_class
.
new
(
application
)
}
before
do
expect_any_instance_of
(
Gitlab
::
Kubernetes
::
Helm
).
to
receive
(
:delete_installation_pod!
).
with
(
application
)
end
context
'when installation POD succeeded'
do
it
'make the application installed'
do
service
.
execute
expect
(
application
).
to
be_installed
expect
(
application
.
status_reason
).
to
be_nil
end
end
context
'when installation POD failed'
do
let
(
:application
)
{
create
(
:applications_helm
,
:errored
)
}
it
'make the application errored'
do
service
.
execute
expect
(
application
).
to
be_errored
expect
(
application
.
status_reason
).
not_to
be_nil
end
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录