Fix regression in `docker-compose up`

When an upstream dependency (e.g. a db) has a container but a downstream
service (e.g. a web app) doesn't, a web container is not created on
`docker-compose up`.

Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
This commit is contained in:
Aanand Prasad 2015-05-21 20:03:02 +01:00
parent 276fee105b
commit 4795fd874f
3 changed files with 17 additions and 6 deletions

View File

@ -248,10 +248,13 @@ class Project(object):
if updated_dependencies:
log.debug(
'%s has not changed but its dependencies (%s) have, so recreating',
'%s has upstream changes (%s)',
service.name, ", ".join(updated_dependencies),
)
plan = service.recreate_plan()
plan = service.convergence_plan(
allow_recreate=allow_recreate,
smart_recreate=False,
)
else:
plan = service.convergence_plan(
allow_recreate=allow_recreate,

View File

@ -294,10 +294,6 @@ class Service(object):
return ConvergencePlan('recreate', containers)
def recreate_plan(self):
containers = self.containers(stopped=True)
return ConvergencePlan('recreate', containers)
def _containers_have_diverged(self, containers):
config_hash = self.config_hash()
has_diverged = False

View File

@ -174,6 +174,18 @@ class ProjectTest(DockerClientTestCase):
project.kill()
project.remove_stopped()
def test_project_up_starts_uncreated_services(self):
db = self.create_service('db')
web = self.create_service('web', links=[(db, 'db')])
project = Project('composetest', [db, web], self.client)
project.up(['db'])
self.assertEqual(len(project.containers()), 1)
project.up()
self.assertEqual(len(project.containers()), 2)
self.assertEqual(len(db.containers()), 1)
self.assertEqual(len(web.containers()), 1)
def test_project_up_recreates_containers(self):
web = self.create_service('web')
db = self.create_service('db', volumes=['/etc'])