Skip to content

Commit 7aa8bb8

Browse files
authored
EH: Update to OCS 9.0.1 container; qsub / qacct / qstat with native spec (#17)
1 parent b1c0c4b commit 7aa8bb8

20 files changed

+1476
-15
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#___INFO__MARK_END_NEW__
2020

2121
#FROM hpcgridware/clusterscheduler-latest-ubuntu2204:latest
22-
FROM hpcgridware/clusterscheduler-latest-ubuntu2204:c245a267a
22+
FROM hpcgridware/clusterscheduler-latest-ubuntu2204:V901_TAG
2323

2424
RUN mkdir -p /opt/helpers
2525

Makefile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
# This Makefile is used for development and testing purposes only.
2222

2323
IMAGE_NAME = $(shell basename $(CURDIR))
24-
IMAGE_TAG = latest
24+
IMAGE_TAG = V901_TAG
2525
CONTAINER_NAME = $(IMAGE_NAME)
2626

2727
.PHONY: build
@@ -32,11 +32,17 @@ build:
3232
# Running apptainers in containers requires more permissions. You can drop
3333
# the --privileged flag and the --cap-add SYS_ADMIN flag if you don't need
3434
# to run apptainers in containers.
35+
.PHONY: run-privileged
36+
run-privileged: build
37+
@echo "Running the container..."
38+
mkdir -p ./installation
39+
docker run -p 7070:7070 --rm -it -h master --privileged -v /dev/fuse:/dev/fuse --cap-add SYS_ADMIN --name $(CONTAINER_NAME) -v ./installation:/opt/cs-install -v ./:/root/go/src/github.com/hpc-gridware/go-clusterscheduler $(IMAGE_NAME):$(IMAGE_TAG) /bin/bash
40+
3541
.PHONY: run
3642
run: build
3743
@echo "Running the container..."
3844
mkdir -p ./installation
39-
docker run --rm -it -h master --privileged -v /dev/fuse:/dev/fuse --cap-add SYS_ADMIN --name $(CONTAINER_NAME) -v ./installation:/opt/cs-install -v ./:/root/go/src/github.com/hpc-gridware/go-clusterscheduler $(IMAGE_NAME):$(IMAGE_TAG) /bin/bash
45+
docker run -p 7070:7070 --rm -it -h master --name $(CONTAINER_NAME) -v ./installation:/opt/cs-install -v ./:/root/go/src/github.com/hpc-gridware/go-clusterscheduler $(IMAGE_NAME):$(IMAGE_TAG) /bin/bash
4046

4147
# Running apptainers in containers requires more permissions. You can drop
4248
# the --privileged flag and the --cap-add SYS_ADMIN flag if you don't need

pkg/qacct/parse.go

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
/*___INFO__MARK_BEGIN__*/
2+
/*************************************************************************
3+
* Copyright 2024 HPC-Gridware GmbH
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
************************************************************************/
18+
/*___INFO__MARK_END__*/
19+
20+
package qacct
21+
22+
import (
23+
"bufio"
24+
"strconv"
25+
"strings"
26+
)
27+
28+
func ParseQacctJobOutputWithScanner(scanner *bufio.Scanner) ([]JobDetail, error) {
29+
var jobs []JobDetail
30+
var job JobDetail
31+
32+
for scanner.Scan() {
33+
line := scanner.Text()
34+
if strings.HasPrefix(line, "==============================================================") {
35+
if job.JobNumber != 0 {
36+
jobs = append(jobs, job)
37+
}
38+
job = JobDetail{}
39+
continue
40+
}
41+
42+
parts := strings.SplitN(line, " ", 2)
43+
if len(parts) < 2 {
44+
continue
45+
}
46+
47+
key := strings.TrimSpace(parts[0])
48+
value := strings.TrimSpace(parts[1])
49+
50+
switch key {
51+
case "qname":
52+
job.QName = value
53+
case "hostname":
54+
job.HostName = value
55+
case "group":
56+
job.Group = value
57+
case "owner":
58+
job.Owner = value
59+
case "project":
60+
job.Project = value
61+
case "department":
62+
job.Department = value
63+
case "jobname":
64+
job.JobName = value
65+
case "jobnumber":
66+
job.JobNumber = parseInt64(value)
67+
case "taskid":
68+
job.TaskID = parseInt64(value)
69+
case "pe_taskid":
70+
job.PETaskID = value
71+
case "account":
72+
job.Account = value
73+
case "priority":
74+
job.Priority = parseInt64(value)
75+
case "qsub_time":
76+
job.QSubTime = value
77+
case "submit_cmd_line":
78+
job.SubmitCommandLine = value
79+
case "start_time":
80+
job.StartTime = value
81+
case "end_time":
82+
job.EndTime = value
83+
case "granted_pe":
84+
job.GrantedPE = value
85+
case "slots":
86+
job.Slots = parseInt64(value)
87+
case "failed":
88+
job.Failed = parseInt64(value)
89+
case "exit_status":
90+
job.ExitStatus = parseInt64(value)
91+
case "ru_wallclock":
92+
job.RuWallClock = parseFloat(value)
93+
case "ru_utime":
94+
job.RuUTime = parseFloat(value)
95+
case "ru_stime":
96+
job.RuSTime = parseFloat(value)
97+
case "ru_maxrss":
98+
job.RuMaxRSS = parseInt64(value)
99+
case "ru_ixrss":
100+
job.RuIXRSS = parseInt64(value)
101+
case "ru_ismrss":
102+
job.RuISMRSS = parseInt64(value)
103+
case "ru_idrss":
104+
job.RuIDRSS = parseInt64(value)
105+
case "ru_isrss":
106+
job.RuISRss = parseInt64(value)
107+
case "ru_minflt":
108+
job.RuMinFlt = parseInt64(value)
109+
case "ru_majflt":
110+
job.RuMajFlt = parseInt64(value)
111+
case "ru_nswap":
112+
job.RuNSwap = parseInt64(value)
113+
case "ru_inblock":
114+
job.RuInBlock = parseInt64(value)
115+
case "ru_oublock":
116+
job.RuOuBlock = parseInt64(value)
117+
case "ru_msgsnd":
118+
job.RuMsgSend = parseInt64(value)
119+
case "ru_msgrcv":
120+
job.RuMsgRcv = parseInt64(value)
121+
case "ru_nsignals":
122+
job.RuNSignals = parseInt64(value)
123+
case "ru_nvcsw":
124+
job.RuNVCSw = parseInt64(value)
125+
case "ru_nivcsw":
126+
job.RuNiVCSw = parseInt64(value)
127+
case "wallclock":
128+
job.WallClock = parseFloat(value)
129+
case "cpu":
130+
job.CPU = parseFloat(value)
131+
case "mem":
132+
job.Memory = parseFloat(value)
133+
case "io":
134+
job.IO = parseFloat(value)
135+
case "iow":
136+
job.IOWait = parseFloat(value)
137+
case "maxvmem":
138+
job.MaxVMem = parseInt64(value)
139+
case "maxrss":
140+
job.MaxRSS = parseInt64(value)
141+
case "arid":
142+
job.ArID = value
143+
}
144+
}
145+
146+
if job.JobNumber != 0 {
147+
jobs = append(jobs, job)
148+
}
149+
150+
return jobs, nil
151+
}
152+
153+
// ParseQacctOutput parses the output of the qacct command and returns
154+
// a slice of JobDetail.
155+
func ParseQAcctJobOutput(output string) ([]JobDetail, error) {
156+
scanner := bufio.NewScanner(strings.NewReader(output))
157+
jobs, err := ParseQacctJobOutputWithScanner(scanner)
158+
if err != nil {
159+
return nil, err
160+
}
161+
return jobs, nil
162+
}
163+
164+
func parseInt(value string) int {
165+
i, _ := strconv.Atoi(value)
166+
return i
167+
}
168+
169+
func parseInt64(value string) int64 {
170+
i, _ := strconv.ParseInt(value, 10, 64)
171+
return i
172+
}
173+
174+
func parseFloat(value string) float64 {
175+
f, _ := strconv.ParseFloat(value, 64)
176+
return f
177+
}

0 commit comments

Comments
 (0)