From f5827052a49db0cbf750ed4c3a7b85d2255f0cc8 Mon Sep 17 00:00:00 2001 From: Andrea Luzzardi Date: Tue, 2 Dec 2014 17:45:03 -0800 Subject: [PATCH] Port filtering: Fixed a race condition. Port filtering used to rely on NetworkSettings, however, those are not populated until the container is started. While stopped, the filter was unaware of the port being used, resulting in a race condition. Signed-off-by: Andrea Luzzardi --- scheduler/filter/port.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scheduler/filter/port.go b/scheduler/filter/port.go index 9bd2a04f6c..e6a0914e8d 100644 --- a/scheduler/filter/port.go +++ b/scheduler/filter/port.go @@ -33,7 +33,7 @@ func (p *PortFilter) Filter(config *dockerclient.ContainerConfig, nodes []*clust func (p *PortFilter) portAlreadyInUse(node *cluster.Node, requested dockerclient.PortBinding) bool { for _, c := range node.Containers() { - for _, port := range c.Info.NetworkSettings.Ports { + for _, port := range c.Info.HostConfig.PortBindings { for _, binding := range port { if binding.HostPort == requested.HostPort { // Another container on the same host is binding on the same