Merge pull request #1451 from aluzzardi/parallel-affinity-fix

Set labels for pending containers
This commit is contained in:
Victor Vieux 2015-11-25 15:19:58 -08:00
commit 24fc1b6909
3 changed files with 20 additions and 3 deletions

View File

@ -28,8 +28,10 @@ type pendingContainer struct {
func (p *pendingContainer) ToContainer() *cluster.Container {
container := &cluster.Container{
Container: dockerclient.Container{},
Config: p.Config,
Container: dockerclient.Container{
Labels: p.Config.Labels,
},
Config: p.Config,
Info: dockerclient.ContainerInfo{
HostConfig: &dockerclient.HostConfig{},
},

View File

@ -4,7 +4,7 @@
FROM dockerswarm/dind:1.9.0
# Install dependencies.
RUN apt-get update && apt-get install -y --no-install-recommends git file \
RUN apt-get update && apt-get install -y --no-install-recommends git file parallel \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
# Install golang

View File

@ -126,6 +126,21 @@ function teardown() {
[[ "${output}" != *'"Name": "node-1"'* ]]
}
@test "label affinity in parallel" {
start_docker_with_busybox 2
swarm_manage
# Run 3 tests in parallel. One of them must fail.
run parallel docker -H "${SWARM_HOSTS[0]}" run --label test.label=true -e affinity:test.label!=true -d busybox:latest ::: sh sh sh
[ "$status" -ne 0 ]
[[ "${output}" == *'unable to find a node that satisfies test.label!=true'* ]]
# Only 2 containers should have succeeded.
run docker_swarm ps -q
[ "$status" -eq 0 ]
[ "${#lines[@]}" -eq 2 ]
}
@test "soft affinity" {
start_docker_with_busybox 2