mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #19194 from LK4D4/fix_race_clean_net
Fix race on cleaning endpoint data
This commit is contained in:
commit
45211af702
1 changed files with 25 additions and 1 deletions
|
@ -11,6 +11,7 @@ import (
|
||||||
"github.com/docker/docker/image"
|
"github.com/docker/docker/image"
|
||||||
"github.com/docker/engine-api/types"
|
"github.com/docker/engine-api/types"
|
||||||
"github.com/docker/engine-api/types/filters"
|
"github.com/docker/engine-api/types/filters"
|
||||||
|
networktypes "github.com/docker/engine-api/types/network"
|
||||||
"github.com/docker/go-connections/nat"
|
"github.com/docker/go-connections/nat"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -344,7 +345,30 @@ func (daemon *Daemon) transformContainer(container *container.Container, ctx *li
|
||||||
newC.Created = container.Created.Unix()
|
newC.Created = container.Created.Unix()
|
||||||
newC.Status = container.State.String()
|
newC.Status = container.State.String()
|
||||||
newC.HostConfig.NetworkMode = string(container.HostConfig.NetworkMode)
|
newC.HostConfig.NetworkMode = string(container.HostConfig.NetworkMode)
|
||||||
newC.NetworkSettings = &types.SummaryNetworkSettings{container.NetworkSettings.Networks}
|
// copy networks to avoid races
|
||||||
|
networks := make(map[string]*networktypes.EndpointSettings)
|
||||||
|
for name, network := range container.NetworkSettings.Networks {
|
||||||
|
if network == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
networks[name] = &networktypes.EndpointSettings{
|
||||||
|
EndpointID: network.EndpointID,
|
||||||
|
Gateway: network.Gateway,
|
||||||
|
IPAddress: network.IPAddress,
|
||||||
|
IPPrefixLen: network.IPPrefixLen,
|
||||||
|
IPv6Gateway: network.IPv6Gateway,
|
||||||
|
GlobalIPv6Address: network.GlobalIPv6Address,
|
||||||
|
GlobalIPv6PrefixLen: network.GlobalIPv6PrefixLen,
|
||||||
|
MacAddress: network.MacAddress,
|
||||||
|
}
|
||||||
|
if network.IPAMConfig != nil {
|
||||||
|
networks[name].IPAMConfig = &networktypes.EndpointIPAMConfig{
|
||||||
|
IPv4Address: network.IPAMConfig.IPv4Address,
|
||||||
|
IPv6Address: network.IPAMConfig.IPv6Address,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
newC.NetworkSettings = &types.SummaryNetworkSettings{Networks: networks}
|
||||||
|
|
||||||
newC.Ports = []types.Port{}
|
newC.Ports = []types.Port{}
|
||||||
for port, bindings := range container.NetworkSettings.Ports {
|
for port, bindings := range container.NetworkSettings.Ports {
|
||||||
|
|
Loading…
Add table
Reference in a new issue