Implement merge request review comments

This commit is contained in:
Maximilian Paß
2021-05-10 11:58:57 +02:00
parent ed735f284f
commit 5a5ab8f02b
4 changed files with 40 additions and 84 deletions

View File

@@ -5,14 +5,10 @@ import (
"encoding/json"
"github.com/google/uuid"
"gitlab.hpi.de/codeocean/codemoon/poseidon/api/dto"
"gitlab.hpi.de/codeocean/codemoon/poseidon/logging"
"gitlab.hpi.de/codeocean/codemoon/poseidon/store"
"sync"
"time"
)
var log = logging.GetLogger("runner")
// Status is the type for the status of a Runner.
type Status string
@@ -50,10 +46,6 @@ type Runner interface {
// DeleteExecution deletes the execution of the runner with the specified id.
DeleteExecution(ExecutionId)
// Execute runs one of the runners Executions by it's id
// ok will be false if the runner has no execution with the provided id
Execute(ExecutionId) (err error, ok bool)
}
// ExerciseRunner is an abstraction to communicate with Nomad allocations.
@@ -128,19 +120,6 @@ func (r *ExerciseRunner) DeleteExecution(id ExecutionId) {
delete(r.executions, id)
}
func (r *ExerciseRunner) Execute(id ExecutionId) (err error, ok bool) {
execution, ok := r.Execution(id)
if !ok {
return
}
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(execution.TimeLimit)*time.Second)
defer cancel()
log.WithField("Context", ctx).Printf("ToDo: Running execution")
// ToDo: Implement command execution
// r.nomadApiClient.ExecuteCommand(r.id, ctx, )
return
}
// NewContext creates a context containing a runner.
func NewContext(ctx context.Context, runner Runner) context.Context {
return context.WithValue(ctx, runnerContextKey, runner)