From e7cfbc235fdef7bf5ff533b860f5d8e82bea6ef4 Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Thu, 30 Apr 2020 15:18:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E8=B5=84=E6=BA=90=E6=B1=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/TestResourcePoolService.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/backend/src/main/java/io/metersphere/service/TestResourcePoolService.java b/backend/src/main/java/io/metersphere/service/TestResourcePoolService.java index 45817ed53f..cd454e60e8 100644 --- a/backend/src/main/java/io/metersphere/service/TestResourcePoolService.java +++ b/backend/src/main/java/io/metersphere/service/TestResourcePoolService.java @@ -29,6 +29,7 @@ import java.util.List; import java.util.UUID; import java.util.stream.Collectors; +import static io.metersphere.commons.constants.ResourceStatusEnum.INVALID; import static io.metersphere.commons.constants.ResourceStatusEnum.VALID; /** @@ -98,6 +99,7 @@ public class TestResourcePoolService { if (nodeIps.size() < testResourcePool.getResources().size()) { MSException.throwException(Translator.get("duplicate_node_ip")); } + testResourcePool.setStatus(VALID.name()); for (TestResource resource : testResourcePool.getResources()) { NodeDTO nodeDTO = JSON.parseObject(resource.getConfiguration(), NodeDTO.class); boolean isValidate = validateNode(nodeDTO); @@ -134,6 +136,7 @@ public class TestResourcePoolService { KubernetesProvider provider = new KubernetesProvider(testResource.getConfiguration()); provider.validateCredential(); testResource.setStatus(VALID.name()); + testResourcePool.setStatus(VALID.name()); } catch (Exception e) { testResource.setStatus(ResourceStatusEnum.INVALID.name()); testResourcePool.setStatus(ResourceStatusEnum.INVALID.name()); @@ -161,6 +164,18 @@ public class TestResourcePoolService { } public List listValidResourcePools() { + QueryResourcePoolRequest request = new QueryResourcePoolRequest(); + List testResourcePools = listResourcePools(request); + // 重新校验 pool + for (TestResourcePoolDTO pool : testResourcePools) { + try { + updateTestResourcePool(pool); + } catch (MSException e) { + pool.setStatus(INVALID.name()); + pool.setUpdateTime(System.currentTimeMillis()); + testResourcePoolMapper.updateByPrimaryKeySelective(pool); + } + } TestResourcePoolExample example = new TestResourcePoolExample(); example.createCriteria().andStatusEqualTo(ResourceStatusEnum.VALID.name()); return testResourcePoolMapper.selectByExample(example);