Commit 5ebe8dda authored by duanjinfei's avatar duanjinfei

update standard task handler

parent c9cf1c8e
...@@ -219,35 +219,37 @@ func (t *TaskHandler) ComputeTaskHandler(taskMsg *nodeManagerV1.PushTaskMessage) ...@@ -219,35 +219,37 @@ func (t *TaskHandler) ComputeTaskHandler(taskMsg *nodeManagerV1.PushTaskMessage)
log.Error("received error: ", err) log.Error("received error: ", err)
return return
} }
isUseFileCache := true if taskMsg.TaskKind == baseV1.TaskKind_StandardTask {
for key, value := range taskParam.Headers { isUseFileCache := true
if key == models.UseFileCache { for key, value := range taskParam.Headers {
if value[0] == "0" { if key == models.UseFileCache {
isUseFileCache = false if value[0] == "0" {
break isUseFileCache = false
break
}
} }
} }
} if isUseFileCache && readBody != nil {
if isUseFileCache && readBody != nil { containerResp := &models.ModelResponse{}
containerResp := &models.ModelResponse{} err = json.Unmarshal(readBody, &containerResp)
err = json.Unmarshal(readBody, &containerResp) if err != nil {
if err != nil { log.WithError(err).Error("Error unmarshalling oss resp body failed")
log.WithError(err).Error("Error unmarshalling oss resp body failed") return
return }
} if len(containerResp.Output) == 1 {
if len(containerResp.Output) == 1 { if utils.IsBase64ImageStr(containerResp.Output[0]) {
if utils.IsBase64ImageStr(containerResp.Output[0]) { imageStr := strings.SplitN(containerResp.Output[0], ",", 2)[1]
imageStr := strings.SplitN(containerResp.Output[0], ",", 2)[1] queryString := utils.MatchFileCacheQueryString(taskParam.Headers, taskCmd.ImageName, t.DockerOp.ModelsInfo)
queryString := utils.MatchFileCacheQueryString(taskParam.Headers, taskCmd.ImageName, t.DockerOp.ModelsInfo) ossUri, err := t.uploadOSS(taskMsg.TaskId, queryString, imageStr)
ossUri, err := t.uploadOSS(taskMsg.TaskId, queryString, imageStr) if err != nil {
if err != nil { log.WithError(err).Error("upload image into file cache failed")
log.WithError(err).Error("upload image into file cache failed") return
return }
} log.WithField("uri", ossUri).Info("upload image OSS successful")
log.WithField("uri", ossUri).Info("upload image OSS successful") if ossUri != "" {
if ossUri != "" { taskExecResult.TaskHttpStatusCode = models.RedirectCode
taskExecResult.TaskHttpStatusCode = models.RedirectCode post.Header.Set("Location", ossUri)
post.Header.Set("Location", ossUri) }
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment