|
@@ -1,11 +1,11 @@
|
|
|
package seecoder.devcloud.web.service.impl.pipeline;
|
|
package seecoder.devcloud.web.service.impl.pipeline;
|
|
|
|
|
|
|
|
|
|
+import io.kubernetes.client.openapi.models.V1DeploymentStatus;
|
|
|
import org.apache.http.HttpStatus;
|
|
import org.apache.http.HttpStatus;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import seecoder.devcloud.api.ApplicationProperties;
|
|
import seecoder.devcloud.api.ApplicationProperties;
|
|
|
-import seecoder.devcloud.api.k8s.model.DeploymentStatus;
|
|
|
|
|
import seecoder.devcloud.common.exceptions.AccessDeniedException;
|
|
import seecoder.devcloud.common.exceptions.AccessDeniedException;
|
|
|
import seecoder.devcloud.common.exceptions.ServiceException;
|
|
import seecoder.devcloud.common.exceptions.ServiceException;
|
|
|
import seecoder.devcloud.core.pipeline.Pipeline;
|
|
import seecoder.devcloud.core.pipeline.Pipeline;
|
|
@@ -25,6 +25,7 @@ import seecoder.devcloud.web.model.vo.pipeline.DeploymentInfoVO;
|
|
|
import seecoder.devcloud.web.service.pipeline.DeploymentService;
|
|
import seecoder.devcloud.web.service.pipeline.DeploymentService;
|
|
|
|
|
|
|
|
import java.sql.Timestamp;
|
|
import java.sql.Timestamp;
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
@@ -60,21 +61,24 @@ public class DeploymentServiceImpl implements DeploymentService {
|
|
|
@Override
|
|
@Override
|
|
|
public List<DeploymentInfoVO> retrieveDeploymentInfos(Integer projectId) throws AccessDeniedException {
|
|
public List<DeploymentInfoVO> retrieveDeploymentInfos(Integer projectId) throws AccessDeniedException {
|
|
|
//projectAuthentication(projectId);
|
|
//projectAuthentication(projectId);
|
|
|
- ProjectPO project = projectMapper.getProjectById(projectId);
|
|
|
|
|
List<PipelinePO> pipelines = pipelineMapper.selectByProjectId(projectId);
|
|
List<PipelinePO> pipelines = pipelineMapper.selectByProjectId(projectId);
|
|
|
- // 获取项目所关联的所有流水线
|
|
|
|
|
|
|
+ if (pipelines.size()==0){
|
|
|
|
|
+ return new ArrayList<>();
|
|
|
|
|
+ }
|
|
|
List<Integer> pipelineIds = pipelines.stream().map(PipelinePO::getId).collect(Collectors.toList());
|
|
List<Integer> pipelineIds = pipelines.stream().map(PipelinePO::getId).collect(Collectors.toList());
|
|
|
-
|
|
|
|
|
List<DeploymentPO> deployments = deploymentMapper.selectByPipelineIds(pipelineIds);
|
|
List<DeploymentPO> deployments = deploymentMapper.selectByPipelineIds(pipelineIds);
|
|
|
return deployments.stream().map(x->{
|
|
return deployments.stream().map(x->{
|
|
|
PipelineInspector inspector = PipelineInspectorFactory.init(x.getNamespace(),x.getDeployName());
|
|
PipelineInspector inspector = PipelineInspectorFactory.init(x.getNamespace(),x.getDeployName());
|
|
|
//获取状态
|
|
//获取状态
|
|
|
String status = null;
|
|
String status = null;
|
|
|
- DeploymentStatus deploymentStatus = inspector.inspectStatus();
|
|
|
|
|
- if(deploymentStatus.isAvailable()){
|
|
|
|
|
|
|
+ V1DeploymentStatus deploymentStatus = inspector.inspectStatus();
|
|
|
|
|
+ if (deploymentStatus == null){
|
|
|
|
|
+ status = "部署不存在,请重新部署";
|
|
|
|
|
+ }
|
|
|
|
|
+ else if(deploymentStatus.getAvailableReplicas()==1){
|
|
|
status = "正常运行";
|
|
status = "正常运行";
|
|
|
} else{
|
|
} else{
|
|
|
- status = "不可用: " + deploymentStatus.getProgressingMessage();
|
|
|
|
|
|
|
+ status = "不可用";
|
|
|
}
|
|
}
|
|
|
return DeploymentInfoVO.builder()
|
|
return DeploymentInfoVO.builder()
|
|
|
.pipelineId(x.getPipelineId())
|
|
.pipelineId(x.getPipelineId())
|