Signed-off-by: Veres Lajos <vlajos@gmail.com>
This commit is contained in:
Veres Lajos 2015-08-07 22:55:33 +01:00
parent bf4bb808e7
commit 0d94d7a11a
11 changed files with 16 additions and 16 deletions

View File

@ -78,12 +78,12 @@ func BuildContainerConfig(c dockerclient.ContainerConfig) *ContainerConfig {
json.Unmarshal([]byte(labels), &affinities)
}
// parse contraints from labels (ex. docker run --label 'com.docker.swarm.constraints=["region==us-east","storage==ssd"]')
// parse constraints from labels (ex. docker run --label 'com.docker.swarm.constraints=["region==us-east","storage==ssd"]')
if labels, ok := c.Labels[SwarmLabelNamespace+".constraints"]; ok {
json.Unmarshal([]byte(labels), &constraints)
}
// parse affinities/contraints from env (ex. docker run -e affinity:container==redis -e affinity:image==nginx -e constraint:region==us-east -e constraint:storage==ssd)
// parse affinities/constraints from env (ex. docker run -e affinity:container==redis -e affinity:image==nginx -e constraint:region==us-east -e constraint:storage==ssd)
for _, e := range c.Env {
if ok, key, value := parseEnv(e); ok && key == "affinity" {
affinities = append(affinities, value)
@ -94,7 +94,7 @@ func BuildContainerConfig(c dockerclient.ContainerConfig) *ContainerConfig {
}
}
// remove affinities/contraints from env
// remove affinities/constraints from env
c.Env = env
// store affinities in labels
@ -104,7 +104,7 @@ func BuildContainerConfig(c dockerclient.ContainerConfig) *ContainerConfig {
}
}
// store contraints in labels
// store constraints in labels
if len(constraints) > 0 {
if labels, err := json.Marshal(constraints); err == nil {
c.Labels[SwarmLabelNamespace+".constraints"] = string(labels)

View File

@ -106,7 +106,7 @@ func (c *Cluster) createContainer(config *cluster.ContainerConfig, name string,
c.scheduler.Lock()
defer c.scheduler.Unlock()
// Ensure the name is avaliable
// Ensure the name is available
if cID := c.getIDFromName(name); cID != "" {
return nil, fmt.Errorf("Conflict, The name %s is already assigned to %s. You have to delete (or rename) that container to be able to assign %s to a container again.", name, cID, name)
}
@ -579,7 +579,7 @@ func (c *Cluster) RenameContainer(container *cluster.Container, newName string)
c.RLock()
defer c.RUnlock()
// check new name whether avaliable
// check new name whether available
if cID := c.getIDFromName(newName); cID != "" {
return fmt.Errorf("Conflict, The name %s is already assigned to %s. You have to delete (or rename) that container to be able to assign %s to a container again.", newName, cID, newName)
}

View File

@ -65,7 +65,7 @@ func TestConstrainteFilter(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, result, nodes)
// Set a constraint that cannot be fullfilled and expect an error back.
// Set a constraint that cannot be fulfilled and expect an error back.
result, err = f.Filter(cluster.BuildContainerConfig(dockerclient.ContainerConfig{Env: []string{"constraint:does_not_exist==true"}}), nodes)
assert.Error(t, err)
@ -75,7 +75,7 @@ func TestConstrainteFilter(t *testing.T) {
assert.Len(t, result, 1)
assert.Equal(t, result[0], nodes[1])
// This constraint can only be fullfilled by a subset of nodes.
// This constraint can only be fulfilled by a subset of nodes.
result, err = f.Filter(cluster.BuildContainerConfig(dockerclient.ContainerConfig{Env: []string{"constraint:group==1"}}), nodes)
assert.NoError(t, err)
assert.Len(t, result, 2)

View File

@ -101,7 +101,7 @@ func (p *PortFilter) compare(requested dockerclient.PortBinding, bindings map[st
for _, b := range binding {
if b.HostPort == "" {
// Skip undefined HostPorts. This happens in bindings that
// didn't explicitely specify an external port.
// didn't explicitly specify an external port.
continue
}

View File

@ -35,7 +35,7 @@ skip
# test attach-ws api
# jimmyxian/centos7-wssh is an image with websocket CLI(WSSH) wirtten in Python
# if connected successfull, it returns two lines, "Session Open" and "Session Closed"
# if connected successful, it returns two lines, "Session Open" and "Session Closed"
# Note: with stdout=1&stdin=1&stream=1: it can be used as SSH
URL="ws://${SWARM_HOST}/${CLIENT_API_VERSION}/containers/test_container/attach/ws?stderr=1"
run docker_host run --rm --net=host jimmyxian/centos7-wssh wssh $URL

View File

@ -18,7 +18,7 @@ function teardown() {
[ "${#lines[@]}" -eq 2 ]
[[ "${lines[1]}" == *"test_container"* ]]
# no comming name before commit
# no coming name before commit
run docker_swarm images
[ "$status" -eq 0 ]
[[ "${output}" != *"commit_image_busybox"* ]]

View File

@ -12,7 +12,7 @@ function teardown() {
swarm_manage
docker_swarm create --name test_container busybox sleep 100
# if container is not runing, exec will failed
# if container is not running, exec will failed
run docker_swarm exec test_container ls
[ "$status" -ne 0 ]
[[ "$output" == *"is not running"* ]]

View File

@ -51,7 +51,7 @@ function teardown() {
# Running
firstID=$(docker_swarm run -d --name name1 --label "match=me" --label "second=tag" busybox sleep 10000)
# Exited - successfull
# Exited - successful
secondID=$(docker_swarm run -d --name name2 --label "match=me too" busybox true)
docker_swarm wait "$secondID"
# Exited - error

View File

@ -27,7 +27,7 @@ function teardown() {
[ "$status" -ne 0 ]
[[ "${output}" == *"Conflict,"* ]]
# rename container, sucessful
# rename container, successful
docker_swarm rename test_container rename_container
# verify after, rename

View File

@ -15,7 +15,7 @@ function teardown() {
swarm_manage
# make sure the image of busybox exists
# the comming image of tag_busybox not exsit
# the coming image of tag_busybox not exsit
run docker_swarm images
[ "$status" -eq 0 ]
[ "${#lines[@]}" -ge 2 ]

View File

@ -20,7 +20,7 @@ function teardown() {
[ "${#lines[@]}" -eq 2 ]
[[ "${lines[1]}" == *"test_container"* ]]
# no comming name before commit
# no coming name before commit
run docker_swarm images
[ "$status" -eq 0 ]
[[ "${output}" != *"commit_image_busybox"* ]]