Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ContainerStart must run sequentially for engine to assing distinct ports within configured range #10067

Merged
merged 1 commit into from
Dec 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 7 additions & 11 deletions pkg/compose/convergence.go
Original file line number Diff line number Diff line change
Expand Up @@ -721,21 +721,17 @@ func (s *composeService) startService(ctx context.Context, project *types.Projec
}

w := progress.ContextWriter(ctx)
eg, ctx := errgroup.WithContext(ctx)
for _, container := range containers {
if container.State == ContainerRunning {
continue
}
container := container
eg.Go(func() error {
eventName := getContainerProgressName(container)
w.Event(progress.StartingEvent(eventName))
err := s.apiClient().ContainerStart(ctx, container.ID, moby.ContainerStartOptions{})
if err == nil {
w.Event(progress.StartedEvent(eventName))
}
eventName := getContainerProgressName(container)
w.Event(progress.StartingEvent(eventName))
err := s.apiClient().ContainerStart(ctx, container.ID, moby.ContainerStartOptions{})
if err != nil {
return err
})
}
w.Event(progress.StartedEvent(eventName))
}
return eg.Wait()
return nil
}
10 changes: 10 additions & 0 deletions pkg/e2e/compose_up_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,13 @@ func TestUpExitCodeFrom(t *testing.T) {

c.RunDockerComposeCmd(t, "--project-name", projectName, "down", "--remove-orphans")
}

func TestPortRange(t *testing.T) {
c := NewParallelCLI(t)
const projectName = "e2e-port-range"

res := c.RunDockerComposeCmdNoCheck(t, "-f", "fixtures/port-range/compose.yaml", "--project-name", projectName, "up", "-d")
res.Assert(t, icmd.Success)

c.RunDockerComposeCmd(t, "--project-name", projectName, "down", "--remove-orphans")
}
6 changes: 6 additions & 0 deletions pkg/e2e/fixtures/port-range/compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
services:
a:
image: nginx:alpine
scale: 5
ports:
- "6005-6015:80"