查询job信息
This commit is contained in:
parent
ba8469deef
commit
a0290c4568
|
@ -116,6 +116,17 @@ type cancelJobReq {
|
||||||
JobId string `form:"jobId"`
|
JobId string `form:"jobId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type jobInfoReq {
|
||||||
|
ClusterId int64 `form:"clusterId"`
|
||||||
|
JobId string `form:"jobId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type jobInfoResp {
|
||||||
|
JobId string `form:"jobId"`
|
||||||
|
JobState string `json:"jobState"`
|
||||||
|
CurrentWorkingDirectory string `json:"currentWorkingDirectory"`
|
||||||
|
}
|
||||||
|
|
||||||
type QueueAssetsResp {
|
type QueueAssetsResp {
|
||||||
QueueAssets []QueueAsset `json:"queueAsset"`
|
QueueAssets []QueueAsset `json:"queueAsset"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -209,6 +209,10 @@ service pcm {
|
||||||
@doc "删除超算任务"
|
@doc "删除超算任务"
|
||||||
@handler cancelJobHandler
|
@handler cancelJobHandler
|
||||||
delete /hpc/cancelJob (cancelJobReq)
|
delete /hpc/cancelJob (cancelJobReq)
|
||||||
|
|
||||||
|
@doc "查看job状态"
|
||||||
|
@handler jobInfoHandler
|
||||||
|
get /hpc/jobInfo (jobInfoReq) returns (jobInfoResp)
|
||||||
}
|
}
|
||||||
|
|
||||||
//cloud二级接口
|
//cloud二级接口
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -19,7 +19,7 @@ require (
|
||||||
github.com/robfig/cron/v3 v3.0.1
|
github.com/robfig/cron/v3 v3.0.1
|
||||||
github.com/zeromicro/go-zero v1.7.3
|
github.com/zeromicro/go-zero v1.7.3
|
||||||
gitlink.org.cn/JointCloud/pcm-ac v0.0.0-20240920093406-601f283f0185
|
gitlink.org.cn/JointCloud/pcm-ac v0.0.0-20240920093406-601f283f0185
|
||||||
gitlink.org.cn/JointCloud/pcm-hpc v0.0.0-20241026041404-af824802cfc8
|
gitlink.org.cn/JointCloud/pcm-hpc v0.0.0-20241104040331-d3a6eb951631
|
||||||
gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20240918011543-482dcd609877
|
gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20240918011543-482dcd609877
|
||||||
gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20240817071412-44397870b110
|
gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20240817071412-44397870b110
|
||||||
gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240403033338-e7edabad4203
|
gitlink.org.cn/JointCloud/pcm-openstack v0.0.0-20240403033338-e7edabad4203
|
||||||
|
|
4
go.sum
4
go.sum
|
@ -467,8 +467,8 @@ github.com/zeromicro/go-zero v1.7.3 h1:yDUQF2DXDhUHc77/NZF6mzsoRPMBfldjPmG2O/ZSz
|
||||||
github.com/zeromicro/go-zero v1.7.3/go.mod h1:9JIW3gHBGuc9LzvjZnNwINIq9QdiKu3AigajLtkJamQ=
|
github.com/zeromicro/go-zero v1.7.3/go.mod h1:9JIW3gHBGuc9LzvjZnNwINIq9QdiKu3AigajLtkJamQ=
|
||||||
gitlink.org.cn/JointCloud/pcm-ac v0.0.0-20240920093406-601f283f0185 h1:B+YBB5xHlIAS6ILuaCGQwbOpr/L6LOHAlj9PeFUCetM=
|
gitlink.org.cn/JointCloud/pcm-ac v0.0.0-20240920093406-601f283f0185 h1:B+YBB5xHlIAS6ILuaCGQwbOpr/L6LOHAlj9PeFUCetM=
|
||||||
gitlink.org.cn/JointCloud/pcm-ac v0.0.0-20240920093406-601f283f0185/go.mod h1:3eECiw9O2bIFkkePlloKyLNXiqBAhOxNrDoGaaGseGY=
|
gitlink.org.cn/JointCloud/pcm-ac v0.0.0-20240920093406-601f283f0185/go.mod h1:3eECiw9O2bIFkkePlloKyLNXiqBAhOxNrDoGaaGseGY=
|
||||||
gitlink.org.cn/JointCloud/pcm-hpc v0.0.0-20241026041404-af824802cfc8 h1:74Sgm3izTWGiENLQQKf/DUCHUds9vU4OigXvYi4d9Pc=
|
gitlink.org.cn/JointCloud/pcm-hpc v0.0.0-20241104040331-d3a6eb951631 h1:udsOCXqZslipOlDEaxaVaG8gRZzieiRhTfSSnJYSc+E=
|
||||||
gitlink.org.cn/JointCloud/pcm-hpc v0.0.0-20241026041404-af824802cfc8/go.mod h1:0tMb2cfE73vdFC3AZmPdfH7NwQYhpwsjdFyh2ZdOfY0=
|
gitlink.org.cn/JointCloud/pcm-hpc v0.0.0-20241104040331-d3a6eb951631/go.mod h1:2/lG00ZhmS8wURzNSCTLexeGDvqYmZgHbCRnNCSqZaY=
|
||||||
gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20240918011543-482dcd609877 h1:a+1FpxqLPRojlAkJlAeRhKRbxajymXYgrM+s9bfQx0E=
|
gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20240918011543-482dcd609877 h1:a+1FpxqLPRojlAkJlAeRhKRbxajymXYgrM+s9bfQx0E=
|
||||||
gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20240918011543-482dcd609877/go.mod h1:/eOmBFZKWGoabG3sRVkVvIbLwsd2631k4jkUBR6x1AA=
|
gitlink.org.cn/JointCloud/pcm-modelarts v0.0.0-20240918011543-482dcd609877/go.mod h1:/eOmBFZKWGoabG3sRVkVvIbLwsd2631k4jkUBR6x1AA=
|
||||||
gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20240817071412-44397870b110 h1:GaXwr5sgDh0raHjUf9IewTvnRvajYea7zbLsaerYyXo=
|
gitlink.org.cn/JointCloud/pcm-octopus v0.0.0-20240817071412-44397870b110 h1:GaXwr5sgDh0raHjUf9IewTvnRvajYea7zbLsaerYyXo=
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
package hpc
|
||||||
|
|
||||||
|
import (
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/logic/hpc"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
func JobInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
var req types.JobInfoReq
|
||||||
|
if err := httpx.Parse(r, &req); err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
l := hpc.NewJobInfoLogic(r.Context(), svcCtx)
|
||||||
|
resp, err := l.JobInfo(&req)
|
||||||
|
result.HttpResult(r, w, resp, err)
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,56 @@
|
||||||
|
package hpc
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-hpc/slurm"
|
||||||
|
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
|
||||||
|
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
)
|
||||||
|
|
||||||
|
type JobInfoLogic struct {
|
||||||
|
logx.Logger
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewJobInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *JobInfoLogic {
|
||||||
|
return &JobInfoLogic{
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *JobInfoLogic) JobInfo(req *types.JobInfoReq) (resp *types.JobInfoResp, err error) {
|
||||||
|
resp = &types.JobInfoResp{}
|
||||||
|
var clusterInfo *types.ClusterInfo
|
||||||
|
tx := l.svcCtx.DbEngin.Raw("select * from t_cluster where id = ?", req.ClusterId).Scan(&clusterInfo)
|
||||||
|
if tx.Error != nil {
|
||||||
|
return nil, tx.Error
|
||||||
|
}
|
||||||
|
client, err := slurm.NewClient(slurm.ClientOptions{
|
||||||
|
URL: clusterInfo.Server,
|
||||||
|
ClientVersion: clusterInfo.Version,
|
||||||
|
RestUserName: clusterInfo.Username,
|
||||||
|
Token: clusterInfo.Token})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
job, err := client.Job(slurm.JobOptions{})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
jobResp, _ := job.GetJob(slurm.GetJobReq{JobId: req.JobId})
|
||||||
|
|
||||||
|
if len(jobResp.Errors) != 0 {
|
||||||
|
return nil, errors.Errorf(jobResp.Errors[0].Description)
|
||||||
|
}
|
||||||
|
resp.JobId = jobResp.Jobs[0].JobId
|
||||||
|
resp.JobState = jobResp.Jobs[0].JobState
|
||||||
|
resp.CurrentWorkingDirectory = jobResp.Jobs[0].CurrentWorkingDirectory
|
||||||
|
return resp, nil
|
||||||
|
}
|
12237
internal/types/types.go
12237
internal/types/types.go
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue