添加删除作业pb

This commit is contained in:
tzwang 2022-10-31 01:28:22 -07:00
parent 7de7ef6a3c
commit 337d8c1b2f
8 changed files with 38 additions and 3 deletions

View File

@ -7,7 +7,6 @@ package slurm
#include <stdint.h>
#include<slurm/slurm.h>
#include<slurm/slurm_errno.h>
#include <sys/types.h>
#include <signal.h>
struct job_info_msg *get_job_info(){
@ -40,6 +39,7 @@ int delete_job(uint32_t id) {
char msg[64];
sprintf(msg, "slurm_kill_job(%.12s)",id);
slurm_perror (msg);
return error_code;
}
return (error_code);
}
@ -85,7 +85,7 @@ func Get_all_jobs() Job_info_msg {
}
func Delete_job(id uint32) uint32 {
error_code := C.delete_job(C.uint32_t(id))
error_code := C.slurm_kill_job(C.uint32_t(id), C.SIGKILL, C.uint16_t(0))
return uint32(error_code)
}

View File

@ -12,6 +12,15 @@ message SubmitJobResp{
repeated Submit_response_msg submitResponseMsg = 1;
}
message DeleteJobReq{
uint32 JobId = 1;
int32 SlurmVersion = 2;
}
message DeleteJobResp{
uint32 Error_code=1;
}
message Argv{
string argv =1;
}

View File

@ -36,4 +36,5 @@ service SlurmService {
rpc GetAllJobs(JobInfoMsgReq) returns (JobInfoMsgResp);
rpc GetJob(JobInfoMsgReq) returns (JobInfoMsgResp);
rpc SubmitJob(SubmitJobReq) returns (SubmitJobResp);
rpc DeleteJob(DeleteJobReq) returns (DeleteJobResp);
}

View File

@ -11,4 +11,6 @@ http:
get: "/apis/slurm/getJob/{JobId}"
- selector: slurm.SlurmService.SubmitJob
post: "/apis/slurm/submitJob/data"
body: "data"
body: "data"
- selector: slurm.SlurmService.DeleteJob
delete: "/apis/slurm/deleteJob/{JobId}"

View File

@ -48,3 +48,12 @@ func (s *Server) SubmitJob(ctx context.Context, req *slurmpb.SubmitJobReq) (*slu
}
return resp, nil
}
func (s *Server) DeleteJob(ctx context.Context, req *slurmpb.DeleteJobReq) (*slurmpb.DeleteJobResp, error) {
resp, err := DeleteJob(ctx, req)
if err != nil {
glog.Errorf("ListSlurmNodes error %+v", err)
return nil, status.Errorf(codes.Internal, err.Error())
}
return resp, nil
}

View File

@ -29,3 +29,9 @@ func SubmitJob(ctx context.Context, req *pbslurm.SubmitJobReq) (*pbslurm.SubmitJ
resp, _ := slurm.SubmitJob(ctx, req)
return resp, nil
}
func DeleteJob(ctx context.Context, req *pbslurm.DeleteJobReq) (*pbslurm.DeleteJobResp, error) {
slurm, _ := slurmer.SelectSlurmVersion(req.SlurmVersion)
resp, _ := slurm.DeleteJob(ctx, req)
return resp, nil
}

View File

@ -10,6 +10,7 @@ type Slurmer interface {
GetAllJobs(ctx context.Context, req *pbslurm.JobInfoMsgReq) (resp *pbslurm.JobInfoMsgResp, err error)
GetJob(ctx context.Context, req *pbslurm.JobInfoMsgReq) (resp *pbslurm.JobInfoMsgResp, err error)
SubmitJob(ctx context.Context, req *pbslurm.SubmitJobReq) (resp *pbslurm.SubmitJobResp, err error)
DeleteJob(ctx context.Context, req *pbslurm.DeleteJobReq) (resp *pbslurm.DeleteJobResp, err error)
}
func SelectSlurmVersion(slurmVersion int32) (slurmer Slurmer, err error) {

View File

@ -61,6 +61,13 @@ func (slurmStruct SlurmStruct) SubmitJob(ctx context.Context, req *pbslurm.Submi
return &resp, nil
}
func (slurmStruct SlurmStruct) DeleteJob(ctx context.Context, req *pbslurm.DeleteJobReq) (*pbslurm.DeleteJobResp, error) {
errorCode := slurm.Delete_job(req.JobId)
var resp = pbslurm.DeleteJobResp{}
resp.ErrorCode = errorCode
return &resp, nil
}
func getJobInfoMsgResp(job_info_msg slurm.Job_info_msg) *pbslurm.JobInfoMsgResp {
var resp = pbslurm.JobInfoMsgResp{}
var jobInfoList = []*pbslurm.JobInfo{}