Implement merge request review comments

This commit is contained in:
Maximilian Paß
2021-05-06 13:26:55 +02:00
parent 0dc4d28c1b
commit dba7160a41
10 changed files with 136 additions and 112 deletions

View File

@@ -2,19 +2,15 @@ package nomad
import (
nomadApi "github.com/hashicorp/nomad/api"
"gitlab.hpi.de/codeocean/codemoon/poseidon/logging"
"net/url"
)
var log = logging.GetLogger("nomad")
// ExecutorApi provides access to an container orchestration solution
type ExecutorApi interface {
LoadJobList() (list []*nomadApi.JobListStub, err error)
GetJobScale(jobId string) (jobScale int, err error)
SetJobScaling(jobId string, count int, reason string) (err error)
LoadRunners(jobId string) (runnerIds []string, err error)
CreateDebugJob()
}
// ApiClient provides access to the Nomad functionality
@@ -45,25 +41,6 @@ func (apiClient *ApiClient) LoadJobList() (list []*nomadApi.JobListStub, err err
return
}
// CreateDebugJob creates a simple python job in the nomad cluster
func (apiClient *ApiClient) CreateDebugJob() {
job := nomadApi.NewBatchJob("python", "python", "global", 50)
job.AddDatacenter("dc1")
group := nomadApi.NewTaskGroup("python", 5)
task := nomadApi.NewTask("python", "docker")
task.SetConfig("image", "openhpi/co_execenv_python:3.8")
task.SetConfig("command", "sleep")
task.SetConfig("args", []string{"infinity"})
group.AddTask(task)
job.AddTaskGroup(group)
register, w, err := apiClient.client.Jobs().Register(job, nil)
log.Printf("response: %+v", register)
log.Printf("meta: %+v", w)
if err != nil {
log.WithError(err).Fatal("Error creating nomad job")
}
}
// GetJobScale returns the scale of the passed job.
func (apiClient *ApiClient) GetJobScale(jobId string) (jobScale int, err error) {
status, _, err := apiClient.client.Jobs().ScaleStatus(jobId, nil)