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

@ -219,15 +219,17 @@ func (n *NomadEnvironment) Register() error {
return nil
}
func (n *NomadEnvironment) Delete() error {
func (n *NomadEnvironment) Delete(local bool) error {
n.cancel()
err := n.removeRunners()
if err != nil {
return err
}
err = n.apiClient.DeleteJob(*n.job.ID)
if err != nil {
return fmt.Errorf("couldn't delete environment job: %w", err)
if !local {
err := n.removeRunners()
if err != nil {
return err
}
err = n.apiClient.DeleteJob(*n.job.ID)
if err != nil {
return fmt.Errorf("couldn't delete environment job: %w", err)
}
}
return nil
}