diff --git a/internal/environment/environment.go b/internal/environment/environment.go index 6de0c46..5f01c5c 100644 --- a/internal/environment/environment.go +++ b/internal/environment/environment.go @@ -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 } diff --git a/internal/runner/manager.go b/internal/runner/manager.go index 0bf5cc1..dab5abd 100644 --- a/internal/runner/manager.go +++ b/internal/runner/manager.go @@ -141,15 +141,18 @@ func (m *NomadRunnerManager) Claim(environmentID dto.EnvironmentID, duration int if !ok { return nil, ErrUnknownExecutionEnvironment } + log.Debug("Before Sample") runner, ok := environment.Sample(m.apiClient) if !ok { return nil, ErrNoRunnersAvailable } m.usedRunners.Add(runner) + log.Debug("Before Mark Runner As Used") err := m.apiClient.MarkRunnerAsUsed(runner.ID(), duration) if err != nil { return nil, fmt.Errorf("can't mark runner as used: %w", err) } + log.Debug("After Mark Runner As Used") runner.SetupTimeout(time.Duration(duration) * time.Second) return runner, nil