Merge pull request #1192 from vieux/revert_mesos_logs

Revert "prevent double starts with mesos"
This commit is contained in:
Chanwit Kaewkasi 2015-09-04 02:12:27 +07:00
commit 15cc8a31d8
8 changed files with 4 additions and 89 deletions

View File

@ -717,25 +717,8 @@ func postBuild(c *context, w http.ResponseWriter, r *http.Request) {
}
}
// POST /containers/{name:.*}/start
func postContainersStart(c *context, w http.ResponseWriter, r *http.Request) {
_, container, err := getContainerFromVars(c, mux.Vars(r))
if err != nil {
httpError(w, err.Error(), http.StatusNotFound)
return
}
if err = c.cluster.StartContainer(container); err != nil {
if strings.HasPrefix(err.Error(), "Conflict") {
httpError(w, err.Error(), http.StatusConflict)
} else {
httpError(w, err.Error(), http.StatusInternalServerError)
}
}
}
// POST /containers/{name:.*}/rename
func postContainersRename(c *context, w http.ResponseWriter, r *http.Request) {
func postRenameContainer(c *context, w http.ResponseWriter, r *http.Request) {
_, container, err := getContainerFromVars(c, mux.Vars(r))
if err != nil {
httpError(w, err.Error(), http.StatusNotFound)

View File

@ -60,9 +60,9 @@ var routes = map[string]map[string]handler{
"/containers/{name:.*}/kill": proxyContainerAndForceRefresh,
"/containers/{name:.*}/pause": proxyContainerAndForceRefresh,
"/containers/{name:.*}/unpause": proxyContainerAndForceRefresh,
"/containers/{name:.*}/rename": postContainersRename,
"/containers/{name:.*}/rename": postRenameContainer,
"/containers/{name:.*}/restart": proxyContainerAndForceRefresh,
"/containers/{name:.*}/start": postContainersStart,
"/containers/{name:.*}/start": proxyContainerAndForceRefresh,
"/containers/{name:.*}/stop": proxyContainerAndForceRefresh,
"/containers/{name:.*}/wait": proxyContainerAndForceRefresh,
"/containers/{name:.*}/resize": proxyContainer,

View File

@ -31,9 +31,6 @@ type Cluster interface {
// cluster.Containers().Get(IDOrName)
Container(IDOrName string) *Container
// Start a container
StartContainer(container *Container) error
// Pull images
// `callback` can be called multiple time
// `where` is where it is being pulled

View File

@ -433,11 +433,6 @@ func (e *Engine) Create(config *ContainerConfig, name string, pullImage bool) (*
return container, err
}
// StartContainer a container from the engine.
func (e *Engine) StartContainer(container *Container, config *dockerclient.HostConfig) error {
return e.client.StartContainer(container.Id, config)
}
// RemoveContainer a container from the engine.
func (e *Engine) RemoveContainer(container *Container, force bool) error {
if err := e.client.RemoveContainer(container.Id, force, true); err != nil {

View File

@ -284,23 +284,6 @@ func (c *Cluster) Import(source string, repository string, tag string, imageRead
}
// StartContainer start a container
func (c *Cluster) StartContainer(container *cluster.Container) error {
c.RLock()
defer c.RUnlock()
if container, _ := container.Refresh(); container != nil {
// As mesos garbage collect containers, we only allow starting on a "Created" containers
if container.Info.State.Running == false && container.Info.State.FinishedAt.IsZero() {
if err := container.Engine.StartContainer(container, nil); err != nil {
_, err = container.Refresh()
return err
}
}
}
return nil
}
// RenameContainer Rename a container
func (c *Cluster) RenameContainer(container *cluster.Container, newName string) error {
//FIXME this doesn't work as the next refreshcontainer will erase this change (this change is in-memory only)

View File

@ -552,18 +552,6 @@ func (c *Cluster) RANDOMENGINE() (*cluster.Engine, error) {
return nil, nil
}
// StartContainer start a container
func (c *Cluster) StartContainer(container *cluster.Container) error {
c.RLock()
defer c.RUnlock()
if err := container.Engine.StartContainer(container, nil); err != nil {
return err
}
_, err := container.Refresh()
return err
}
// RenameContainer rename a container
func (c *Cluster) RenameContainer(container *cluster.Container, newName string) error {
c.RLock()

View File

@ -19,7 +19,7 @@ function teardown() {
local events_pid="$!"
# This should emit 3 events: create, start, die.
docker_swarm run -d -m 20m --name test_container -e constraint:node==node-0 busybox true
docker_swarm run -m 20m --name test_container -e constraint:node==node-0 busybox true
# events might take a little big to show up, wait until we get the last one.
retry 5 0.5 grep -q "die" "$log_file"

View File

@ -1,31 +0,0 @@
#!/usr/bin/env bats
load ../mesos_helpers
function teardown() {
swarm_manage_cleanup
stop_mesos
stop_docker
}
@test "mesos - docker logs" {
start_docker_with_busybox 2
start_mesos
swarm_manage --cluster-driver mesos-experimental 127.0.0.1:$MESOS_MASTER_PORT
# run a container with echo command
docker_swarm run -d -m 20m --name test_container busybox /bin/sh -c "echo hello world; echo hello docker; echo hello swarm"
# make sure container exists
run docker_swarm ps -l
[ "${#lines[@]}" -eq 2 ]
[[ "${lines[1]}" == *"test_container"* ]]
# verify
run docker_swarm logs test_container
[ "$status" -eq 0 ]
[ "${#lines[@]}" -eq 3 ]
[[ "${lines[0]}" == *"hello world"* ]]
[[ "${lines[1]}" == *"hello docker"* ]]
[[ "${lines[2]}" == *"hello swarm"* ]]
}