Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 修复当队列中没有节点的报错问题 #22

Merged
merged 1 commit into from
Oct 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 33 additions & 26 deletions services/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,20 +257,23 @@ func (s *ServerConfig) GetClusterConfig(ctx context.Context, in *pb.GetClusterCo
nodeMem, _ := strconv.Atoi(memOutput)
totalMemInt = nodeMem * totalNodeNumInt
} else {
getMemCmd := fmt.Sprintf("scontrol show node=%s | grep RealMemory=| awk '{print $1}' | awk -F'=' '{print $2}'", nodeArray[0])
memOutput, err := utils.RunCommand(getMemCmd)
if err != nil || utils.CheckSlurmStatus(memOutput) {
errInfo := &errdetails.ErrorInfo{
Reason: "COMMAND_EXEC_FAILED",
// 如果nodeArray[0]是(null) 则跳过
if nodeArray[0] != "(null)" {
getMemCmd := fmt.Sprintf("scontrol show node=%s | grep RealMemory=| awk '{print $1}' | awk -F'=' '{print $2}'", nodeArray[0])
memOutput, err := utils.RunCommand(getMemCmd)
if err != nil || utils.CheckSlurmStatus(memOutput) {
errInfo := &errdetails.ErrorInfo{
Reason: "COMMAND_EXEC_FAILED",
}
st := status.New(codes.Internal, "Exec command failed or slurmctld down.")
st, _ = st.WithDetails(errInfo)
caller.Logger.Errorf("GetClusterConfig failed: %v", st.Err())
return nil, st.Err()
}
st := status.New(codes.Internal, "Exec command failed or slurmctld down.")
st, _ = st.WithDetails(errInfo)
caller.Logger.Errorf("GetClusterConfig failed: %v", st.Err())
return nil, st.Err()
}

nodeMem, _ := strconv.Atoi(memOutput)
totalMemInt = nodeMem * totalNodeNumInt
nodeMem, _ := strconv.Atoi(memOutput)
totalMemInt = nodeMem * totalNodeNumInt
}
}
} else {
errInfo := &errdetails.ErrorInfo{
Expand Down Expand Up @@ -329,22 +332,26 @@ func (s *ServerConfig) GetClusterConfig(ctx context.Context, in *pb.GetClusterCo
totalGpus = uint32(perNodeGpuNum) * uint32(totalNodeNumInt)
}
} else {
getGpusCmd := fmt.Sprintf("scontrol show node=%s| grep ' Gres=' | awk -F':' '{print $NF}'", nodeArray[0])
gpusOutput, err := utils.RunCommand(getGpusCmd)
if err != nil || utils.CheckSlurmStatus(gpusOutput) {
errInfo := &errdetails.ErrorInfo{
Reason: "COMMAND_EXEC_FAILED",
}
st := status.New(codes.Internal, "Exec command failed or slurmctld down.")
st, _ = st.WithDetails(errInfo)
caller.Logger.Errorf("GetClusterConfig failed: %v", st.Err())
return nil, st.Err()
}
if gpusOutput == "Gres=(null)" {
if nodeArray[0] == "(null)" {
totalGpus = 0
} else {
perNodeGpuNum, _ := strconv.Atoi(gpusOutput)
totalGpus = uint32(perNodeGpuNum) * uint32(totalNodeNumInt)
getGpusCmd := fmt.Sprintf("scontrol show node=%s| grep ' Gres=' | awk -F':' '{print $NF}'", nodeArray[0])
gpusOutput, err := utils.RunCommand(getGpusCmd)
if err != nil || utils.CheckSlurmStatus(gpusOutput) {
errInfo := &errdetails.ErrorInfo{
Reason: "COMMAND_EXEC_FAILED",
}
st := status.New(codes.Internal, "Exec command failed or slurmctld down.")
st, _ = st.WithDetails(errInfo)
caller.Logger.Errorf("GetClusterConfig failed: %v", st.Err())
return nil, st.Err()
}
if gpusOutput == "Gres=(null)" {
totalGpus = 0
} else {
perNodeGpuNum, _ := strconv.Atoi(gpusOutput)
totalGpus = uint32(perNodeGpuNum) * uint32(totalNodeNumInt)
}
}
}
getPartitionQosCmd := fmt.Sprintf("scontrol show partition=%s | grep -i ' QoS=' | awk '{print $3}'", partition)
Expand Down
Loading