This commit is contained in:
jagger 2024-05-08 18:29:41 +08:00
parent 6a60105ce8
commit c8dab68524
1 changed files with 10 additions and 5 deletions

View File

@ -28,31 +28,36 @@ func SyncTaskInfo() {
}
var sys = new(base.OperateStruct)
now := time.Now()
sync := false
if resp.CloudInfoList != nil && len(resp.CloudInfoList) != 0 {
for _, cloudInfoList := range resp.CloudInfoList {
if cloudInfoList.Status == "Pending" {
if cloudInfoList.Status == "Saved" {
cloudInfoList.StartTime = &now
sys.YamlString = cloudInfoList.YamlString
sys.ClusterName = cloudInfoList.ClusterName
err = sys.Apply()
if err != nil {
sync = false
continue
}
cloudInfoList.Status = "Running"
// push submitted mark to coordinator
pushTaskInfo(resp, err, httpClient)
sync = true
}
}
}
// push submitted mark to coordinator
if sync {
pushTaskInfo(resp, httpClient)
}
}
func pushTaskInfo(resp coreClient.PullTaskInfoResp, err error, httpClient *resty.Request) {
func pushTaskInfo(resp coreClient.PullTaskInfoResp, httpClient *resty.Request) {
PushReq := coreClient.PushTaskInfoReq{
AdapterId: global.PCM_CONFIG.System.AdapterId,
CloudInfoList: resp.CloudInfoList,
}
pushResult := coreClient.PushTaskInfoResp{}
_, err = httpClient.SetHeader("Content-Type", "application/json").
_, err := httpClient.SetHeader("Content-Type", "application/json").
SetBody(&PushReq).
SetResult(&pushResult).
Post(global.PCM_CONFIG.System.CoreServerUrl + "/pcm/v1/core/pushTaskInfo")