Skip to content

Commit

Permalink
fix: empty out the aliases on recreation
Browse files Browse the repository at this point in the history
  • Loading branch information
simskij committed Jul 24, 2023
1 parent dfe4346 commit 48e689f
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion pkg/container/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,25 @@ func (client dockerClient) StopContainer(c t.Container, timeout time.Duration) e
return nil
}

func (client dockerClient) GetNetworkConfig(c t.Container) *network.NetworkingConfig {
config := &network.NetworkingConfig{
EndpointsConfig: c.ContainerInfo().NetworkSettings.Networks,
}

for _, ep := range config.EndpointsConfig {
// This keeps accumulating across upgrades with no apparent added value
// so throwing the information away to prevent overflows.
ep.Aliases = nil
}
return config

Check warning on line 221 in pkg/container/client.go

View check run for this annotation

Codecov / codecov/patch

pkg/container/client.go#L211-L221

Added lines #L211 - L221 were not covered by tests
}

func (client dockerClient) StartContainer(c t.Container) (t.ContainerID, error) {
bg := context.Background()
config := c.GetCreateConfig()
hostConfig := c.GetCreateHostConfig()
networkConfig := &network.NetworkingConfig{EndpointsConfig: c.ContainerInfo().NetworkSettings.Networks}
networkConfig := client.GetNetworkConfig(c)

Check warning on line 229 in pkg/container/client.go

View check run for this annotation

Codecov / codecov/patch

pkg/container/client.go#L228-L229

Added lines #L228 - L229 were not covered by tests
// simpleNetworkConfig is a networkConfig with only 1 network.
// see: https://github.com/docker/docker/issues/29265
simpleNetworkConfig := func() *network.NetworkingConfig {
Expand All @@ -228,6 +242,7 @@ func (client dockerClient) StartContainer(c t.Container) (t.ContainerID, error)
name := c.Name()

log.Infof("Creating %s", name)

Check warning on line 245 in pkg/container/client.go

View check run for this annotation

Codecov / codecov/patch

pkg/container/client.go#L245

Added line #L245 was not covered by tests
createdContainer, err := client.api.ContainerCreate(bg, config, hostConfig, simpleNetworkConfig, nil, name)
if err != nil {
return "", err
Expand Down

0 comments on commit 48e689f

Please sign in to comment.