From 695a19866d5a0bd41d395d5d8087aa95fa60057d Mon Sep 17 00:00:00 2001 From: jsonwan Date: Mon, 5 Dec 2022 22:14:08 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E5=AE=B9=E5=99=A8=E5=8C=96-=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E5=90=84=E5=BE=AE=E6=9C=8D=E5=8A=A1=E6=8C=89=E9=A1=BA?= =?UTF-8?q?=E5=BA=8F=E6=9B=B4=E6=96=B0=20#919?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 更正默认命名空间逻辑 --- .../src/main/java/com/tencent/bk/job/k8s/Consts.java | 2 ++ .../main/java/com/tencent/bk/job/k8s/ServiceDependModel.java | 2 +- .../main/java/com/tencent/bk/job/k8s/StartupController.java | 4 ++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/backend/job-tools/k8s-startup-controller/src/main/java/com/tencent/bk/job/k8s/Consts.java b/src/backend/job-tools/k8s-startup-controller/src/main/java/com/tencent/bk/job/k8s/Consts.java index ce4d209308..b541180b9c 100644 --- a/src/backend/job-tools/k8s-startup-controller/src/main/java/com/tencent/bk/job/k8s/Consts.java +++ b/src/backend/job-tools/k8s-startup-controller/src/main/java/com/tencent/bk/job/k8s/Consts.java @@ -27,6 +27,8 @@ public class Consts { // k8s命名空间 public static final String KEY_KUBERNETES_NAMESPACE = "KUBERNETES_NAMESPACE"; + // k8s默认命名空间 + public static final String VALUE_NAMESPACE_DEFAULT = "default"; // 服务启动依赖关系定义字符串 public static final String KEY_STARTUP_DEPENDENCIES_STR = "BK_JOB_STARTUP_DEPENDENCIES_STR"; // 当前服务名称 diff --git a/src/backend/job-tools/k8s-startup-controller/src/main/java/com/tencent/bk/job/k8s/ServiceDependModel.java b/src/backend/job-tools/k8s-startup-controller/src/main/java/com/tencent/bk/job/k8s/ServiceDependModel.java index 04567f2b2d..198f6c7d5b 100644 --- a/src/backend/job-tools/k8s-startup-controller/src/main/java/com/tencent/bk/job/k8s/ServiceDependModel.java +++ b/src/backend/job-tools/k8s-startup-controller/src/main/java/com/tencent/bk/job/k8s/ServiceDependModel.java @@ -30,7 +30,7 @@ @Data public class ServiceDependModel { @Parameter(names = {"-n", "--namespace"}, description = "当前服务所在的命名空间") - private String namespace = "default"; + private String namespace; @Parameter(names = {"-s", "--service"}, description = "当前服务名称") private String serviceName; diff --git a/src/backend/job-tools/k8s-startup-controller/src/main/java/com/tencent/bk/job/k8s/StartupController.java b/src/backend/job-tools/k8s-startup-controller/src/main/java/com/tencent/bk/job/k8s/StartupController.java index 856fd9a26a..d264f5d0a6 100644 --- a/src/backend/job-tools/k8s-startup-controller/src/main/java/com/tencent/bk/job/k8s/StartupController.java +++ b/src/backend/job-tools/k8s-startup-controller/src/main/java/com/tencent/bk/job/k8s/StartupController.java @@ -139,6 +139,10 @@ static ServiceDependModel parseDependModelFromArgsOrEnv(String[] args) { Consts.KEY_KUBERNETES_NAMESPACE, namespace ); + if (StringUtils.isBlank(namespace)) { + namespace = Consts.VALUE_NAMESPACE_DEFAULT; + log.warn("use default namespace:{}", namespace); + } serviceDependModel.setNamespace(namespace); } String serviceName = serviceDependModel.getServiceName();