From 2f66a667ba6bed20003cfb17af3f347166e678c1 Mon Sep 17 00:00:00 2001 From: John Huang Date: Thu, 1 Feb 2024 10:39:54 +0800 Subject: [PATCH] refactor comments & function name for confuse (#15546) Co-authored-by: fuchanghai --- .../api/controller/K8sNamespaceController.java | 4 ++-- .../dolphinscheduler/api/service/K8sNamespaceService.java | 4 ++-- .../api/service/impl/K8SNamespaceServiceImpl.java | 4 ++-- .../api/service/K8SNamespaceServiceTest.java | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/K8sNamespaceController.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/K8sNamespaceController.java index f150f0c015..38b1923c82 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/K8sNamespaceController.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/K8sNamespaceController.java @@ -92,7 +92,7 @@ public class K8sNamespaceController extends BaseController { } /** - * create namespace,if not exist on k8s,will create,if exist only register in db + * register namespace in db,need to create namespace in k8s first * * @param loginUser * @param namespace k8s namespace @@ -111,7 +111,7 @@ public class K8sNamespaceController extends BaseController { @RequestParam(value = "namespace") String namespace, @RequestParam(value = "clusterCode") Long clusterCode) { Map result = - k8sNamespaceService.createK8sNamespace(loginUser, namespace, clusterCode); + k8sNamespaceService.registerK8sNamespace(loginUser, namespace, clusterCode); return returnDataList(result); } diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/K8sNamespaceService.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/K8sNamespaceService.java index daf988fdfe..032612a4ee 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/K8sNamespaceService.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/K8sNamespaceService.java @@ -41,14 +41,14 @@ public interface K8sNamespaceService { Result queryListPaging(User loginUser, String searchVal, Integer pageNo, Integer pageSize); /** - * create namespace,if not exist on k8s,will create,if exist only register in db + * register namespace in db,need to create namespace in k8s first * * @param loginUser login user * @param namespace namespace * @param clusterCode k8s not null * @return */ - Map createK8sNamespace(User loginUser, String namespace, Long clusterCode); + Map registerK8sNamespace(User loginUser, String namespace, Long clusterCode); /** * verify namespace and k8s diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/K8SNamespaceServiceImpl.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/K8SNamespaceServiceImpl.java index f05e69b9db..06f3608207 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/K8SNamespaceServiceImpl.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/K8SNamespaceServiceImpl.java @@ -100,7 +100,7 @@ public class K8SNamespaceServiceImpl extends BaseServiceImpl implements K8sNames } /** - * create namespace,if not exist on k8s,will create,if exist only register in db + * register namespace in db,need to create namespace in k8s first * * @param loginUser login user * @param namespace namespace @@ -108,7 +108,7 @@ public class K8SNamespaceServiceImpl extends BaseServiceImpl implements K8sNames * @return */ @Override - public Map createK8sNamespace(User loginUser, String namespace, Long clusterCode) { + public Map registerK8sNamespace(User loginUser, String namespace, Long clusterCode) { Map result = new HashMap<>(); if (isNotAdmin(loginUser)) { throw new ServiceException(Status.USER_NO_OPERATION_PERM); diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/K8SNamespaceServiceTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/K8SNamespaceServiceTest.java index b4b95ea497..6cc6f0d324 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/K8SNamespaceServiceTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/K8SNamespaceServiceTest.java @@ -107,16 +107,16 @@ public class K8SNamespaceServiceTest { public void createK8sNamespace() { // namespace is null Map result = - k8sNamespaceService.createK8sNamespace(getLoginUser(), null, clusterCode); + k8sNamespaceService.registerK8sNamespace(getLoginUser(), null, clusterCode); logger.info(result.toString()); Assertions.assertEquals(Status.REQUEST_PARAMS_NOT_VALID_ERROR, result.get(Constants.STATUS)); // k8s is null - result = k8sNamespaceService.createK8sNamespace(getLoginUser(), namespace, null); + result = k8sNamespaceService.registerK8sNamespace(getLoginUser(), namespace, null); logger.info(result.toString()); Assertions.assertEquals(Status.REQUEST_PARAMS_NOT_VALID_ERROR, result.get(Constants.STATUS)); // correct Mockito.when(clusterMapper.queryByClusterCode(Mockito.anyLong())).thenReturn(getCluster()); - result = k8sNamespaceService.createK8sNamespace(getLoginUser(), namespace, clusterCode); + result = k8sNamespaceService.registerK8sNamespace(getLoginUser(), namespace, clusterCode); logger.info(result.toString()); Assertions.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); }