Skip to content

Commit 09e6b02

Browse files
committed
up/start/run: don't wait for disabled service
Signed-off-by: Nick Sieger <[email protected]>
1 parent 3c561e7 commit 09e6b02

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed

pkg/compose/convergence.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,12 @@ func shouldWaitForDependency(serviceName string, dependencyConfig types.ServiceD
352352
return false, nil
353353
}
354354
if service, err := project.GetService(serviceName); err != nil {
355+
for _, ds := range project.DisabledServices {
356+
if ds.Name == serviceName {
357+
// don't wait for disabled service (--no-deps)
358+
return false, nil
359+
}
360+
}
355361
return false, err
356362
} else if service.Scale == 0 {
357363
// don't wait for the dependency which configured to have 0 containers running
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
version: '3.8'
2+
services:
3+
my-service:
4+
image: alpine
5+
command: tail -f /dev/null
6+
depends_on:
7+
nginx: {condition: service_healthy}
8+
9+
nginx:
10+
image: nginx:alpine
11+
healthcheck:
12+
test: "echo | nc -w 5 localhost:80"
13+
interval: 2s
14+
timeout: 1s
15+
retries: 10

pkg/e2e/recreate_no_deps_test.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
Copyright 2022 Docker Compose CLI authors
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package e2e
18+
19+
import (
20+
"testing"
21+
22+
"gotest.tools/v3/icmd"
23+
)
24+
25+
func TestRecreateWithNoDeps(t *testing.T) {
26+
c := NewParallelCLI(t, WithEnv(
27+
"COMPOSE_PROJECT_NAME=recreate-no-deps",
28+
))
29+
30+
res := c.RunDockerComposeCmdNoCheck(t, "-f", "fixtures/dependencies/recreate-no-deps.yaml", "up", "-d")
31+
res.Assert(t, icmd.Success)
32+
33+
res = c.RunDockerComposeCmdNoCheck(t, "-f", "fixtures/dependencies/recreate-no-deps.yaml", "up", "-d", "--force-recreate", "--no-deps", "my-service")
34+
res.Assert(t, icmd.Success)
35+
36+
RequireServiceState(t, c, "my-service", "running")
37+
38+
c.RunDockerComposeCmd(t, "down")
39+
}

0 commit comments

Comments
 (0)