Skip to content

Commit

Permalink
Merge pull request #1721 from jsonwan/github_master
Browse files Browse the repository at this point in the history
Merge: 3.6.x->master
  • Loading branch information
jsonwan authored Feb 3, 2023
2 parents b7606f9 + fcaa713 commit c650ccc
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@

package com.tencent.bk.job.common.cc.model;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.tencent.bk.job.common.util.ip.IpUtils;
import lombok.Getter;
import lombok.Setter;

Expand All @@ -37,7 +39,7 @@ public class CcHostInfoDTO {
@JsonProperty("bk_host_id")
private Long hostId;
@JsonProperty("bk_host_innerip")
private String ip;
private String innerIp;
@JsonProperty("bk_host_innerip_v6")
private String ipv6;
@JsonProperty("bk_agent_id")
Expand All @@ -48,4 +50,9 @@ public class CcHostInfoDTO {
private String os;
@JsonProperty("bk_cloud_id")
private Long cloudId;

@JsonIgnore
public String getFirstIp() {
return IpUtils.getFirstIpFromMultiIp(innerIp, ",");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@

package com.tencent.bk.job.common.cc.model;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.tencent.bk.job.common.util.ip.IpUtils;
import lombok.Data;

import java.util.List;
Expand All @@ -43,7 +45,7 @@ public class DynamicGroupHostPropDTO {

// 可能为多个ip
@JsonProperty("bk_host_innerip")
private String ip;
private String innerIp;

// 可能为多个ip
@JsonProperty("bk_host_innerip_v6")
Expand All @@ -56,4 +58,8 @@ public class DynamicGroupHostPropDTO {
@JsonProperty("bk_cloud_id")
private List<CcCloudIdDTO> cloudIdList;

@JsonIgnore
public String getFirstIp() {
return IpUtils.getFirstIpFromMultiIp(innerIp, ",");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,8 @@ private ApplicationHostDTO convertHost(long bizId, CcHostInfoDTO ccHostInfo) {
log.warn("Host does not have cloud area id!|{}", ccHostInfo);
return null;
}
hostDTO.setIp(ccHostInfo.getIp());
hostDTO.setDisplayIp(ccHostInfo.getInnerIp());
hostDTO.setIp(ccHostInfo.getFirstIp());
hostDTO.setIpv6(ccHostInfo.getIpv6());
hostDTO.setAgentId(ccHostInfo.getAgentId());
hostDTO.setBizId(bizId);
Expand Down Expand Up @@ -809,7 +810,7 @@ private List<DynamicGroupHostPropDTO> convertToCcGroupHostPropList(List<CcHostIn
log.warn(
"host(id={},ip={}) does not have cloud area, ignore",
ccHostInfo.getHostId(),
ccHostInfo.getIp()
ccHostInfo.getInnerIp()
);
} else if (ccHostInfo.getHostId() == null) {
log.warn("{} hostId is invalid, ignore", ccHostInfo);
Expand Down Expand Up @@ -865,7 +866,7 @@ private DynamicGroupHostPropDTO convertToCcHost(CcHostInfoDTO ccHostInfo) {
DynamicGroupHostPropDTO dynamicGroupHostPropDTO = new DynamicGroupHostPropDTO();
dynamicGroupHostPropDTO.setId(ccHostInfo.getHostId());
dynamicGroupHostPropDTO.setName(ccHostInfo.getHostName());
dynamicGroupHostPropDTO.setIp(ccHostInfo.getIp());
dynamicGroupHostPropDTO.setInnerIp(ccHostInfo.getInnerIp());
dynamicGroupHostPropDTO.setIpv6(ccHostInfo.getIpv6());
dynamicGroupHostPropDTO.setAgentId(ccHostInfo.getAgentId());
CcCloudIdDTO ccCloudIdDTO = new CcCloudIdDTO();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -434,4 +434,21 @@ public static Long extractBkCloudId(String cloudIp) {
String bkCloudId = cloudIp.substring(0, idx);
return Long.parseLong(bkCloudId);
}

/**
* 从含有多个IP的字符串中获取首个IP,若multiIp不含有任何IP则直接返回multiIp本身
*
* @param multiIp 多IP字符串
* @param separator 分隔符
* @return 首个IP
*/
public static String getFirstIpFromMultiIp(String multiIp, String separator) {
if (StringUtils.isBlank(multiIp)) {
return multiIp;
}
if (multiIp.contains(separator)) {
return multiIp.split(separator)[0];
}
return multiIp;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,13 @@ void testExtractBkCloudId() {
bkCloudId = IpUtils.extractBkCloudId(cloudIpv6);
assertThat(bkCloudId).isEqualTo(0L);
}

@Test
void testGetFirstIpFromMultiIp() {
assertThat(IpUtils.getFirstIpFromMultiIp(null, ",")).isNull();
assertThat(IpUtils.getFirstIpFromMultiIp("", ",")).isEqualTo("");
assertThat(IpUtils.getFirstIpFromMultiIp("192.168.1.1", ",")).isEqualTo("192.168.1.1");
assertThat(IpUtils.getFirstIpFromMultiIp("192.168.1.1,", ",")).isEqualTo("192.168.1.1");
assertThat(IpUtils.getFirstIpFromMultiIp("192.168.1.1,192.168.1.2", ",")).isEqualTo("192.168.1.1");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -193,19 +193,19 @@ public List<HostDTO> getHostsByDynamicGroupId(long appId, String groupId) {
List<CcCloudIdDTO> hostCloudIdList = hostProp.getCloudIdList();
if (hostCloudIdList == null || hostCloudIdList.isEmpty()) {
log.warn("Get ip by dynamic group id, cmdb return illegal host, skip it!appId={}, groupId={}, " +
"hostIp={}", appId, groupId, hostProp.getIp());
"hostIp={}", appId, groupId, hostProp.getInnerIp());
continue;
}
CcCloudIdDTO hostCloudId = hostCloudIdList.get(0);
if (hostCloudId == null) {
log.warn("Get ip by dynamic group id, cmdb return illegal host, skip it!appId={}, groupId={}, " +
"hostIp={}", appId, groupId, hostProp.getIp());
"hostIp={}", appId, groupId, hostProp.getInnerIp());
continue;
}
HostDTO host = new HostDTO();
host.setHostId(hostProp.getId());
host.setBkCloudId(hostCloudId.getInstanceId());
host.setIp(hostProp.getIp());
host.setIp(hostProp.getFirstIp());
host.setIpv6(hostProp.getIpv6());
host.setAgentId(hostProp.getAgentId());
hostList.add(host);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ public class JobManageConfig {
@Value("${job.web.url:}")
private String jobWebUrl;

@Value("${bk.helper.url:}")
private String bkHelperUrl;

@Value("${bk.doc.root:}")
private String bkDocRoot;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ public List<DynamicGroupWithHost> getBizDynamicGroupHostList(String username,
List<String> cloudIpList = new ArrayList<>();
for (DynamicGroupHostPropDTO groupHostProp : dynamicGroupHostProps) {
if (CollectionUtils.isNotEmpty(groupHostProp.getCloudIdList())) {
cloudIpList.add(groupHostProp.getCloudIdList().get(0).getInstanceId() + ":" + groupHostProp.getIp());
cloudIpList.add(groupHostProp.getCloudIdList().get(0).getInstanceId() + ":" + groupHostProp.getFirstIp());
} else {
log.warn("Wrong host info! No cloud area!|{}", groupHostProp);
}
Expand Down
9 changes: 9 additions & 0 deletions support-files/kubernetes/charts/bk-job/VALUES_LOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,15 @@ fileWorkerConfig:
port: 19810
```

## 0.2.2-rc.7
1.增加文档中心与问题反馈URL配置项
```shell script
# 文档中心 url
bkDocsCenterUrl: "https://bk.tencent.com/docs"
# 问题反馈 url
bkFeedBackUrl: "https://bk.tencent.com/s-mart/community"
```

## 0.2.2-rc.1
1.增加权限中心系统ID配置:
```shell script
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,9 @@ data:
max-request-size: 5GB
bk:
doc:
root:
root: {{ .Values.bkDocsCenterUrl }}
feedback:
root:
helper:
url:
root: {{ .Values.bkFeedBackUrl }}
job:
manage:
sync:
Expand Down
4 changes: 4 additions & 0 deletions support-files/kubernetes/charts/bk-job/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,10 @@ bkRepoUrl: "http://bkrepo.example.com"
bkNodemanUrl: "http://nodeman.example.com"
# 蓝鲸 GSE API Gateway url
bkGseApiGatewayUrl: "http://bkapi.example.com"
# 文档中心 url
bkDocsCenterUrl: "https://bk.tencent.com/docs"
# 问题反馈 url
bkFeedBackUrl: "https://bk.tencent.com/s-mart/community"

## 蓝鲸GSE参数配置
gse:
Expand Down
3 changes: 0 additions & 3 deletions support-files/templates/#etc#job#job-manage#job-manage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ bk:
feedback:
# 首页右上角问题反馈链接
root:
helper:
# 首页底部联系BK助手的跳转URL(可为企业微信URL)
url: wxwork://message?uin=8444252571319680
job:
manage:
sync:
Expand Down

0 comments on commit c650ccc

Please sign in to comment.