fix: 修复K8s执行 pod 过滤错误

Signed-off-by: fit2-zhao <yong.zhao@fit2cloud.com>
This commit is contained in:
fit2-zhao 2024-08-07 15:08:25 +08:00 committed by Craftsman
parent eabe03a8e8
commit 6c74445829
1 changed files with 26 additions and 24 deletions

View File

@ -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");
}