Fix Goroutine Leak of Environment Get

that was caused by creating an intermediate environment `fetchedEnvironment` when fetching the environments but not removing it in case that we just copy its configuration to the existing environment.
This commit is contained in:
Maximilian Paß
2023-09-11 10:22:19 +02:00
parent 460b8b2065
commit 59da36303c
8 changed files with 48 additions and 33 deletions

View File

@@ -72,6 +72,10 @@ func (m *NomadEnvironmentManager) Get(id dto.EnvironmentID, fetch bool) (
ok = true
default:
executionEnvironment.SetConfigFrom(fetchedEnvironment)
err = fetchedEnvironment.Delete(true)
if err != nil {
log.WithError(err).Warn("Failed to remove environment locally")
}
}
}
@@ -98,7 +102,7 @@ func (m *NomadEnvironmentManager) CreateOrUpdate(
if isExistingEnvironment {
// Remove existing environment to force downloading the newest Docker image.
// See https://github.com/openHPI/poseidon/issues/69
err = environment.Delete()
err = environment.Delete(false)
if err != nil {
return false, fmt.Errorf("failed to remove the environment: %w", err)
}