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

fix: 主机AgentId更新后,小概率出现使用旧AgentId下发任务 #2142 #2178

Merged
merged 3 commits into from
Jun 30, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ public class FindModuleHostRelationReq extends EsbReq {
private List<Long> moduleIdList;

@JsonProperty("module_fields")
private List<String> moduleFields = Arrays.asList("bk_module_id", "bk_set_id");
private List<String> moduleFields = Arrays.asList("bk_module_id", "bk_set_id", "last_time");

@JsonProperty("host_fields")
private List<String> hostFields = Arrays.asList("bk_host_id", "bk_host_innerip", "bk_host_innerip_v6",
"bk_agent_id", "bk_host_name", "bk_os_name", "bk_cloud_id", "bk_os_type", "bk_cloud_vendor");
"bk_agent_id", "bk_host_name", "bk_os_name", "bk_cloud_id", "bk_os_type", "bk_cloud_vendor", "last_time");

private Page page;
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@

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

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.util.List;

Expand All @@ -39,47 +35,4 @@ public class FindModuleHostRelationResult {

private List<HostWithModules> relation;

@Getter
@Setter
@ToString
public static class HostWithModules {
private HostProp host;
private List<ModuleProp> modules;
}

@Getter
@Setter
@ToString
public static class HostProp {
@JsonProperty("bk_host_id")
private Long hostId;
@JsonProperty("bk_host_innerip")
private String ip;
@JsonProperty("bk_host_innerip_v6")
private String ipv6;
@JsonProperty("bk_agent_id")
private String agentId;
@JsonProperty("bk_host_name")
private String hostName;
@JsonProperty("bk_os_name")
private String osName;
@JsonProperty("bk_os_type")
private String osType;
@JsonProperty("bk_cloud_id")
private Long cloudAreaId = 0L;
@JsonProperty("bk_cloud_vendor")
private String cloudVendorId;
}

@Getter
@Setter
@ToString
public static class ModuleProp {
@JsonProperty("bk_module_id")
private Long moduleId;
@JsonProperty("bk_set_id")
private Long setId;
@JsonProperty("bk_module_type")
private String moduleType;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import com.tencent.bk.job.common.model.dto.ApplicationHostDTO;
import com.tencent.bk.job.common.util.StringUtil;
import com.tencent.bk.job.common.util.TimeUtil;
import lombok.Data;

import java.util.List;
Expand Down Expand Up @@ -62,6 +63,9 @@ public class HostEventDetail {
@JsonProperty("bk_cloud_vendor")
private String cloudVendorId;

@JsonProperty("last_time")
private String lastTime;

public static ApplicationHostDTO toHostInfoDTO(HostEventDetail eventDetail) {
ApplicationHostDTO hostInfoDTO = new ApplicationHostDTO();
hostInfoDTO.setHostId(eventDetail.hostId);
Expand All @@ -78,6 +82,7 @@ public static ApplicationHostDTO toHostInfoDTO(HostEventDetail eventDetail) {
hostInfoDTO.setOsType(eventDetail.osType);
hostInfoDTO.setCloudAreaId(Long.parseLong(eventDetail.getCloudId()));
hostInfoDTO.setCloudVendorId(eventDetail.cloudVendorId);
hostInfoDTO.setLastTime(TimeUtil.parseIsoZonedTimeToMillis(eventDetail.getLastTime()));
return hostInfoDTO;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
* Tencent is pleased to support the open source community by making BK-JOB蓝鲸智云作业平台 available.
*
* Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
*
* BK-JOB蓝鲸智云作业平台 is licensed under the MIT License.
*
* License for BK-JOB蓝鲸智云作业平台:
* --------------------------------------------------------------------
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
* to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of
* the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
* THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/

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


import com.fasterxml.jackson.annotation.JsonProperty;
import com.tencent.bk.job.common.model.dto.ApplicationHostDTO;
import com.tencent.bk.job.common.util.StringUtil;
import com.tencent.bk.job.common.util.TimeUtil;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.util.List;

@Getter
@Setter
@ToString
public class HostProp {
@JsonProperty("bk_host_id")
private Long hostId;
@JsonProperty("bk_host_innerip")
private String ip;
@JsonProperty("bk_host_innerip_v6")
private String ipv6;
@JsonProperty("bk_agent_id")
private String agentId;
@JsonProperty("bk_host_name")
private String hostName;
@JsonProperty("bk_os_name")
private String osName;
@JsonProperty("bk_os_type")
private String osType;
@JsonProperty("bk_cloud_id")
private Long cloudAreaId = 0L;
@JsonProperty("bk_cloud_vendor")
private String cloudVendorId;
@JsonProperty("last_time")
private String lastTime;

public ApplicationHostDTO toApplicationHostDTO() {
ApplicationHostDTO applicationHostDTO = new ApplicationHostDTO();
applicationHostDTO.setHostId(hostId);
List<String> ipList = StringUtil.strToList(ip, String.class, ",");
applicationHostDTO.setIpList(ipList);
if (ipList != null && !ipList.isEmpty()) {
applicationHostDTO.setIp(ipList.get(0));
}
applicationHostDTO.setDisplayIp(ip);
applicationHostDTO.setIpv6(ipv6);
applicationHostDTO.setAgentId(agentId);
int hostNameMaxLength = 2000;
int osNameMaxLength = 512;
int osTypeNameMaxLength = 32;
applicationHostDTO.setHostName(StringUtil.substring(hostName, hostNameMaxLength));
applicationHostDTO.setOsName(StringUtil.substring(osName, osNameMaxLength));
applicationHostDTO.setOsType(StringUtil.substring(osType, osTypeNameMaxLength));
applicationHostDTO.setCloudAreaId(cloudAreaId);
applicationHostDTO.setCloudVendorId(cloudVendorId);
applicationHostDTO.setLastTime(TimeUtil.parseIsoZonedTimeToMillis(lastTime));
return applicationHostDTO;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,7 @@ public class HostRelationEventDetail {

@JsonProperty("bk_module_id")
private Long moduleId;

@JsonProperty("last_time")
private String lastTime;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Tencent is pleased to support the open source community by making BK-JOB蓝鲸智云作业平台 available.
*
* Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
*
* BK-JOB蓝鲸智云作业平台 is licensed under the MIT License.
*
* License for BK-JOB蓝鲸智云作业平台:
* --------------------------------------------------------------------
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
* to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of
* the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
* THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/

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

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.util.List;


@Getter
@Setter
@ToString
public class HostWithModules {
private HostProp host;
private List<ModuleProp> modules;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Tencent is pleased to support the open source community by making BK-JOB蓝鲸智云作业平台 available.
*
* Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
*
* BK-JOB蓝鲸智云作业平台 is licensed under the MIT License.
*
* License for BK-JOB蓝鲸智云作业平台:
* --------------------------------------------------------------------
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
* to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of
* the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
* THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/

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


import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

@Getter
@Setter
@ToString
public class ModuleProp {
@JsonProperty("bk_module_id")
private Long moduleId;
@JsonProperty("bk_set_id")
private Long setId;
@JsonProperty("bk_module_type")
private String moduleType;
@JsonProperty("last_time")
private String lastTime;
}