Introduce a context for RetryExponential

as second criteria (next to the maximum number of attempts) for canceling the retrying. This is required as we started with the previous commit to retry the nomad environment recovery. This always fails for unit tests (as they are not connected to an Nomad cluster). Before, we ignored the one error but the retrying leads to unit test timeouts.
Additionally, we now stop retrying to create a runner when the environment got deleted.
This commit is contained in:
Maximilian Paß
2023-08-16 18:22:44 +02:00
committed by Sebastian Serth
parent 73759f8a3c
commit 13a9da95e5
7 changed files with 68 additions and 41 deletions

View File

@ -245,9 +245,7 @@ func (n *NomadEnvironment) Sample() (runner.Runner, bool) {
r, ok := n.idleRunners.Sample()
if ok && n.idleRunners.Length() < n.PrewarmingPoolSize() {
go func() {
err := util.RetryExponential(func() error {
return n.createRunner(false)
})
err := util.RetryExponentialContext(n.ctx, func() error { return n.createRunner(false) })
if err != nil {
log.WithError(err).WithField(dto.KeyEnvironmentID, n.ID().ToString()).
Error("Couldn't create new runner for claimed one")