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

bugfix: 去除k8s负载中重复定义的环境变量 #1828 #1844

Merged
merged 1 commit into from
Mar 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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