Skip to content

Commit

Permalink
Merge pull request #1844 from jsonwan/3.6.x
Browse files Browse the repository at this point in the history
bugfix: 去除k8s负载中重复定义的环境变量 #1828
  • Loading branch information
wangyu096 authored Mar 17, 2023
2 parents 06ae3df + 65a26bb commit 66125ca
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
1240003=错误的请求
1240004=Cookie过期或者不存在
1240005=服务认证失败
1240006=配置异常:{0}

##系统错误-公共组件错误
1250001=Redis服务连接失败
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
1240003=Bad Request
1240004=Cookies expire or do not exist
1240005=Service auth fail
1240006=Invalid config:{0}

## System error - common components
1250001=Redis service connection failed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
1240003=Bad Request
1240004=Cookies expire or do not exist
1240005=Service auth fail
1240006=Invalid config:{0}

## System error - common components
1250001=Redis service connection failed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
1240003=错误的请求
1240004=Cookie过期或者不存在
1240005=服务认证失败
1240006=配置异常:{0}

##系统错误-公共组件错误
1250001=Redis服务连接失败
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
1240003=错误的请求
1240004=Cookie过期或者不存在
1240005=服务认证失败
1240006=配置异常:{0}

##系统错误-公共组件错误
1250001=Redis服务连接失败
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,8 @@ public class ErrorCode {
public static final int SERVICE_UNAVAILABLE = 1240001;
// 服务认证失败
public static final int SERVICE_AUTH_FAIL = 1240005;
// 配置异常:{0}
public static final int INVALID_CONFIG = 1240006;

// ========= 系统错误-API通用 ==================//
// IP:{}无访问权限
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.tencent.bk.job.common.exception;

import lombok.Getter;
import lombok.ToString;

/**
* 内部服务异常--配置异常
*/
@Getter
@ToString
public class IncorrectConfigException extends InternalException {

public IncorrectConfigException(String message, Integer errorCode, Object[] errorParams) {
super(message, errorCode, errorParams);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.tencent.bk.job.file.worker.cos.service;

import com.tencent.bk.job.common.constant.ErrorCode;
import com.tencent.bk.job.common.constant.JobConstants;
import com.tencent.bk.job.common.exception.IncorrectConfigException;
import com.tencent.bk.job.common.util.ip.IpUtils;
import com.tencent.bk.job.file.worker.config.WorkerConfig;
import io.micrometer.core.instrument.util.StringUtils;
Expand Down Expand Up @@ -37,8 +39,24 @@ public boolean isInK8s() {
}

private String getAccessHostInK8s() {
String podName = System.getenv("BK_JOB_POD_NAME");
String podName = System.getenv("BK_JOB_FILE_WORKER_POD_NAME");
if (StringUtils.isBlank(podName)) {
String message = "ENV BK_JOB_FILE_WORKER_POD_NAME cannot be blank!";
throw new IncorrectConfigException(
message,
ErrorCode.INVALID_CONFIG,
new String[]{"ENV:BK_JOB_FILE_WORKER_POD_NAME"}
);
}
String fileWorkerServiceName = System.getenv("BK_JOB_FILE_WORKER_SERVICE_NAME");
if (StringUtils.isBlank(fileWorkerServiceName)) {
String message = "ENV BK_JOB_FILE_WORKER_SERVICE_NAME cannot be blank!";
throw new IncorrectConfigException(
message,
ErrorCode.INVALID_CONFIG,
new String[]{"ENV:BK_JOB_FILE_WORKER_SERVICE_NAME"}
);
}
String accessHost = podName + "." + fileWorkerServiceName;
log.debug("accessHost={}", accessHost);
return accessHost;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ spec:
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: BK_JOB_POD_NAME
- name: BK_JOB_FILE_WORKER_POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
Expand Down

0 comments on commit 66125ca

Please sign in to comment.