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:

committed by
Sebastian Serth

parent
73759f8a3c
commit
13a9da95e5
@@ -36,6 +36,7 @@ func NewNomadEnvironmentManager(
|
||||
runnerManager runner.Manager,
|
||||
apiClient nomad.ExecutorAPI,
|
||||
templateJobFile string,
|
||||
ctx context.Context,
|
||||
) (*NomadEnvironmentManager, error) {
|
||||
if err := loadTemplateEnvironmentJobHCL(templateJobFile); err != nil {
|
||||
return nil, err
|
||||
@@ -43,7 +44,7 @@ func NewNomadEnvironmentManager(
|
||||
|
||||
m := &NomadEnvironmentManager{&AbstractManager{nil, runnerManager},
|
||||
apiClient, templateEnvironmentJobHCL}
|
||||
if err := util.RetryExponential(func() error { return m.Load() }); err != nil {
|
||||
if err := util.RetryExponentialContext(ctx, func() error { return m.Load() }); err != nil {
|
||||
log.WithError(err).Error("Error recovering the execution environments")
|
||||
}
|
||||
runnerManager.Load()
|
||||
|
Reference in New Issue
Block a user