|
|
|
@@ -149,13 +149,14 @@ public class ServiceServiceImpl implements ServiceService { |
|
|
|
public String editServiceVersion(ServiceVersionVo serviceVersionVo) throws Exception { |
|
|
|
ServiceVersion serviceVersion = getServiceVersion(serviceVersionVo); |
|
|
|
ServiceVersion oldServiceVersion = serviceDao.getServiceVersionById(serviceVersionVo.getId()); |
|
|
|
if (!oldServiceVersion.getReplicas().equals(serviceVersionVo.getReplicas()) || !oldServiceVersion.getResource().equals(serviceVersionVo.getResource()) |
|
|
|
if (!oldServiceVersion.getReplicas().equals(serviceVersionVo.getReplicas()) || !oldServiceVersion.getComputingResourceId().equals(serviceVersionVo.getComputingResourceId()) |
|
|
|
|| serviceVersionVo.getRerun()) { |
|
|
|
updateServiceVersion(serviceVersion); |
|
|
|
} |
|
|
|
LoginUser loginUser = SecurityUtils.getLoginUser(); |
|
|
|
serviceVersion.setUpdateBy(loginUser.getUsername()); |
|
|
|
serviceDao.updateServiceVersion(serviceVersion); |
|
|
|
|
|
|
|
return "修改成功"; |
|
|
|
} |
|
|
|
|
|
|
|
@@ -274,7 +275,7 @@ public class ServiceServiceImpl implements ServiceService { |
|
|
|
serviceDao.updateServiceVersion(serviceVersion); |
|
|
|
|
|
|
|
// 记录开始扣积分 |
|
|
|
resourceOccupyService.startDeduce(serviceVersion.getComputingResourceId(), Constant.TaskType_Service, serviceVersion.getServiceId(), serviceVersion.getId(), null, null); |
|
|
|
resourceOccupyService.startDeduce(serviceVersion.getComputingResourceId(), Constant.TaskType_Service, serviceVersion.getServiceId(), serviceVersion.getId(), null, service.getServiceName(), null); |
|
|
|
return "启动成功"; |
|
|
|
} else { |
|
|
|
throw new RuntimeException("启动失败"); |
|
|
|
@@ -304,19 +305,26 @@ public class ServiceServiceImpl implements ServiceService { |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public String updateServiceVersion(ServiceVersion serviceVersion) { |
|
|
|
HashMap<String, Object> paramMap = new HashMap<>(); |
|
|
|
paramMap.put("deployment_name", serviceVersion.getDeploymentName()); |
|
|
|
HashMap<String, Object> updateMap = new HashMap<>(); |
|
|
|
updateMap.put("replicas", serviceVersion.getReplicas()); |
|
|
|
updateMap.put("resource", serviceVersion.getResource()); |
|
|
|
paramMap.put("update_model", new JSONObject(updateMap)); |
|
|
|
String req = HttpUtils.sendPost(argoUrl + modelService + "/update", JSON.toJSONString(paramMap)); |
|
|
|
if (StringUtils.isNotEmpty(req)) { |
|
|
|
return "修改成功"; |
|
|
|
} else { |
|
|
|
throw new RuntimeException("更新失败"); |
|
|
|
public String updateServiceVersion(ServiceVersion serviceVersion) throws Exception { |
|
|
|
// 判断是否有资源 |
|
|
|
if (resourceOccupyService.haveResource(serviceVersion.getComputingResourceId())) { |
|
|
|
HashMap<String, Object> paramMap = new HashMap<>(); |
|
|
|
paramMap.put("deployment_name", serviceVersion.getDeploymentName()); |
|
|
|
HashMap<String, Object> updateMap = new HashMap<>(); |
|
|
|
updateMap.put("replicas", serviceVersion.getReplicas()); |
|
|
|
updateMap.put("resource", serviceVersion.getResource()); |
|
|
|
paramMap.put("update_model", new JSONObject(updateMap)); |
|
|
|
String req = HttpUtils.sendPost(argoUrl + modelService + "/update", JSON.toJSONString(paramMap)); |
|
|
|
if (StringUtils.isNotEmpty(req)) { |
|
|
|
com.ruoyi.platform.domain.Service service = serviceDao.getServiceById(serviceVersion.getServiceId()); |
|
|
|
// 记录开始扣积分 |
|
|
|
resourceOccupyService.startDeduce(serviceVersion.getComputingResourceId(), Constant.TaskType_Service, serviceVersion.getServiceId(), serviceVersion.getId(), null, service.getServiceName(), null); |
|
|
|
return "修改成功"; |
|
|
|
} else { |
|
|
|
throw new RuntimeException("更新失败"); |
|
|
|
} |
|
|
|
} |
|
|
|
throw new RuntimeException("更新失败"); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
|