Browse Source

多节点日志下载问题。

Signed-off-by: zouap <zouap@pcl.ac.cn>
pull/3481/head
zouap 2 years ago
parent
commit
d883eec2e5
2 changed files with 32 additions and 12 deletions
  1. +20
    -4
      modules/storage/obs.go
  2. +12
    -8
      routers/repo/modelarts.go

+ 20
- 4
modules/storage/obs.go View File

@@ -614,7 +614,7 @@ func ObsCreateObject(path string) error {
return nil
}

func GetObsLogFileName(prefix string) (string, error) {
func GetObsLogFileName(prefix string) ([]FileInfo, error) {
input := &obs.ListObjectsInput{}
input.Bucket = setting.Bucket
input.Prefix = prefix
@@ -622,10 +622,26 @@ func GetObsLogFileName(prefix string) (string, error) {
output, err := ObsCli.ListObjects(input)
if err != nil {
log.Error("PutObject failed:", err.Error())
return "", err
return nil, err
}
if output == nil || len(output.Contents) == 0 {
return "", errors.New("obs log files not exist")
return nil, errors.New("obs log files not exist")
}
fileInfos := make([]FileInfo, 0)
for _, val := range output.Contents {
//result[num] = c.Key
if strings.HasSuffix(val.Key, ".log") {
log.Info("log fileName=" + val.Key)
fileInfo := FileInfo{
ModTime: val.LastModified.Local().Format("2006-01-02 15:04:05"),
FileName: val.Key,
Size: val.Size,
IsDir: false,
ParenDir: "",
}
fileInfos = append(fileInfos, fileInfo)
}

}
return output.Contents[0].Key, nil
return fileInfos, nil
}

+ 12
- 8
routers/repo/modelarts.go View File

@@ -2893,15 +2893,19 @@ func TrainJobDownloadLogFile(ctx *context.Context) {
ctx.ServerError("GetObsLogFileName", err)
return
}

url, err := storage.GetObsCreateSignedUrlByBucketAndKey(setting.Bucket, key)
if err != nil {
log.Error("GetObsCreateSignedUrlByBucketAndKey failed: %v", err.Error(), ctx.Data["msgID"])
ctx.ServerError("GetObsCreateSignedUrlByBucketAndKey", err)
return
if len(key) > 1 {
ObsDownloadManyFile("", ctx, task.DisplayJobName+".zip", key)
} else {
url, err := storage.GetObsCreateSignedUrlByBucketAndKey(setting.Bucket, key[0].FileName)
if err != nil {
log.Error("GetObsCreateSignedUrlByBucketAndKey failed: %v", err.Error(), ctx.Data["msgID"])
ctx.ServerError("GetObsCreateSignedUrlByBucketAndKey", err)
return
}
ctx.Resp.Header().Set("Cache-Control", "max-age=0")
http.Redirect(ctx.Resp, ctx.Req.Request, url, http.StatusTemporaryRedirect)
}
ctx.Resp.Header().Set("Cache-Control", "max-age=0")
http.Redirect(ctx.Resp, ctx.Req.Request, url, http.StatusTemporaryRedirect)

}
func getDatasUrlListByUUIDS(uuidStr string) ([]models.Datasurl, string, string, bool, error) {
var isMultiDataset bool


Loading…
Cancel
Save