Attach to a container's log_stream before they're started

So we're not displaying output of all previous logs for a container, we attach,
if possible, to a container before the container is started.

LogPrinter checks if a container has a log_stream already attached and
print from that rather than always attempting to attach one itself.

Signed-off-by: Mazz Mosley <mazz@houseofmnowster.com>
This commit is contained in:
Mazz Mosley 2015-10-21 17:28:16 +01:00
commit 7603ebea9b
6 changed files with 66 additions and 27 deletions

View file

@ -18,6 +18,7 @@ from compose.service import ConvergenceStrategy
class ProjectTestCase(DockerClientTestCase):
def run_up(self, cfg, **kwargs):
kwargs.setdefault('timeout', 1)
kwargs.setdefault('detached', True)
project = self.make_project(cfg)
project.up(**kwargs)
@ -184,7 +185,8 @@ def converge(service,
do_build=True):
"""Create a converge plan from a strategy and execute the plan."""
plan = service.convergence_plan(strategy)
return service.execute_convergence_plan(plan, do_build=do_build, timeout=1)
containers, logging_threads = zip(*service.execute_convergence_plan(plan, do_build=do_build, timeout=1))
return containers
class ServiceStateTest(DockerClientTestCase):