From cacff89ceff26fe071b7af215ef8d96cacd8753e Mon Sep 17 00:00:00 2001 From: Nick Sieger Date: Fri, 27 May 2022 09:18:29 -0500 Subject: [PATCH 1/2] fix: bring up services with deps with --no-deps Don't fail on not finding dependent services because they were put in the disabled slice. Fixes #9427. Signed-off-by: Nick Sieger --- pkg/compose/create.go | 6 +++++- pkg/e2e/start_stop_test.go | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/pkg/compose/create.go b/pkg/compose/create.go index e9589cf75..bc551b167 100644 --- a/pkg/compose/create.go +++ b/pkg/compose/create.go @@ -183,7 +183,11 @@ func prepareServicesDependsOn(p *types.Project) error { if service.DependsOn == nil { service.DependsOn = make(types.DependsOnConfig) } - deps, err := p.GetServices(dependencies...) + + // Verify dependencies exist in the project, whether disabled or not + projAllServices := types.Project{} + projAllServices.Services = p.AllServices() + deps, err := projAllServices.GetServices(dependencies...) if err != nil { return err } diff --git a/pkg/e2e/start_stop_test.go b/pkg/e2e/start_stop_test.go index 39dfdff33..f1ea41c34 100644 --- a/pkg/e2e/start_stop_test.go +++ b/pkg/e2e/start_stop_test.go @@ -131,6 +131,12 @@ func TestStartStopWithDependencies(t *testing.T) { assert.Assert(t, strings.Contains(res.Combined(), "e2e-start-stop-with-dependencies-foo-1"), res.Combined()) }) + t.Run("Up no-deps", func(t *testing.T) { + _ = c.RunDockerComposeCmd("--project-name", projectName, "down") + res := c.RunDockerComposeCmd("-f", "./fixtures/dependencies/compose.yaml", "--project-name", projectName, "up", "--no-deps", "-d", "foo") + assert.Assert(t, strings.Contains(res.Combined(), "Container e2e-start-stop-with-dependencies-foo-1 Started"), res.Combined()) + }) + t.Run("down", func(t *testing.T) { _ = c.RunDockerComposeCmd("--project-name", projectName, "down") }) From 28c0fbfdc0944e13b6d47c4c85f376fb8ae5ae89 Mon Sep 17 00:00:00 2001 From: Nick Sieger Date: Tue, 31 May 2022 16:32:29 -0500 Subject: [PATCH 2/2] e2e: reproduce bug with links Signed-off-by: Nick Sieger --- pkg/e2e/fixtures/links/compose.yaml | 8 ++++++++ pkg/e2e/start_stop_test.go | 5 +++-- 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 pkg/e2e/fixtures/links/compose.yaml diff --git a/pkg/e2e/fixtures/links/compose.yaml b/pkg/e2e/fixtures/links/compose.yaml new file mode 100644 index 000000000..8c182c4d2 --- /dev/null +++ b/pkg/e2e/fixtures/links/compose.yaml @@ -0,0 +1,8 @@ +services: + foo: + image: nginx:alpine + links: + - bar + + bar: + image: nginx:alpine diff --git a/pkg/e2e/start_stop_test.go b/pkg/e2e/start_stop_test.go index f1ea41c34..f649112a2 100644 --- a/pkg/e2e/start_stop_test.go +++ b/pkg/e2e/start_stop_test.go @@ -131,10 +131,11 @@ func TestStartStopWithDependencies(t *testing.T) { assert.Assert(t, strings.Contains(res.Combined(), "e2e-start-stop-with-dependencies-foo-1"), res.Combined()) }) - t.Run("Up no-deps", func(t *testing.T) { + t.Run("Up no-deps links", func(t *testing.T) { _ = c.RunDockerComposeCmd("--project-name", projectName, "down") - res := c.RunDockerComposeCmd("-f", "./fixtures/dependencies/compose.yaml", "--project-name", projectName, "up", "--no-deps", "-d", "foo") + res := c.RunDockerComposeCmd("-f", "./fixtures/links/compose.yaml", "--project-name", projectName, "up", "--no-deps", "-d", "foo") assert.Assert(t, strings.Contains(res.Combined(), "Container e2e-start-stop-with-dependencies-foo-1 Started"), res.Combined()) + assert.Assert(t, !strings.Contains(res.Combined(), "Container e2e-start-stop-with-dependencies-bar-1 Started"), res.Combined()) }) t.Run("down", func(t *testing.T) {