Skip to content

Commit

Permalink
Merge pull request #3376 from wangyu096/issue_3375
Browse files Browse the repository at this point in the history
fix: 定时任务传入非法主机,后台处理异常 #3375
  • Loading branch information
wangyu096 authored Jan 9, 2025
2 parents 3c29bb9 + 17bb891 commit 51783d7
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -773,8 +773,15 @@ private void checkExecuteObjectExist(TaskInstanceDTO taskInstance,
// 处理主机执行对象
if (CollectionUtils.isNotEmpty(taskInstanceExecuteObjects.getNotExistHosts())) {
if (shouldIgnoreInvalidHost(taskInstance)) {
// 忽略主机不存在错误,并标识执行对象的 invalid 属性为 true
markExecuteObjectInvalid(stepInstanceList, taskInstanceExecuteObjects.getNotExistHosts());
if (taskInstanceExecuteObjects.getNotExistHosts().stream().anyMatch(host -> host.getHostId() == null)) {
// 由于历史原因,部分定时任务使用了管控区域ID:Ipv4 作为主机 ID,并且这部分主机已经不存在于 cmdb,所以无法
// 正确获取到对应的 hostId,会导致后续报错;所以这里直接对外抛出错误,不再继续兼容处理
invalidExecuteObjects.addAll(taskInstanceExecuteObjects.getNotExistHosts().stream()
.map(this::printHostIdOrIp).collect(Collectors.toList()));
} else {
// 忽略主机不存在错误,并标识执行对象的 invalid 属性为 true
markExecuteObjectInvalid(stepInstanceList, taskInstanceExecuteObjects.getNotExistHosts());
}
} else {
invalidExecuteObjects.addAll(taskInstanceExecuteObjects.getNotExistHosts().stream()
.map(this::printHostIdOrIp).collect(Collectors.toList()));
Expand Down

0 comments on commit 51783d7

Please sign in to comment.