Create a new runner async after one gets claimed

This commit is contained in:
Maximilian Paß
2021-10-21 11:31:57 +02:00
parent dff3df9cc7
commit 055fa43227
2 changed files with 9 additions and 4 deletions

View File

@@ -234,10 +234,12 @@ func (n *NomadEnvironment) UpdateRunnerSpecs(apiClient nomad.ExecutorAPI) error
func (n *NomadEnvironment) Sample(apiClient nomad.ExecutorAPI) (runner.Runner, bool) {
r, ok := n.idleRunners.Sample()
if ok {
err := n.createRunner(apiClient)
if err != nil {
log.WithError(err).WithField("environmentID", n.ID()).Error("Couldn't create new runner for claimed one")
}
go func() {
err := n.createRunner(apiClient)
if err != nil {
log.WithError(err).WithField("environmentID", n.ID()).Error("Couldn't create new runner for claimed one")
}
}()
}
return r, ok
}