From 854cad3c1404c410687729642e35493cfd0bedd3 Mon Sep 17 00:00:00 2001 From: Victor Vieux Date: Thu, 18 Feb 2016 10:01:26 -0800 Subject: [PATCH] don't erase hostconfig on refresh Signed-off-by: Victor Vieux --- cluster/engine.go | 3 +++ test/integration/rescheduling.bats | 28 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/cluster/engine.go b/cluster/engine.go index 213594bfc2..bb6086d210 100644 --- a/cluster/engine.go +++ b/cluster/engine.go @@ -620,6 +620,9 @@ func (e *Engine) updateContainer(c dockerclient.Container, containers map[string } // Convert the ContainerConfig from inspect into our own // cluster.ContainerConfig. + if info.HostConfig != nil { + info.Config.HostConfig = *info.HostConfig + } container.Config = BuildContainerConfig(*info.Config) // FIXME remove "duplicate" lines and move this to cluster/config.go diff --git a/test/integration/rescheduling.bats b/test/integration/rescheduling.bats index 5e3fd8f953..6baebd9b49 100644 --- a/test/integration/rescheduling.bats +++ b/test/integration/rescheduling.bats @@ -171,3 +171,31 @@ function containerRunning() { # c2 should have been rescheduled from node-1 to node-0 retry 5 1 containerRunning "c2" "node-0" } + + +@test "rescheduling with exposed ports" { + start_docker_with_busybox 2 + swarm_manage --engine-refresh-min-interval=1s --engine-refresh-max-interval=1s --engine-failure-retry=1 ${HOSTS[0]},${HOSTS[1]} + + # c1 on node-0 with reschedule=on-node-failure + run docker_swarm run -dit --name c1 -p 80:80 -e constraint:node==~node-0 --label 'com.docker.swarm.reschedule-policies=["on-node-failure"]' busybox sh + [ "$status" -eq 0 ] + + run docker_swarm ps -q + [ "${#lines[@]}" -eq 1 ] + + # Make sure container is running where it should. + containerRunning "c1" "node-0" + + # Stop node-0 + docker_host stop ${DOCKER_CONTAINERS[0]} + + # Wait for Swarm to detect the node failure. + retry 5 1 eval "docker_swarm info | grep -q 'Unhealthy'" + + # Wait for the container to be rescheduled + retry 5 1 containerRunning "c1" "node-1" + + run docker_swarm ps + [[ "${output}" == *"->80/tcp"* ]] +}