Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow users to delete AppNamespace #4499

Merged
merged 68 commits into from
Aug 13, 2022
Merged
Show file tree
Hide file tree
Changes from 52 commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
fe75b4d
add tech-support-qq-4.png
klboke May 16, 2019
99bf97a
Update README.md
klboke May 16, 2019
1579f41
Merge remote-tracking branch 'upstream/master'
klboke Nov 11, 2020
9f65eed
Merge remote-tracking branch 'upstream/master'
klboke Dec 9, 2020
d7d3fd9
Enhance the user experience in the scenario of submitting duplicate keys
klboke Dec 11, 2020
7329fab
Merge branch 'master' into master
nobodyiam Dec 12, 2020
5def448
Modify the key-value conflict exception prompt, adjust the code style
klboke Dec 12, 2020
6942564
Merge branch 'master' into master
nobodyiam Dec 12, 2020
0fc1f91
Merge remote-tracking branch 'upstream/master'
klboke Dec 19, 2020
61ad016
Merge remote-tracking branch 'origin/master'
klboke Dec 19, 2020
587ce33
rge remote-tracking branch 'upstream/master'
klboke Mar 1, 2021
9de6563
Merge remote-tracking branch 'upstream/master'
klboke Mar 8, 2021
9aab632
Merge remote-tracking branch 'upstream/master'
klboke Mar 25, 2021
050dd0a
Merge branch 'ctripcorp:master' into master
klboke May 10, 2021
5a64035
Merge branch 'master' of github.com:klboke/apollo
klboke May 10, 2021
0648fbd
Merge branch 'ctripcorp:master' into master
klboke May 19, 2021
35bd3a6
Merge branch 'master' of github.com:klboke/apollo
klboke May 19, 2021
bc8149b
Merge branch 'ctripcorp:master' into master
klboke Jun 8, 2021
e771bdd
Merge branch 'master' of github.com:klboke/apollo
klboke Jun 8, 2021
9a1ad83
Merge branch 'ctripcorp:master' into master
klboke Jun 25, 2021
3efef37
Merge branch 'master' of github.com:klboke/apollo
klboke Jun 25, 2021
1274281
Merge branch 'apolloconfig:master' into master
klboke Sep 1, 2021
a968932
Merge branch 'master' of github.com:klboke/apollo
klboke Sep 1, 2021
df8942c
Merge branch 'apolloconfig:master' into master
klboke Jan 7, 2022
f98175a
Merge branch 'master' of github.com:klboke/apollo
klboke Jan 7, 2022
710cdd6
Merge branch 'apolloconfig:master' into master
klboke Feb 18, 2022
3c162b6
Merge branch 'master' of github.com:klboke/apollo
klboke Feb 18, 2022
0101a3f
Merge branch 'apolloconfig:master' into master
klboke Jun 17, 2022
cc6f568
Merge branch 'master' of github.com:klboke/apollo
klboke Jun 17, 2022
21dd30c
Merge branch 'apolloconfig:master' into master
klboke Jun 21, 2022
c1eeb41
Merge branch 'master' of github.com:klboke/apollo
klboke Jun 21, 2022
e85d645
Merge branch 'apolloconfig:master' into master
klboke Jun 27, 2022
8b0056d
Merge branch 'master' of github.com:klboke/apollo
klboke Jun 27, 2022
347e07b
Merge branch 'apolloconfig:master' into master
klboke Jul 1, 2022
d8eb437
Merge branch 'master' of github.com:klboke/apollo
klboke Jul 1, 2022
19bae52
Merge branch 'apolloconfig:master' into master
klboke Jul 4, 2022
7e40fa1
Merge branch 'master' of github.com:klboke/apollo
klboke Jul 4, 2022
fbbb02d
Merge branch 'apolloconfig:master' into master
klboke Jul 6, 2022
19cee24
Merge branch 'master' of github.com:klboke/apollo
klboke Jul 6, 2022
91ba3b7
Merge branch 'apolloconfig:master' into master
klboke Jul 8, 2022
94ad542
Merge branch 'master' of github.com:klboke/apollo
klboke Jul 8, 2022
64e1b0b
Merge branch 'apolloconfig:master' into master
klboke Jul 19, 2022
36ce5e2
Merge branch 'master' of github.com:klboke/apollo
klboke Jul 19, 2022
c1364c2
Merge branch 'apolloconfig:master' into master
klboke Jul 22, 2022
76ed2ea
Merge branch 'master' of github.com:klboke/apollo
klboke Jul 22, 2022
db8cf3d
Merge branch 'apolloconfig:master' into master
klboke Jul 26, 2022
3e4616d
Merge branch 'master' of github.com:klboke/apollo
klboke Jul 26, 2022
47297cc
Merge branch 'apolloconfig:master' into master
klboke Jul 30, 2022
1c320e7
Merge branch 'apolloconfig:master' into master
klboke Aug 2, 2022
e723db5
Merge branch 'master' of github.com:klboke/apollo
klboke Aug 2, 2022
df1dc49
refactor(apollo-portal): Allow users to delete AppNamespace(https://g…
klboke Aug 3, 2022
ef6325d
doc(CHANGES.md): update CHANGES.md
klboke Aug 3, 2022
f4c6881
Update apollo-portal/src/main/resources/static/i18n/en.json
klboke Aug 4, 2022
fae7f9f
Update apollo-portal/src/main/resources/static/i18n/zh-CN.json
klboke Aug 4, 2022
1be9790
Update apollo-portal/src/main/resources/static/i18n/zh-CN.json
klboke Aug 4, 2022
9dcc111
Merge branch 'master' into deleted-namespace
klboke Aug 9, 2022
d388f0e
feat(apollo-portal): Delete Namespace
klboke Aug 11, 2022
66ee7d6
Update apollo-portal/src/main/resources/static/i18n/en.json
klboke Aug 12, 2022
ecd91bc
Update apollo-portal/src/main/resources/static/i18n/en.json
klboke Aug 12, 2022
197b684
Update apollo-portal/src/main/resources/static/scripts/directive/dele…
klboke Aug 12, 2022
b0a5f45
Update apollo-portal/src/main/resources/static/scripts/directive/dele…
klboke Aug 12, 2022
4ec7117
Update apollo-portal/src/main/resources/static/scripts/directive/dele…
klboke Aug 12, 2022
19d8940
Update apollo-portal/src/main/resources/static/scripts/directive/dele…
klboke Aug 12, 2022
2c942f4
Update apollo-portal/src/main/resources/static/scripts/directive/dele…
klboke Aug 12, 2022
454488d
Update apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/…
klboke Aug 12, 2022
6c57b80
Update apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/…
klboke Aug 12, 2022
cb14888
feat(apollo-portal): Remove server-side delete Namespace check
klboke Aug 12, 2022
4696f13
Fix(apollo-portal): Fix NamespaceServiceTest test case
klboke Aug 12, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ Apollo 2.1.0
* [fix(#4474):'openjdk:8-jre-alpine' potentially causing wrong number of cpu cores](https://github.com/apolloconfig/apollo/pull/4475)
* [Switching spring-session serialization mode to json for compatibility with spring-security version updates]()
* [fix(#4483):Fixed overwrite JSON type configuration being empty](https://github.com/apolloconfig/apollo/pull/4486)

* [Allow users to delete AppNamespace](https://github.com/apolloconfig/apollo/pull/4499)
------------------
All issues and pull requests are [here](https://github.com/apolloconfig/apollo/milestone/11?closed=1)
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,21 @@ public ResponseEntity<Void> createNamespace(@PathVariable String appId,
}

@PreAuthorize(value = "@permissionValidator.hasDeleteNamespacePermission(#appId)")
@DeleteMapping("/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName:.+}")
public ResponseEntity<Void> deleteNamespace(@PathVariable String appId, @PathVariable String env,
@PathVariable String clusterName, @PathVariable String namespaceName) {
@DeleteMapping("/apps/{appId}/envs/{env}/clusters/{clusterName}/linked-namespaces/{namespaceName:.+}")
public ResponseEntity<Void> deleteLinkedNamespace(@PathVariable String appId, @PathVariable String env,
@PathVariable String clusterName, @PathVariable String namespaceName) {

namespaceService.deleteNamespace(appId, Env.valueOf(env), clusterName, namespaceName);

return ResponseEntity.ok().build();
}

@PreAuthorize(value = "@permissionValidator.hasDeleteNamespacePermission(#appId)")
klboke marked this conversation as resolved.
Show resolved Hide resolved
@DeleteMapping("/apps/{appId}/namespaces/{namespaceName:.+}")
public ResponseEntity<Void> deleteNamespace(@PathVariable String appId, @PathVariable String namespaceName) {
return this.deleteAppNamespace(appId, namespaceName);
}

@PreAuthorize(value = "@permissionValidator.isSuperAdmin()")
@DeleteMapping("/apps/{appId}/appnamespaces/{namespaceName:.+}")
public ResponseEntity<Void> deleteAppNamespace(@PathVariable String appId, @PathVariable String namespaceName) {
Expand Down
9 changes: 5 additions & 4 deletions apollo-portal/src/main/resources/static/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@
"Common.Operation": "Operation",
"Common.Delete": "Delete",
"Component.DeleteNamespace.Title": "Delete Namespace",
"Component.DeleteNamespace.PublicContent": "Deleting namespace will cause the instances unable to get the configuration of this namespace. Are you sure to delete it?",
"Component.DeleteNamespace.PrivateContent": "Deleting a private Namespace will cause the instances unable to get the configuration of this namespace, and the page will prompt 'missing namespace' (unless the AppNamespace is deleted by admin tool). Are you sure to delete it?",
"Component.DeleteNamespace.PublicContent": "Note, that the public Namespace for all environments will be deleted! This will cause the instance and the associated Namespace to fail to obtain the configuration of this Namespace. Are you sure you want to delete it?",
"Component.DeleteNamespace.PrivateContent": "Note, that the private Namespace for all environments will be deleted! This will cause the instance to not get the configuration of this namespace. Are you sure you want to delete it?",
"Component.DeleteNamespace.LinkedContent": "Note, that the namespace associated with the current environment will be deleted! This will cause the instance to not get the configuration of this namespace. Are you sure you want to delete it?",
klboke marked this conversation as resolved.
Show resolved Hide resolved
"Component.GrayscalePublishRule.Title": "Edit Grayscale Rule",
"Component.GrayscalePublishRule.AppId": "Grayscale AppId",
"Component.GrayscalePublishRule.AcceptRule": "Grayscale Application Rule",
Expand Down Expand Up @@ -428,8 +429,8 @@
"Delete.ClusterNameTips": "(Please query cluster information before deletion)",
"Delete.ClusterInfo": "Cluster information",
"Delete.DeleteNamespace": "Delete AppNamespace",
"Delete.DeleteNamespaceTips": "(Note that Namespace and AppNamespace in all environments will be deleted! If you just want to delete the namespace of some environment, let the user delete it on the project page!",
"Delete.DeleteNamespaceTips2": "Currently users can delete the associated namespace and private namespace by themselves, but they can not delete the AppNamespace. Because deleting AppNamespace has very large impacts, it is only allowed to be deleted by system administrators for the time being. For public Namespace, it is necessary to ensure that no application associates the AppNamespace",
"Delete.DeleteNamespaceTips": "(Note that Namespace and AppNamespace in all environments will be deleted!",
"Delete.DeleteNamespaceTips2": "For public Namespace, it is necessary to ensure that no application associates the AppNamespace",
"Delete.AppNamespaceName": "AppNamespace name",
"Delete.AppNamespaceNameTips": "(For non-properties namespaces, please add the suffix, such as apollo.xml)",
"Delete.AppNamespaceInfo": "AppNamespace Information",
Expand Down
9 changes: 5 additions & 4 deletions apollo-portal/src/main/resources/static/i18n/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@
"Common.Operation": "操作",
"Common.Delete": "删除",
"Component.DeleteNamespace.Title": "删除 Namespace",
"Component.DeleteNamespace.PublicContent": "删除 Namespace 将导致实例获取不到此 Namespace 的配置,确定要删除吗?",
"Component.DeleteNamespace.PrivateContent": "删除私有 Namespace 将导致实例获取不到此 Namespace 的配置,且页面会提示缺失 Namespace(除非使用管理员工具删除 AppNamespace),确定要删除吗?",
"Component.DeleteNamespace.PublicContent": "注意,所有环境的公共 Namespace 都会被删除!这将导致实例以及关联的 Namespace 获取不到此 Namespace 的配置,确定要删除吗?",
"Component.DeleteNamespace.PrivateContent": "注意,所有环境的私有 Namespace 都会被删除!这将导致实例获取不到此 Namespace 的配置,确定要删除吗?",
"Component.DeleteNamespace.LinkedContent": "注意,当前环境关联的 Namespace 会被删除!这将导致实例获取不到此 Namespace 的配置,确定要删除吗?",
klboke marked this conversation as resolved.
Show resolved Hide resolved
"Component.GrayscalePublishRule.Title": "编辑灰度规则",
"Component.GrayscalePublishRule.AppId": "灰度的 AppId",
"Component.GrayscalePublishRule.AcceptRule": "灰度应用规则",
Expand Down Expand Up @@ -428,8 +429,8 @@
"Delete.ClusterNameTips": "(删除前请先查询应用集群信息)",
"Delete.ClusterInfo": "集群信息",
"Delete.DeleteNamespace": "删除 AppNamespace",
"Delete.DeleteNamespaceTips": "(注意,所有环境的 Namespace 和 AppNamespace 都会被删除!如果只是要删除某个环境的 Namespace,让用户到应用页面中自行删除!)",
"Delete.DeleteNamespaceTips2": "目前用户可以自行删除关联的 Namespace 和私有的 Namespace,不过无法删除 AppNamespace 元信息,因为删除 AppNamespace 影响面较大,所以现在暂时只允许系统管理员删除,对于公共 Namespace 需要确保没有应用关联了该 AppNamespace。",
"Delete.DeleteNamespaceTips": "(注意,所有环境的 Namespace 和 AppNamespace 都会被删除!)",
klboke marked this conversation as resolved.
Show resolved Hide resolved
"Delete.DeleteNamespaceTips2": "对于公共 Namespace 需要确保没有应用关联了该 AppNamespace。",
"Delete.AppNamespaceName": "AppNamespace 名称",
"Delete.AppNamespaceNameTips": "(非 properties 类型的 Namespace 请加上类型后缀,例如 apollo.xml)",
"Delete.AppNamespaceInfo": "AppNamespace 信息",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ function deleteNamespaceModalDirective($window, $q, $translate, toastr, AppUtil,
},
link: function (scope) {



scope.doDeleteNamespace = doDeleteNamespace;

EventManager.subscribe(EventManager.EventType.PRE_DELETE_NAMESPACE, function (context) {
Expand All @@ -39,24 +37,18 @@ function deleteNamespaceModalDirective($window, $q, $translate, toastr, AppUtil,
//1. check operator has master permission
checkPermission(toDeleteNamespace).then(function () {

//2. check namespace's master branch has not instances
if (!checkMasterInstance(toDeleteNamespace)) {
return;
}

//3. check namespace's gray branch has not instances
if (!checkBranchInstance(toDeleteNamespace)) {
return;
}
if(toDeleteNamespace.isLinkedNamespace){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For public and private namespaces, I think we still need to check the instances bycheckMasterInstance and checkBranchInstance?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Here it is considered that the user delete action is expected.
  • Only the current environment and the usage of the current cluster can be checked here, and deleting the AppNamespace will affect all clusters, so the logic here remains consistent with the administrator's deletion
  • Or, is there a need to check the usage of all clusters in all environments?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, there is a detailed message indicating that this operation will cause the instances unable to get the configuration, so I think it's ok to not checkMasterInstance and checkBranchInstance.
If we don't check for public and private namespaces, I suppose we don't need to check for linked namespaces?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we don't check for public and private namespaces, I suppose we don't need to check for linked namespaces?

Yes, I think they are the same type of problem

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So maybe we could simplify the logic as the following?

                //1. check operator has master permission
                checkPermission(toDeleteNamespace).then(function () {

                    if (!toDeleteNamespace.isPublic || toDeleteNamespace.isLinkedNamespace) {
                        showDeleteNamespaceConfirmDialog();
                    } else {
                        //2. check public namespace has not associated namespace
                        checkPublicNamespace(toDeleteNamespace).then(function () {
                            showDeleteNamespaceConfirmDialog();
                        });
                    }
                })

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic for deleting different types of Namespace on the user side has been unified, and a uniform instance usage prompt message is added before deletion, e.g.

  • Delete private Namespace

image

image

  • Delete public Namespace

image

image

  • Delete linked Namespace

image

image

klboke marked this conversation as resolved.
Show resolved Hide resolved
//2. check namespace's master branch has not instances
if (!checkMasterInstance(toDeleteNamespace)) {
return;
}

if (!toDeleteNamespace.isPublic || toDeleteNamespace.isLinkedNamespace) {
showDeleteNamespaceConfirmDialog();
} else {
//5. check public namespace has not associated namespace
checkPublicNamespace(toDeleteNamespace).then(function () {
klboke marked this conversation as resolved.
Show resolved Hide resolved
showDeleteNamespaceConfirmDialog();
});
//3. check namespace's gray branch has not instances
if (!checkBranchInstance(toDeleteNamespace)) {
return;
}
}
showDeleteNamespaceConfirmDialog();
})

});
Expand Down Expand Up @@ -124,6 +116,9 @@ function deleteNamespaceModalDirective($window, $q, $translate, toastr, AppUtil,
return true;
}

/**
* @deprecated
*/
function checkPublicNamespace(namespace) {
var d = $q.defer();

Expand Down Expand Up @@ -162,9 +157,10 @@ function deleteNamespaceModalDirective($window, $q, $translate, toastr, AppUtil,

function doDeleteNamespace() {
var toDeleteNamespace = scope.toDeleteNamespace;
NamespaceService.deleteNamespace(toDeleteNamespace.baseInfo.appId, scope.env,
toDeleteNamespace.baseInfo.clusterName,
toDeleteNamespace.baseInfo.namespaceName)
if(toDeleteNamespace.isLinkedNamespace){
NamespaceService.deleteLinkedNamespace(toDeleteNamespace.baseInfo.appId, scope.env,
toDeleteNamespace.baseInfo.clusterName,
toDeleteNamespace.baseInfo.namespaceName)
.then(function () {
toastr.success($translate.instant('Common.Deleted'));

Expand All @@ -175,7 +171,20 @@ function deleteNamespaceModalDirective($window, $q, $translate, toastr, AppUtil,
}, function (result) {
AppUtil.showErrorMsg(result, $translate.instant('Common.DeleteFailed'));
})
}else {
klboke marked this conversation as resolved.
Show resolved Hide resolved
NamespaceService.deleteNamespace(toDeleteNamespace.baseInfo.appId,
toDeleteNamespace.baseInfo.namespaceName)
.then(function () {
toastr.success($translate.instant('Common.Deleted'));

setTimeout(function () {
$window.location.reload();
}, 1000);

}, function (result) {
AppUtil.showErrorMsg(result, $translate.instant('Common.DeleteFailed'));
})
}
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ appService.service("NamespaceService", ['$resource', '$q', 'AppUtil', function (
},
deleteNamespace: {
method: 'DELETE',
url: AppUtil.prefixPath() + '/apps/:appId/envs/:env/clusters/:clusterName/namespaces/:namespaceName'
url: AppUtil.prefixPath() + '/apps/:appId/namespaces/:namespaceName'
},
deleteLinkedNamespace: {
method: 'DELETE',
url: AppUtil.prefixPath() + '/apps/:appId/envs/:env/clusters/:clusterName/linked-namespaces/:namespaceName'
},
getPublicAppNamespaceAllNamespaces: {
method: 'GET',
Expand Down Expand Up @@ -102,12 +106,10 @@ appService.service("NamespaceService", ['$resource', '$q', 'AppUtil', function (
return d.promise;
}

function deleteNamespace(appId, env, clusterName, namespaceName) {
function deleteNamespace(appId, namespaceName) {
var d = $q.defer();
namespace_source.deleteNamespace({
appId: appId,
env: env,
clusterName: clusterName,
namespaceName: namespaceName
},
function (result) {
Expand All @@ -120,6 +122,24 @@ appService.service("NamespaceService", ['$resource', '$q', 'AppUtil', function (
return d.promise;
}

function deleteLinkedNamespace(appId, env, clusterName, namespaceName) {
var d = $q.defer();
namespace_source.deleteLinkedNamespace({
appId: appId,
env: env,
clusterName: clusterName,
namespaceName: namespaceName
},
function (result) {
d.resolve(result);
},
function (result) {
d.reject(result);
});

return d.promise;
}

function getPublicAppNamespaceAllNamespaces(env, publicNamespaceName, page, size) {
var d = $q.defer();
namespace_source.getPublicAppNamespaceAllNamespaces({
Expand Down Expand Up @@ -175,6 +195,7 @@ appService.service("NamespaceService", ['$resource', '$q', 'AppUtil', function (
createAppNamespace: createAppNamespace,
getNamespacePublishInfo: getNamespacePublishInfo,
deleteNamespace: deleteNamespace,
deleteLinkedNamespace: deleteLinkedNamespace,
getPublicAppNamespaceAllNamespaces: getPublicAppNamespaceAllNamespaces,
loadAppNamespace: loadAppNamespace,
deleteAppNamespace: deleteAppNamespace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ <h4 class="modal-title">
{{'Component.DeleteNamespace.Title' | translate }}
</h4>
</div>
<div class="modal-body form-horizontal" ng-show="toDeleteNamespace.isPublic">
<div class="modal-body form-horizontal" ng-show="toDeleteNamespace.isPublic && !toDeleteNamespace.isLinkedNamespace">
{{'Component.DeleteNamespace.PublicContent' | translate }}
</div>
<div class="modal-body form-horizontal" ng-show="toDeleteNamespace.isPublic && toDeleteNamespace.isLinkedNamespace">
{{'Component.DeleteNamespace.LinkedContent' | translate }}
</div>
<div class="modal-body form-horizontal" ng-show="!toDeleteNamespace.isPublic">
{{'Component.DeleteNamespace.PrivateContent' | translate }}
</div>
Expand Down