loop, rather than recurse, for container creation
the lock can be held for an arbitrary amount of time, so this risks
stack overflowing. observed irl a giant stack coming from a faulty
worker.
@@ -361,6 +361,7 @@ func (p *containerProvider) findOrCreateContainer(
findContainerFunc func() (dbng.CreatingContainer, dbng.CreatedContainer, error),
createContainerFunc func() (dbng.CreatingContainer, error),
) (Container, error) {
+ for {
var gardenContainer garden.Container
creatingContainer, createdContainer, err := findContainerFunc()
@@ -428,17 +429,7 @@ func (p *containerProvider) findOrCreateContainer(
if !acquired {
p.clock.Sleep(creatingContainerRetryDelay)
- return p.findOrCreateContainer(
- logger,
- resourceUser,
- cancel,
- delegate,
- metadata,
- spec,
- resourceTypes,
- findContainerFunc,
- createContainerFunc,
- )
+ continue
}
defer lock.Release()
@@ -480,6 +471,7 @@ func (p *containerProvider) findOrCreateContainer(
gardenContainer,
)
}
+}
func (p *containerProvider) constructGardenWorkerContainer(
logger lager.Logger,
