Persist runner timeout in metadata

To be able to restore the runner timeouts even after a Poseidon restart,
the timeout is stored in the Nomad metadata. The timeout will restart,
but at least the runner will be returned at all.
This commit is contained in:
Konrad Hanff
2021-06-22 11:11:33 +02:00
parent ae08e37106
commit e0e254a6af
9 changed files with 116 additions and 135 deletions

View File

@@ -11,6 +11,7 @@ import (
"gitlab.hpi.de/codeocean/codemoon/poseidon/util"
"io"
"net/url"
"strconv"
"time"
)
@@ -255,7 +256,7 @@ func checkEvaluation(eval *nomadApi.Evaluation) (err error) {
return err
}
func (a *APIClient) MarkRunnerAsUsed(runnerID string) error {
func (a *APIClient) MarkRunnerAsUsed(runnerID string, duration int) error {
job, err := a.job(runnerID)
if err != nil {
return fmt.Errorf("couldn't retrieve job info: %w", err)
@@ -264,6 +265,10 @@ func (a *APIClient) MarkRunnerAsUsed(runnerID string) error {
if err != nil {
return fmt.Errorf("couldn't update runner in job as used: %w", err)
}
err = SetMetaConfigValue(job, ConfigMetaTimeoutKey, strconv.Itoa(duration))
if err != nil {
return fmt.Errorf("couldn't update runner in job with timeout: %w", err)
}
_, err = a.RegisterNomadJob(job)
if err != nil {
return fmt.Errorf("couldn't update runner config: %w", err)