|
@@ -8,8 +8,11 @@ import (
|
|
|
"dcl_dispatch_server/src/package/util"
|
|
|
"github.com/gin-gonic/gin"
|
|
|
"net/http"
|
|
|
+ "sync"
|
|
|
)
|
|
|
|
|
|
+var envMap sync.Map
|
|
|
+
|
|
|
// 返回 true(用来确认任务是否执行的,直接返回 true 即可)
|
|
|
func Confirm(c *gin.Context) {
|
|
|
c.String(http.StatusOK, "true")
|
|
@@ -24,7 +27,7 @@ func State(c *gin.Context) {
|
|
|
taskId := c.Query("taskId")
|
|
|
state := c.Query("state")
|
|
|
podName := c.Query("podName")
|
|
|
- callbackUri := ""
|
|
|
+
|
|
|
if taskId == "" || state == "" || podName == "" {
|
|
|
infra.GlobalLogger.Error("任务状态接口请求参数错误,需要GET请求和【taskId】【state】【podName】三个参数。")
|
|
|
c.JSON(http.StatusBadRequest, entity.HttpResult{Status: false, Code: "1003", Message: "请求参数格式错误。"})
|
|
@@ -47,11 +50,11 @@ func State(c *gin.Context) {
|
|
|
}
|
|
|
if cache.Task.Info.TaskId == taskId {
|
|
|
if cache.Env == "cicv" {
|
|
|
+ envMap.Store(taskId, "cicv")
|
|
|
infra.GlobalLogger.Infof("运行环境为 cicv")
|
|
|
- callbackUri = infra.ApplicationYaml.K8s.CallbackUriCicv
|
|
|
} else if cache.Env == "pji" {
|
|
|
+ envMap.Store(taskId, "pji")
|
|
|
infra.GlobalLogger.Infof("运行环境为 pji")
|
|
|
- callbackUri = infra.ApplicationYaml.K8s.CallbackUriPji
|
|
|
} else {
|
|
|
infra.GlobalLogger.Infof("运行环境为【%v】", cache.Env)
|
|
|
}
|
|
@@ -103,18 +106,28 @@ func State(c *gin.Context) {
|
|
|
"nowTime": "2024-05-10 15:57:42"
|
|
|
}
|
|
|
*/
|
|
|
- _, err := util.PostJsonResponseJson(
|
|
|
- //"http://1.202.169.139:8081/project/task/callback",
|
|
|
- //"http://10.14.86.127:9081/project/task/callback",
|
|
|
- callbackUri,
|
|
|
- map[string]string{
|
|
|
- "taskId": taskId,
|
|
|
- "state": state,
|
|
|
- },
|
|
|
- )
|
|
|
- if err != nil {
|
|
|
- infra.GlobalLogger.Error(err)
|
|
|
- c.String(http.StatusOK, "false")
|
|
|
+ if value, ok := envMap.Load(taskId); ok {
|
|
|
+ callbackUri := ""
|
|
|
+ if value.(string) == "pji" {
|
|
|
+ callbackUri = infra.ApplicationYaml.K8s.CallbackUriPji
|
|
|
+ } else {
|
|
|
+ callbackUri = infra.ApplicationYaml.K8s.CallbackUriCicv
|
|
|
+ }
|
|
|
+ _, err := util.PostJsonResponseJson(
|
|
|
+ //"http://1.202.169.139:8081/project/task/callback",
|
|
|
+ //"http://10.14.86.127:9081/project/task/callback",
|
|
|
+ callbackUri,
|
|
|
+ map[string]string{
|
|
|
+ "taskId": taskId,
|
|
|
+ "state": state,
|
|
|
+ },
|
|
|
+ )
|
|
|
+ if err != nil {
|
|
|
+ infra.GlobalLogger.Error(err)
|
|
|
+ c.String(http.StatusOK, "false")
|
|
|
+ }
|
|
|
+ envMap.Delete(taskId)
|
|
|
}
|
|
|
+
|
|
|
c.String(http.StatusOK, "true")
|
|
|
}
|