|
@@ -1,7 +1,10 @@
|
|
package handler
|
|
package handler
|
|
|
|
|
|
import (
|
|
import (
|
|
|
|
+ "cicv-data-closedloop/amd64/dispatch_server/package/domain"
|
|
|
|
+ "cicv-data-closedloop/amd64/dispatch_server/package/global"
|
|
"cicv-data-closedloop/amd64/dispatch_server/package/infra"
|
|
"cicv-data-closedloop/amd64/dispatch_server/package/infra"
|
|
|
|
+ "cicv-data-closedloop/amd64/dispatch_server/package/service"
|
|
"cicv-data-closedloop/amd64/dispatch_server/package/util"
|
|
"cicv-data-closedloop/amd64/dispatch_server/package/util"
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/gin-gonic/gin"
|
|
"net/http"
|
|
"net/http"
|
|
@@ -23,8 +26,38 @@ func State(c *gin.Context) {
|
|
if state != "Running" {
|
|
if state != "Running" {
|
|
err := util.DeletePod(infra.ClientSet, podName, infra.ApplicationYaml.K8s.NamespaceName)
|
|
err := util.DeletePod(infra.ClientSet, podName, infra.ApplicationYaml.K8s.NamespaceName)
|
|
if err != nil {
|
|
if err != nil {
|
|
- infra.GlobalLogger.Infof("删除pod【%v】失败", podName)
|
|
|
|
|
|
+ infra.GlobalLogger.Errorf("删除pod【%v】失败", podName)
|
|
}
|
|
}
|
|
|
|
+ // 根据taskId删除缓存中的pod元素
|
|
|
|
+ runningTaskCacheJsons, err := infra.GlobalRedisClient.LRange(global.KeyTaskQueueRunningCluster, 0, -1).Result()
|
|
|
|
+ if err != nil {
|
|
|
|
+ infra.GlobalLogger.Errorf("获取运行中的任务队列【%v】失败", global.KeyTaskQueueRunningCluster)
|
|
|
|
+ }
|
|
|
|
+ for _, json := range runningTaskCacheJsons {
|
|
|
|
+ cache, err := service.JsonToTaskCache(json)
|
|
|
|
+ if err != nil {
|
|
|
|
+ infra.GlobalLogger.Error(err)
|
|
|
|
+ }
|
|
|
|
+ if cache.Task.Info.TaskId == taskId {
|
|
|
|
+ // 1 获取任务id关联的节点
|
|
|
|
+ nodeName, _ := infra.GlobalRedisClient.Get(global.KeyTaskToNode + ":" + taskId).Result()
|
|
|
|
+ // 2 归还并行度
|
|
|
|
+ global.ParallelismMutex.Lock()
|
|
|
|
+ gpuNodeJsons, _ := infra.GlobalRedisClient.LRange(global.KeyGpuNodeList, 0, -1).Result()
|
|
|
|
+ for i, gpuNodeJson := range gpuNodeJsons {
|
|
|
|
+ node, _ := domain.JsonToGpuNode(gpuNodeJson)
|
|
|
|
+ if node.Hostname == nodeName {
|
|
|
|
+ node.Parallelism++
|
|
|
|
+ nodeJson, _ := domain.GpuNodeToJson(node)
|
|
|
|
+ _, _ = infra.GlobalRedisClient.LSet(global.KeyGpuNodeList, int64(i), nodeJson).Result()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ global.ParallelismMutex.Unlock()
|
|
|
|
+ // 3 删除任务队列中的元素
|
|
|
|
+ _, _ = infra.GlobalRedisClient.LRem(global.KeyTaskQueueRunningCluster, 0, json).Result()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
// 发送http请求到索为系统
|
|
// 发送http请求到索为系统
|