Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
apollo
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
apollo
Commits
e9459a21
Commit
e9459a21
authored
Jul 22, 2018
by
nobodyiam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow user to delete private namespace
parent
0c4069f9
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
32 deletions
+14
-32
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/NamespaceService.java
...rip/framework/apollo/portal/service/NamespaceService.java
+4
-8
apollo-portal/src/main/resources/static/config.html
apollo-portal/src/main/resources/static/config.html
+2
-4
apollo-portal/src/main/resources/static/scripts/directive/delete-namespace-modal-directive.js
...tic/scripts/directive/delete-namespace-modal-directive.js
+4
-19
apollo-portal/src/main/resources/static/views/component/delete-namespace-modal.html
...ources/static/views/component/delete-namespace-modal.html
+4
-1
No files found.
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/NamespaceService.java
View file @
e9459a21
...
@@ -74,26 +74,22 @@ public class NamespaceService {
...
@@ -74,26 +74,22 @@ public class NamespaceService {
@Transactional
@Transactional
public
void
deleteNamespace
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
)
{
public
void
deleteNamespace
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
)
{
//1. check private namespace
AppNamespace
appNamespace
=
appNamespaceService
.
findByAppIdAndName
(
appId
,
namespaceName
);
AppNamespace
appNamespace
=
appNamespaceService
.
findByAppIdAndName
(
appId
,
namespaceName
);
if
(
appNamespace
!=
null
&&
!
appNamespace
.
isPublic
())
{
throw
new
BadRequestException
(
"Private namespace can not be deleted"
);
}
//
2
. check parent namespace has not instances
//
1
. check parent namespace has not instances
if
(
namespaceHasInstances
(
appId
,
env
,
clusterName
,
namespaceName
))
{
if
(
namespaceHasInstances
(
appId
,
env
,
clusterName
,
namespaceName
))
{
throw
new
BadRequestException
(
"Can not delete namespace because namespace has active instances"
);
throw
new
BadRequestException
(
"Can not delete namespace because namespace has active instances"
);
}
}
//
3
. check child namespace has not instances
//
2
. check child namespace has not instances
NamespaceDTO
childNamespace
=
branchService
.
findBranchBaseInfo
(
appId
,
env
,
clusterName
,
namespaceName
);
NamespaceDTO
childNamespace
=
branchService
.
findBranchBaseInfo
(
appId
,
env
,
clusterName
,
namespaceName
);
if
(
childNamespace
!=
null
&&
if
(
childNamespace
!=
null
&&
namespaceHasInstances
(
appId
,
env
,
childNamespace
.
getClusterName
(),
namespaceName
))
{
namespaceHasInstances
(
appId
,
env
,
childNamespace
.
getClusterName
(),
namespaceName
))
{
throw
new
BadRequestException
(
"Can not delete namespace because namespace's branch has active instances"
);
throw
new
BadRequestException
(
"Can not delete namespace because namespace's branch has active instances"
);
}
}
//
4
. check public namespace has not associated namespace
//
3
. check public namespace has not associated namespace
if
(
appNamespace
!=
null
&&
publicAppNamespaceHasAssociatedNamespace
(
namespaceName
,
env
))
{
if
(
appNamespace
!=
null
&&
appNamespace
.
isPublic
()
&&
publicAppNamespaceHasAssociatedNamespace
(
namespaceName
,
env
))
{
throw
new
BadRequestException
(
"Can not delete public namespace which has associated namespaces"
);
throw
new
BadRequestException
(
"Can not delete public namespace which has associated namespaces"
);
}
}
...
...
apollo-portal/src/main/resources/static/config.html
View file @
e9459a21
...
@@ -288,8 +288,7 @@
...
@@ -288,8 +288,7 @@
apollo-detail=
"'发现有 <b>' + deleteNamespaceContext.namespace.instancesCount +
apollo-detail=
"'发现有 <b>' + deleteNamespaceContext.namespace.instancesCount +
'</b> 个实例正在使用Namespace(' + deleteNamespaceContext.namespace.baseInfo.namespaceName +
'</b> 个实例正在使用Namespace(' + deleteNamespaceContext.namespace.baseInfo.namespaceName +
'),删除Namespace将导致实例获取不到配置。<br>
'),删除Namespace将导致实例获取不到配置。<br>
请到 <ins>“实例列表”</ins> 确认实例信息,如已确认删除Namespace将不会导致实例异常,
请到 <ins>“实例列表”</ins> 确认实例信息,如确认相关实例都已经不再使用该Namespace配置,可以联系Apollo相关负责人删除实例信息(InstanceConfig)或等待实例24小时自动过期后再来删除。'"
请联系Apollo相关负责人删除Namespace'"
apollo-confirm=
"continueDeleteNamespace"
>
apollo-confirm=
"continueDeleteNamespace"
>
</apolloconfirmdialog>
</apolloconfirmdialog>
...
@@ -298,8 +297,7 @@
...
@@ -298,8 +297,7 @@
apollo-detail=
"'发现有 <b>' + deleteNamespaceContext.namespace.branch.latestReleaseInstances.total
apollo-detail=
"'发现有 <b>' + deleteNamespaceContext.namespace.branch.latestReleaseInstances.total
+ '</b> 个实例正在使用Namespace(' + deleteNamespaceContext.namespace.baseInfo.namespaceName +
+ '</b> 个实例正在使用Namespace(' + deleteNamespaceContext.namespace.baseInfo.namespaceName +
')灰度版本的配置,删除Namespace将导致实例获取不到配置。<br>
')灰度版本的配置,删除Namespace将导致实例获取不到配置。<br>
请到 <ins>“灰度版本” => “实例列表”</ins> 确认实例信息,如已确认删除Namespace将不会导致实例异常,
请到 <ins>“灰度版本” => “实例列表”</ins> 确认实例信息,如确认相关实例都已经不再使用该Namespace配置,可以联系Apollo相关负责人删除实例信息(InstanceConfig)或等待实例24小时自动过期后再来删除。'"
请联系Apollo相关负责人删除Namespace'"
apollo-confirm=
"continueDeleteNamespace"
>
apollo-confirm=
"continueDeleteNamespace"
>
</apolloconfirmdialog>
</apolloconfirmdialog>
...
...
apollo-portal/src/main/resources/static/scripts/directive/delete-namespace-modal-directive.js
View file @
e9459a21
...
@@ -18,25 +18,20 @@ function deleteNamespaceModalDirective($window, $q, toastr, AppUtil, EventManage
...
@@ -18,25 +18,20 @@ function deleteNamespaceModalDirective($window, $q, toastr, AppUtil, EventManage
var
toDeleteNamespace
=
context
.
namespace
;
var
toDeleteNamespace
=
context
.
namespace
;
scope
.
toDeleteNamespace
=
toDeleteNamespace
;
scope
.
toDeleteNamespace
=
toDeleteNamespace
;
//1. check namespace is not private
//1. check operator has master permission
if
(
!
checkNotPrivateNamespace
(
toDeleteNamespace
))
{
return
;
}
//2. check operator has master permission
checkPermission
(
toDeleteNamespace
).
then
(
function
()
{
checkPermission
(
toDeleteNamespace
).
then
(
function
()
{
//
3
. check namespace's master branch has not instances
//
2
. check namespace's master branch has not instances
if
(
!
checkMasterInstance
(
toDeleteNamespace
))
{
if
(
!
checkMasterInstance
(
toDeleteNamespace
))
{
return
;
return
;
}
}
//
4
. check namespace's gray branch has not instances
//
3
. check namespace's gray branch has not instances
if
(
!
checkBranchInstance
(
toDeleteNamespace
))
{
if
(
!
checkBranchInstance
(
toDeleteNamespace
))
{
return
;
return
;
}
}
if
(
toDeleteNamespace
.
isLinkedNamespace
)
{
if
(
!
toDeleteNamespace
.
isPublic
||
toDeleteNamespace
.
isLinkedNamespace
)
{
showDeleteNamespaceConfirmDialog
();
showDeleteNamespaceConfirmDialog
();
}
else
{
}
else
{
//5. check public namespace has not associated namespace
//5. check public namespace has not associated namespace
...
@@ -48,15 +43,6 @@ function deleteNamespaceModalDirective($window, $q, toastr, AppUtil, EventManage
...
@@ -48,15 +43,6 @@ function deleteNamespaceModalDirective($window, $q, toastr, AppUtil, EventManage
});
});
function
checkNotPrivateNamespace
(
namespace
)
{
if
(
!
namespace
.
isPublic
)
{
toastr
.
error
(
"
不能删除私有的Namespace
"
,
"
删除失败
"
);
return
false
;
}
return
true
;
}
function
checkPermission
(
namespace
)
{
function
checkPermission
(
namespace
)
{
var
d
=
$q
.
defer
();
var
d
=
$q
.
defer
();
...
@@ -153,7 +139,6 @@ function deleteNamespaceModalDirective($window, $q, toastr, AppUtil, EventManage
...
@@ -153,7 +139,6 @@ function deleteNamespaceModalDirective($window, $q, toastr, AppUtil, EventManage
function
showDeleteNamespaceConfirmDialog
()
{
function
showDeleteNamespaceConfirmDialog
()
{
AppUtil
.
showModal
(
'
#deleteNamespaceModal
'
);
AppUtil
.
showModal
(
'
#deleteNamespaceModal
'
);
}
}
function
doDeleteNamespace
()
{
function
doDeleteNamespace
()
{
...
...
apollo-portal/src/main/resources/static/views/component/delete-namespace-modal.html
View file @
e9459a21
...
@@ -8,9 +8,12 @@
...
@@ -8,9 +8,12 @@
删除Namespace
删除Namespace
</h4>
</h4>
</div>
</div>
<div
class=
"modal-body form-horizontal"
>
<div
class=
"modal-body form-horizontal"
ng-show=
"toDeleteNamespace.isPublic"
>
删除Namespace将导致实例获取不到此Namespace的配置,确定要删除吗?
删除Namespace将导致实例获取不到此Namespace的配置,确定要删除吗?
</div>
</div>
<div
class=
"modal-body form-horizontal"
ng-show=
"!toDeleteNamespace.isPublic"
>
删除私有Namespace将导致实例获取不到此Namespace的配置,而且无法在当前集群重新创建该Namespace(除非使用管理员工具把所有环境的AppNamespace删除后重建),确定要删除吗?
</div>
<div
class=
"modal-footer"
>
<div
class=
"modal-footer"
>
<button
type=
"button"
class=
"btn btn-default"
data-dismiss=
"modal"
>
<button
type=
"button"
class=
"btn btn-default"
data-dismiss=
"modal"
>
取消
取消
...
...
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