Skip to content

Commit 99c3232

Browse files
authored
Changing slices to maps (#12)
* Cluster Simulator. Improved error messages for qconf * Updated README.md * Adding scheduler config type; fix reporting_params; apptainer * Changing slices to maps * removed cluster json
1 parent eea1780 commit 99c3232

File tree

17 files changed

+508
-302
lines changed

17 files changed

+508
-302
lines changed

Dockerfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,12 @@ COPY entrypoint.sh /entrypoint.sh
3030
ARG GOLANG_VERSION=1.22.4
3131

3232
RUN apt-get update && \
33-
apt-get install -y wget git gcc make vim libhwloc-dev hwloc
33+
apt-get install -y wget git gcc make vim libhwloc-dev hwloc software-properties-common && \
34+
add-apt-repository -y ppa:apptainer/ppa && \
35+
apt-get update && \
36+
apt-get install -y apptainer
37+
38+
RUN touch /etc/localtime
3439

3540
RUN wget https://go.dev/dl/go${GOLANG_VERSION}.linux-amd64.tar.gz && \
3641
rm -rf /usr/local/go && \

Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,13 @@ build:
3333
run: build
3434
@echo "Running the container..."
3535
mkdir -p ./installation
36-
docker run --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
36+
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
37+
38+
.PHONY: simulate
39+
simulate:
40+
@echo "Running the container in simulation mode using cluster.json"
41+
mkdir -p ./installation
42+
docker run --rm -it -h master --privileged --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 -c "cd /root/go/src/github.com/hpc-gridware/go-clusterscheduler/cmd/simulator && go build . && ./simulator run ../../cluster.json && /bin/bash"
3743

3844
.PHONY: simulate
3945
simulate:

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ The Go API offers a range of powerful features, including:
1212
- **`qconf` Command Line Wrapper**: This primary feature enables
1313
developers to build robust applications to configure the Open/Gridware
1414
Cluster Scheduler effortlessly.
15-
- **`simulator` Application**: This example application implements a
15+
- **`simulator` Application**: This application implements a
1616
container based simulator of a real "Grid Engine" cluster. It can
17-
dump the configuration and apply changes to a simulated cluster.
17+
dump the configuration of a SGE or Open Grid Engine cluster and
18+
apply changes to a cluster simulated within a container.
1819
(See the `cmd/simulator` directory for more information.)
1920

2021
## Go API Development Container

autoinstall.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ CELL_NAME="default"
77
ADMIN_USER="root"
88
QMASTER_SPOOL_DIR="/opt/cs-install/default/spool/master"
99
EXECD_SPOOL_DIR="/opt/cs-install/default/spool/execd"
10-
GID_RANGE="20000-20100"
10+
GID_RANGE="20000-20200"
1111
SPOOLING_METHOD="classic"
1212
DB_SPOOLING_DIR="/opt/cs-install/default/spool/bdb"
1313
#PG_SPOOLING_ARGS="none"

cmd/apply/apply.go

Lines changed: 0 additions & 57 deletions
This file was deleted.

cmd/simulator/README.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,34 @@
22

33
Do you want to simulate your Grid Engine or Open Cluster Scheduler?
44

5+
6+
Benefits:
7+
- Testing new configurations without affecting your production cluster.
8+
- Testing new versions of Open Cluster Scheduler with your existing configuration.
9+
- Testing scheduler strategies and policies, JSV scripts, and more.
10+
- Note, that jobs are simulated as well and never executed. The first
11+
parameter of the job defines the runtime.
12+
513
This is the right place for you.
614

715
This repository contains a Dockerfile that builds a container with
816
Open Cluster Scheduler (OCS). Using the simulator application, you can
9-
dump the configuration of your Grid Engine cluster and load it into
10-
the Open Cluster Scheduler inside this container.
17+
dump the configuration of your existing Grid Engine cluster and load
18+
it into the Open Cluster Scheduler inside this container.
1119

1220
This simulator application allows you to do 2 things:
1321
* Dump the configuration of your Grid Engine cluster into JSON format.
1422
* Load the JSON configuration into the cluster inside the container.
1523

1624
Note, depending on the version of your Grid Engine cluster, it
17-
might or might not work. Please report and issues you find to
18-
get the dump function it stable accross different distributions
19-
and Grid Engine implementations.
25+
might or might not work. Resons for configuration dumping might
26+
not work: Lists which have different separation characters. We
27+
need to catch all of them. Resons for configuration loading might
28+
not work: The configuration file is not complete or has new mandatory
29+
fields. We need to catch all of them.
30+
31+
Please report and issues you find to get the dump function it stable
32+
accross different distributions and Grid Engine implementations.
2033

2134
## Build the simulation Go Application
2235

cmd/simulator/go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
77
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
88
github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6 h1:k7nVchz72niMH6YLQNvHSdIE7iqsQxK1P41mySCvssg=
99
github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6/go.mod h1:kf6iHlnVGwgKolg33glAes7Yg/8iWP8ukqeldJSO7jw=
10-
github.com/hpc-gridware/go-clusterscheduler v0.0.0-20240826155740-e0d47e7b5d2d h1:6pWRLuBWL3ftNkgjWgo1+6FQL7lz9tNP/Ts/DL+pI6I=
11-
github.com/hpc-gridware/go-clusterscheduler v0.0.0-20240826155740-e0d47e7b5d2d/go.mod h1:fhKiKQat7cBLahijxDvXhjNscCgT9Etf8OUzQX/eUFY=
1210
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
1311
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
1412
github.com/onsi/ginkgo/v2 v2.19.1 h1:QXgq3Z8Crl5EL1WBAC98A5sEBHARrAJNzAmMxzLcRF0=

cmd/simulator/run.go

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -85,42 +85,39 @@ func run(cmd *cobra.Command, args []string) {
8585
}
8686

8787
// Go through each host and add it to the cluster
88-
for i := range config.ExecHosts {
88+
//
89+
for key := range config.ExecHosts {
8990
// add "master" host (here in the container) to be load
9091
// report host for the simulated host
91-
if config.ExecHosts[i].ComplexValues == nil {
92-
config.ExecHosts[i].ComplexValues = make(map[string]string)
92+
if config.ExecHosts[key].ComplexValues == nil {
93+
//
9394
}
94-
config.ExecHosts[i].ComplexValues["load_report_host"] = "master"
95+
config.ExecHosts[key].ComplexValues["load_report_host"] = "master"
9596
// add to @allhosts
96-
allhosts.Hosts = append(allhosts.Hosts, config.ExecHosts[i].Name)
97+
allhosts.Hosts = append(allhosts.Hosts, config.ExecHosts[key].Name)
9798
}
9899

99100
// add @allhosts to the list of host groups (TODO should be map)
100-
found := false
101-
for i, hg := range config.HostGroups {
102-
if hg.Name == "@allhosts" {
103-
config.HostGroups[i] = allhosts
104-
found = true
105-
break
106-
}
107-
}
108-
if !found {
109-
config.HostGroups = append(config.HostGroups, allhosts)
101+
if _, ok := config.HostGroups["@allhosts"]; !ok {
102+
config.HostGroups["@allhosts"] = allhosts
110103
}
111104

112105
// append "master" host to the list of hosts as it severs
113106
// the fake load for all simulated hosts and is not in the
114107
// list of hosts from the JSON file
115-
config.ExecHosts = append(config.ExecHosts, qconf.HostExecConfig{
108+
if config.ExecHosts == nil {
109+
config.ExecHosts = make(map[string]qconf.HostExecConfig)
110+
}
111+
config.ExecHosts["master"] = qconf.HostExecConfig{
116112
Name: "master",
117-
})
118-
113+
}
119114
// add root as operator
120-
config.Users = append(config.Users,
121-
qconf.UserConfig{
122-
Name: "root",
123-
})
115+
if config.Users == nil {
116+
config.Users = make(map[string]qconf.UserConfig)
117+
}
118+
config.Users["root"] = qconf.UserConfig{
119+
Name: "root",
120+
}
124121
config.Operators = append(config.Operators, "root")
125122
config.Managers = append(config.Managers, "root")
126123

@@ -157,6 +154,8 @@ func RestartQmaster(config qconf.ClusterConfig, cs *qconf.CommandLineQConf) erro
157154
if err != nil {
158155
return fmt.Errorf("Error shutting down qmaster: %s", err)
159156
}
157+
<-time.After(5 * time.Second)
158+
cs.ShutdownMasterDaemon()
160159
fmt.Printf("waiting for qmaster to shut down...\n")
161160
<-time.After(30 * time.Second)
162161
sgemaster := filepath.Join(config.ClusterEnvironment.Root,
@@ -185,7 +184,8 @@ func AddHostsToEtcHosts(config qconf.ClusterConfig) error {
185184
baseIP := [4]int{10, 0, 0, 0}
186185

187186
// Add simulated hosts to /etc/hosts so that they are resolvable
188-
for i, host := range config.ExecHosts {
187+
i := 0
188+
for _, host := range config.ExecHosts {
189189
thirdOctet := i / 256
190190
fourthOctet := i % 256
191191
ip := fmt.Sprintf("10.%d.%d.%d", baseIP[1], baseIP[2]+thirdOctet, fourthOctet)
@@ -200,6 +200,7 @@ func AddHostsToEtcHosts(config qconf.ClusterConfig) error {
200200
baseIP[1]++
201201
baseIP[2] = 0
202202
}
203+
i++
203204
}
204205
return nil
205206
}
@@ -235,18 +236,16 @@ func addComplexToConfig(config *qconf.ClusterConfig) {
235236
return
236237
}
237238
}
238-
config.ComplexEntries = append(config.ComplexEntries,
239-
qconf.ComplexEntryConfig{
240-
Name: "load_report_host",
241-
Shortcut: "lrh",
242-
Type: "STRING",
243-
Relop: "==",
244-
Requestable: "YES",
245-
Consumable: "NO",
246-
Default: "NONE",
247-
Urgency: 0,
248-
})
249-
239+
config.ComplexEntries["load_report_host"] = qconf.ComplexEntryConfig{
240+
Name: "load_report_host",
241+
Shortcut: "lrh",
242+
Type: "STRING",
243+
Relop: "==",
244+
Requestable: "YES",
245+
Consumable: "NO",
246+
Default: "NONE",
247+
Urgency: 0,
248+
}
250249
}
251250

252251
func addGlobalConfig(cs *qconf.CommandLineQConf) error {
@@ -256,7 +255,7 @@ func addGlobalConfig(cs *qconf.CommandLineQConf) error {
256255
}
257256
global.QmasterParams = append(global.QmasterParams, "SIMULATE_EXECDS=TRUE")
258257
global.ExecdParams = append(global.ExecdParams, "SIMULATE_JOBS=TRUE")
259-
return cs.ModifyGlobalConfig(global)
258+
return cs.ModifyGlobalConfig(*global)
260259
}
261260

262261
func addGlobalConfigToConfig(config *qconf.ClusterConfig) {

0 commit comments

Comments
 (0)