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

Commit

Permalink
cluster: Fix name setting of pending containers.
Browse files Browse the repository at this point in the history
Signed-off-by: Andrea Luzzardi <[email protected]>
  • Loading branch information
aluzzardi committed Oct 9, 2015
1 parent 2439461 commit 7c0539c
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions cluster/swarm/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,17 @@ type pendingContainer struct {
}

func (p *pendingContainer) ToContainer() *cluster.Container {
return &cluster.Container{
Container: dockerclient.Container{
Names: []string{"/" + p.Name},
},
Config: p.Config,
Engine: p.Engine,
container := &cluster.Container{
Container: dockerclient.Container{},
Config: p.Config,
Engine: p.Engine,
}

if p.Name != "" {
container.Container.Names = []string{"/" + p.Name}
}

return container
}

// Cluster is exported
Expand Down Expand Up @@ -124,7 +128,7 @@ func (c *Cluster) createContainer(config *cluster.ContainerConfig, name string,
// Ensure the name is available
if !c.checkNameUniqueness(name) {
c.scheduler.Unlock()
return nil, fmt.Errorf("Conflict, The name %s is already assigned. You have to delete (or rename) that container to be able to assign %s to a container again.", name, name)
return nil, fmt.Errorf("Conflict: The name %s is already assigned. You have to delete (or rename) that container to be able to assign %s to a container again.", name, name)
}

// Associate a Swarm ID to the container we are creating.
Expand Down Expand Up @@ -697,7 +701,7 @@ func (c *Cluster) RenameContainer(container *cluster.Container, newName string)

// check new name whether available
if !c.checkNameUniqueness(newName) {
return fmt.Errorf("Conflict, The name %s is already assigned. You have to delete (or rename) that container to be able to assign %s to a container again.", newName, newName)
return fmt.Errorf("Conflict: The name %s is already assigned. You have to delete (or rename) that container to be able to assign %s to a container again.", newName, newName)
}

// call engine rename
Expand Down

0 comments on commit 7c0539c

Please sign in to comment.