Skip to content

Commit

Permalink
removed unused config options. Also now using commonIL from the main …
Browse files Browse the repository at this point in the history
…interlink repo
  • Loading branch information
Surax98 committed May 28, 2024
1 parent 494cf11 commit fd9e9c1
Show file tree
Hide file tree
Showing 15 changed files with 183 additions and 310 deletions.
40 changes: 26 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,28 @@ make all
```

and you will be able to find the built slurm-sd binary inside the bin directory. Before executing it, remember to check
if the configuration file is correctly set according to your needs. You can find an example one under examples/config/InterLinkConfig.yaml.
Do not forget to set the INTERLINKCONFIGPATH environment variable to point to your config.
if the configuration file is correctly set according to your needs. You can find an example one under examples/config/SlurmConfig.yaml.
Do not forget to set the SLURMCONFIGPATH environment variable to point to your config.

### :gear: A SLURM config example

```yaml
SidecarPort: "4000"
SbatchPath: "/usr/bin/sbatch"
ScancelPath: "/usr/bin/scancel"
SqueuePath: "/usr/bin/squeue"
CommandPrefix: ""
SingularityPrefix: ""
ExportPodData: true
DataRootFolder: ".local/interlink/jobs/"
Namespace: "vk"
Tsocks: false
TsocksPath: "$WORK/tsocks-1.8beta5+ds1/libtsocks.so"
TsocksLoginNode: "login01"
BashPath: /bin/bash
VerboseLogging: true
ErrorsOnlyLogging: false
```
### :pencil2: Annotations
Expand All @@ -65,15 +85,12 @@ It is possible to specify Annotations when submitting Pods to the K8S cluster. A
| slurm-job.vk.io/flags | Used to specify SLURM flags. These flags will be added to the SLURM script in the form of #SBATCH flag1, #SBATCH flag2, etc |
| slurm-job.vk.io/mpi-flags | Used to prepend "mpiexec -np $SLURM_NTASKS \*flags\*" to the Singularity Execution |
### :wrench: InterLink Config file
### :gear: Explanation of the SLURM Config file
Detailed explanation of the InterLink config file key values. Edit the config file before running the binary or before
Detailed explanation of the SLURM config file key values. Edit the config file before running the binary or before
building the docker image (`docker compose up -d --build --force-recreate` will recreate and re-run the updated image)
| Key | Value |
|--------------|-----------|
| InterlinkURL | the URL to allow the Virtual Kubelet to contact the InterLink module. |
| SidecarURL | the URL to allow InterLink to communicate with the Sidecar module (docker, slurm, etc). Do not specify port here |
| InterlinkPort | the Interlink listening port. InterLink and VK will communicate over this port. |
| SidecarPort | the sidecar listening port. Sidecar and Interlink will communicate on this port. Set $SIDECARPORT environment variable to specify a custom one |
| SbatchPath | path to your Slurm's sbatch binary |
| ScancelPath | path to your Slurm's scancel binary |
Expand All @@ -91,19 +108,14 @@ building the docker image (`docker compose up -d --build --force-recreate` will
### :wrench: Environment Variables list

Here's the complete list of every customizable environment variable. When specified, it overwrites the listed key
within the InterLink config file.
within the SLURM config file.

| Env | Value |
|--------------|-----------|
| VK_CONFIG_PATH | VK config file path |
| INTERLINKURL | the URL to allow the Virtual Kubelet to contact the InterLink module. Do not specify a port here. Overwrites InterlinkURL. |
| INTERLINKPORT | the InterLink listening port. InterLink and VK will communicate over this port. Overwrites InterlinkPort. |
| INTERLINKCONFIGPATH | your InterLink config file path. Default is `./kustomizations/InterLinkConfig.yaml` |
| SIDECARURL | the URL to allow InterLink to communicate with the Sidecar module (docker, slurm, etc). Do not specify port here. Overwrites SidecarURL. |
| SLURMCONFIGPATH | your SLURM config file path. Default is `/etc/interlink/SlurmConfig.yaml` |
| SIDECARPORT | the Sidecar listening port. Docker default is 4000, Slurm default is 4001. |
| SBATCHPATH | path to your Slurm's sbatch binary. Overwrites SbatchPath. |
| SCANCELPATH | path to your Slurm's scancel binary. Overwrites ScancelPath. |
| VKTOKENFILE | path to a file containing your token fot OAuth2 proxy authentication. Overwrites VKTokenFile. |
| SHARED_FS | set this env to "true" to save configmaps values inside files directly mounted to Singularity containers instead of using ENVS to create them later |
| CUSTOMKUBECONF | path to a service account kubeconfig |
| TSOCKS | true or false, to use tsocks library allowing proxy networking. Working on Slurm sidecar at the moment. Overwrites Tsocks. |
Expand Down
17 changes: 8 additions & 9 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,20 @@ import (
"github.com/virtual-kubelet/virtual-kubelet/log"
logruslogger "github.com/virtual-kubelet/virtual-kubelet/log/logrus"

commonIL "github.com/intertwin-eu/interlink-slurm-plugin/pkg/common"
slurm "github.com/intertwin-eu/interlink-slurm-plugin/pkg/slurm"
)

func main() {
logger := logrus.StandardLogger()

interLinkConfig, err := commonIL.NewInterLinkConfig()
slurmConfig, err := slurm.NewSlurmConfig()
if err != nil {
panic(err)
}

if interLinkConfig.VerboseLogging {
if slurmConfig.VerboseLogging {
logger.SetLevel(logrus.DebugLevel)
} else if interLinkConfig.ErrorsOnlyLogging {
} else if slurmConfig.ErrorsOnlyLogging {
logger.SetLevel(logrus.ErrorLevel)
} else {
logger.SetLevel(logrus.InfoLevel)
Expand All @@ -34,10 +33,10 @@ func main() {
JobIDs := make(map[string]*slurm.JidStruct)
Ctx, cancel := context.WithCancel(context.Background())
defer cancel()
log.G(Ctx).Debug("Debug level: " + strconv.FormatBool(interLinkConfig.VerboseLogging))
log.G(Ctx).Debug("Debug level: " + strconv.FormatBool(slurmConfig.VerboseLogging))

SidecarAPIs := slurm.SidecarHandler{
Config: interLinkConfig,
Config: slurmConfig,
JIDs: &JobIDs,
Ctx: Ctx,
}
Expand All @@ -48,10 +47,10 @@ func main() {
mutex.HandleFunc("/delete", SidecarAPIs.StopHandler)
mutex.HandleFunc("/getLogs", SidecarAPIs.GetLogsHandler)

slurm.CreateDirectories(interLinkConfig)
slurm.LoadJIDs(Ctx, interLinkConfig, &JobIDs)
slurm.CreateDirectories(slurmConfig)
slurm.LoadJIDs(Ctx, slurmConfig, &JobIDs)

err = http.ListenAndServe(":"+interLinkConfig.Sidecarport, mutex)
err = http.ListenAndServe(":"+slurmConfig.Sidecarport, mutex)
if err != nil {
log.G(Ctx).Fatal(err)
}
Expand Down
4 changes: 2 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ WORKDIR /root

COPY --from=build-stage /app/bin/slurm-sidecar /sidecar/slurm-sidecar

ENV INTERLINKCONFIGPATH=/root/InterLinkConfig.yaml
ENV SLURMCONFIGPATH=/root/SlurmConfig.yaml

COPY docker/InterLinkConfig.yaml .
COPY docker/SlurmConfig.yaml .

RUN apt update && apt install -y software-properties-common \
&& add-apt-repository -y ppa:apptainer/ppa \
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
VKTokenFile: "$HOME/interLink/token"
InterlinkURL: "http://192.168.122.121"
SidecarURL: "http://localhost"
InterlinkPort: "3000"
SidecarPort: "4000"
SbatchPath: "/usr/bin/sbatch"
ScancelPath: "/usr/bin/scancel"
SqueuePath: "/usr/bin/squeue"
CommandPrefix: ""
SingularityPrefix: ""
ExportPodData: true
DataRootFolder: ".local/interlink/jobs/"
ServiceAccount: "interlink"
Namespace: "vk"
Tsocks: false
TsocksPath: "$WORK/tsocks-1.8beta5+ds1/libtsocks.so"
TsocksLoginNode: "login01"
BashPath: /bin/bash
VerboseLogging: true
ErrorsOnlyLogging: false
ErrorsOnlyLogging: false
10 changes: 3 additions & 7 deletions docker/InterLinkConfig.yaml → examples/config/SlurmConfig.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
VKTokenFile: "$HOME/interLink/token"
InterlinkURL: "http://interlink-api"
SidecarURL: "http://docker-sidecar"
InterlinkPort: "3000"
SidecarPort: "4000"
SbatchPath: "/usr/bin/sbatch"
ScancelPath: "/usr/bin/scancel"
SqueuePath: "/usr/bin/squeue"
CommandPrefix: ""
SingularityPrefix: ""
ExportPodData: true
DataRootFolder: ".local/interlink/jobs/"
ServiceAccount: "interlink"
Namespace: "vk"
Tsocks: false
TsocksPath: "$WORK/tsocks-1.8beta5+ds1/libtsocks.so"
TsocksLoginNode: "login01"
BashPath: /bin/bash
VerboseLogging: true
ErrorsOnlyLogging: false
Pod_IP: "172.16.9.11"
ErrorsOnlyLogging: false
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ toolchain go1.21.3
require (
github.com/alexellis/go-execute v0.6.0
github.com/containerd/containerd v1.7.6
github.com/intertwin-eu/interlink v0.0.0-20240523154644-820ca4bd6fac
github.com/sirupsen/logrus v1.9.3
github.com/virtual-kubelet/virtual-kubelet v1.11.0
gopkg.in/yaml.v2 v2.4.0
Expand All @@ -33,8 +34,6 @@ require (
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
github.com/stretchr/testify v1.9.0 // indirect
golang.org/x/net v0.20.0 // indirect
golang.org/x/oauth2 v0.16.0 // indirect
golang.org/x/sys v0.17.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 h1:K6RDEckDVWvDI9JAJY
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4=
github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/intertwin-eu/interlink v0.0.0-20240523154644-820ca4bd6fac h1:LdpDorMFbMkcIpO9F9LmvBaUteyWrqEKzDjuhcF4fAc=
github.com/intertwin-eu/interlink v0.0.0-20240523154644-820ca4bd6fac/go.mod h1:BxkHXL7pr4PwdpGR685KgidM+r94N1W+S+cpc/o2MX8=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
Expand Down
166 changes: 0 additions & 166 deletions pkg/common/func.go

This file was deleted.

Loading

0 comments on commit fd9e9c1

Please sign in to comment.