fix: 修复K8s执行 pod 过滤错误
Signed-off-by: fit2-zhao <yong.zhao@fit2cloud.com>
This commit is contained in:
parent
eabe03a8e8
commit
6c74445829
|
@ -15,7 +15,6 @@ import org.springframework.util.CollectionUtils;
|
|||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class KubernetesApiExec {
|
||||
|
||||
|
@ -24,7 +23,10 @@ public class KubernetesApiExec {
|
|||
if (CollectionUtils.isEmpty(pods)) {
|
||||
MSException.throwException("Execution node not found");
|
||||
}
|
||||
List<Pod> nodePods = pods.stream().filter(s -> s.getStatus().getPhase().equals("Running") && s.getMetadata().getGenerateName().startsWith(credential.getDeployName())).collect(Collectors.toList());
|
||||
List<Pod> nodePods = pods.stream()
|
||||
.filter(s -> s.getStatus().getPhase().equals("Running") && StringUtils.startsWith(s.getMetadata().getGenerateName(), credential.getDeployName()))
|
||||
.toList();
|
||||
|
||||
if (CollectionUtils.isEmpty(nodePods)) {
|
||||
MSException.throwException("Execution node not found");
|
||||
}
|
||||
|
@ -45,27 +47,27 @@ public class KubernetesApiExec {
|
|||
private record SimpleListener(JmeterRunRequestDTO runRequest) implements ExecListener {
|
||||
|
||||
@Override
|
||||
public void onOpen() {
|
||||
LoggerUtil.info("K8s命令执行监听 onOpen ", runRequest.getReportId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable t, Response response) {
|
||||
LoggerUtil.info("进入K8s onFailure处理");
|
||||
if (runRequest != null) {
|
||||
LoggerUtil.info("请求参数:", JSON.toJSONString(runRequest));
|
||||
RemakeReportService apiScenarioReportService = CommonBeanFactory.getBean(RemakeReportService.class);
|
||||
apiScenarioReportService.testEnded(runRequest, StringUtils.join("K8s执行异常:", t.getMessage()));
|
||||
} else {
|
||||
MSException.throwException("K8S 节点执行错误:" + t.getMessage());
|
||||
}
|
||||
LoggerUtil.error("K8S 节点执行错误:", t.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClose(int code, String reason) {
|
||||
LoggerUtil.info(code + "_" + reason, runRequest.getReportId());
|
||||
LoggerUtil.info("K8s命令执行监听 onClose ", runRequest.getReportId());
|
||||
}
|
||||
public void onOpen() {
|
||||
LoggerUtil.info("K8s命令执行监听 onOpen ", runRequest.getReportId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable t, Response response) {
|
||||
LoggerUtil.info("进入K8s onFailure处理");
|
||||
if (runRequest != null) {
|
||||
LoggerUtil.info("请求参数:", JSON.toJSONString(runRequest));
|
||||
RemakeReportService apiScenarioReportService = CommonBeanFactory.getBean(RemakeReportService.class);
|
||||
apiScenarioReportService.testEnded(runRequest, StringUtils.join("K8s执行异常:", t.getMessage()));
|
||||
} else {
|
||||
MSException.throwException("K8S 节点执行错误:" + t.getMessage());
|
||||
}
|
||||
LoggerUtil.error("K8S 节点执行错误:", t.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClose(int code, String reason) {
|
||||
LoggerUtil.info(code + "_" + reason, runRequest.getReportId());
|
||||
LoggerUtil.info("K8s命令执行监听 onClose ", runRequest.getReportId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue