Skip to content
This repository was archived by the owner on Feb 1, 2021. It is now read-only.

Commit 8debc53

Browse files
committed
Merge pull request #1833 from vieux/test_p_compose
revert startconfig breaking change
2 parents 39ca8e9 + 358ac57 commit 8debc53

File tree

9 files changed

+26
-52
lines changed

9 files changed

+26
-52
lines changed

api/handlers.go

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -740,34 +740,14 @@ func getEvents(c *context, w http.ResponseWriter, r *http.Request) {
740740

741741
// POST /containers/{name:.*}/start
742742
func postContainersStart(c *context, w http.ResponseWriter, r *http.Request) {
743-
hostConfig := &dockerclient.HostConfig{
744-
MemorySwappiness: -1,
745-
}
746-
747-
buf, err := ioutil.ReadAll(r.Body)
748-
if err != nil {
749-
httpError(w, err.Error(), http.StatusBadRequest)
750-
return
751-
}
752-
r.Body.Close()
753-
754-
if len(buf) == 0 {
755-
hostConfig = nil
756-
} else {
757-
if err := json.Unmarshal(buf, hostConfig); err != nil {
758-
httpError(w, err.Error(), http.StatusBadRequest)
759-
return
760-
}
761-
}
762-
763743
name := mux.Vars(r)["name"]
764744
container := c.cluster.Container(name)
765745
if container == nil {
766746
httpError(w, fmt.Sprintf("No such container %s", name), http.StatusNotFound)
767747
return
768748
}
769749

770-
if err := c.cluster.StartContainer(container, hostConfig); err != nil {
750+
if err := c.cluster.StartContainer(container); err != nil {
771751
httpError(w, err.Error(), http.StatusInternalServerError)
772752
return
773753
}

cluster/cluster.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type Cluster interface {
2727
Containers() Containers
2828

2929
// Start a container
30-
StartContainer(container *Container, hostConfig *dockerclient.HostConfig) error
30+
StartContainer(container *Container) error
3131

3232
// Return container the matching `IDOrName`
3333
// TODO: remove this method from the interface as we can use

cluster/engine.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,8 +1038,8 @@ func (e *Engine) cleanupContainers() {
10381038
}
10391039

10401040
// StartContainer starts a container
1041-
func (e *Engine) StartContainer(id string, hostConfig *dockerclient.HostConfig) error {
1042-
err := e.client.StartContainer(id, hostConfig)
1041+
func (e *Engine) StartContainer(id string) error {
1042+
err := e.client.StartContainer(id, nil)
10431043
e.CheckConnectionErr(err)
10441044
if err != nil {
10451045
return err

cluster/mesos/cluster.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,10 @@ func (c *Cluster) UnregisterEventHandler(h cluster.EventHandler) {
179179
}
180180

181181
// StartContainer starts a container
182-
func (c *Cluster) StartContainer(container *cluster.Container, hostConfig *dockerclient.HostConfig) error {
182+
func (c *Cluster) StartContainer(container *cluster.Container) error {
183183
// if the container was started less than a second ago in detach mode, do not start it
184184
if time.Now().Unix()-container.Created > 1 || container.Config.Labels[cluster.SwarmLabelNamespace+".mesos.detach"] != "true" {
185-
return container.Engine.StartContainer(container.Id, hostConfig)
185+
return container.Engine.StartContainer(container.Id)
186186
}
187187
return nil
188188
}

cluster/swarm/cluster.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ func (c *Cluster) generateUniqueID() string {
125125
}
126126

127127
// StartContainer starts a container
128-
func (c *Cluster) StartContainer(container *cluster.Container, hostConfig *dockerclient.HostConfig) error {
129-
return container.Engine.StartContainer(container.Id, hostConfig)
128+
func (c *Cluster) StartContainer(container *cluster.Container) error {
129+
return container.Engine.StartContainer(container.Id)
130130
}
131131

132132
// CreateContainer aka schedule a brand new container into the cluster.

cluster/watchdog.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func (w *Watchdog) rescheduleContainers(e *Engine) {
8383
log.Infof("Rescheduled container %s from %s to %s as %s", c.Id, c.Engine.Name, newContainer.Engine.Name, newContainer.Id)
8484
if c.Info.State.Running {
8585
log.Infof("Container %s was running, starting container %s", c.Id, newContainer.Id)
86-
if err := w.cluster.StartContainer(newContainer, nil); err != nil {
86+
if err := w.cluster.StartContainer(newContainer); err != nil {
8787
log.Errorf("Failed to start rescheduled container %s", newContainer.Id)
8888
}
8989
}

test/integration/api/start.bats

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,3 @@ function teardown() {
2525
# Verify
2626
[ -n $(docker_swarm ps -q --filter=name=test_container --filter=status=running) ]
2727
}
28-
29-
@test "docker start with hostConfig" {
30-
start_docker_with_busybox 2
31-
swarm_manage
32-
# create
33-
docker_swarm create --name test_container busybox sleep 1000
34-
35-
# make sure created container exists
36-
# new created container has no status
37-
run docker_swarm ps -l
38-
[ "${#lines[@]}" -eq 2 ]
39-
[[ "${lines[1]}" == *"test_container"* ]]
40-
41-
# start
42-
curl -s -H "Content-Type: application/json" -X POST -d '{"PublishAllPorts": true}' ${SWARM_HOSTS[0]}/v1.23/containers/test_container/start
43-
44-
# Verify
45-
[ -n $(docker_swarm ps -q --filter=name=test_container --filter=status=running) ]
46-
47-
# Inspect HostConfig of container, should have PublishAllPorts set to true
48-
run docker_swarm inspect test_container
49-
[[ "${output}" == *'"PublishAllPorts": true'* ]]
50-
}

test/integration/compose/up.bats

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,18 @@ function teardown() {
3232
# check memory-swappiness
3333
[[ "${output}" == *"\"MemorySwappiness\": -1"* ]]
3434
}
35+
36+
@test "docker-compose up - check port" {
37+
start_docker_with_busybox 2
38+
swarm_manage
39+
FILE=$TESTDATA/compose/simple.yml
40+
41+
docker-compose_swarm -f $FILE up -d
42+
43+
run docker_swarm ps -q
44+
[ "${#lines[@]}" -eq 2 ]
45+
46+
run docker_swarm ps
47+
# check memory-swappiness
48+
[[ "${output}" == *"->80/tcp"* ]]
49+
}

test/integration/testdata/compose/simple.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
service1:
22
image: busybox
3+
ports:
4+
- "80"
35
command: sleep 100
46

57
service2:

0 commit comments

Comments
 (0)