compose/tests
Alberto Piai 394c8efe98 fix race condition in Service.create_container()
The Service.create_container() method fetches a list of the current
containers in order to determine the next container number. In doing so,
it makes several API calls: one to fetch the list of containers, then
one per container in order to inspect it.

In some situations it can happen that a container is removed after
having been listed: in that case, the call to inspect will get a 404 and
raise a NotFound.

One situation in which this has been observed is when trying to
concurrently create multiple one-off containers for the same service
(using `docker-compose run` and a unique `--name`), as described in
more detail in gh-5179.

This patch adds a unit test that simulates the race between the
calls to list and to inspect, and changes Service._next_container_number
to skip removed containers instead of blowing up.

Fixes gh-5179

Signed-off-by: Alberto Piai <apiai@sensational.ch>
2018-03-27 10:21:15 +02:00
..
acceptance Merge pull request #5788 from mnottale/dash-underscore-in-project-name 2018-03-19 05:33:21 -07:00
fixtures Merge pull request #5684 from docker/compat_mode 2018-02-26 10:42:59 -08:00
integration Add support for cpu_rt_period and cpu_rt_runtime. 2018-03-19 13:18:35 +01:00
unit fix race condition in Service.create_container() 2018-03-27 10:21:15 +02:00
__init__.py Update pre-commit config to enforace that future imports exist in all files. 2016-01-07 13:09:03 -05:00
helpers.py Bump python SDK to 3.0.0 2018-01-31 18:54:58 -08:00