Merge pull request #45736 from thaJeztah/reserve_once
daemon: registerName(): don't reserve name twice
This commit is contained in:
commit
ab60412cb4
1 changed files with 4 additions and 3 deletions
|
@ -26,11 +26,12 @@ func (daemon *Daemon) registerName(container *container.Container) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if container.Name == "" {
|
if container.Name == "" {
|
||||||
name, err := daemon.generateNewName(container.ID)
|
name, err := daemon.generateAndReserveName(container.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
container.Name = name
|
container.Name = name
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
return daemon.containersReplica.ReserveName(container.Name, container.ID)
|
return daemon.containersReplica.ReserveName(container.Name, container.ID)
|
||||||
}
|
}
|
||||||
|
@ -42,7 +43,7 @@ func (daemon *Daemon) generateIDAndName(name string) (string, string, error) {
|
||||||
)
|
)
|
||||||
|
|
||||||
if name == "" {
|
if name == "" {
|
||||||
if name, err = daemon.generateNewName(id); err != nil {
|
if name, err = daemon.generateAndReserveName(id); err != nil {
|
||||||
return "", "", err
|
return "", "", err
|
||||||
}
|
}
|
||||||
return id, name, nil
|
return id, name, nil
|
||||||
|
@ -81,7 +82,7 @@ func (daemon *Daemon) releaseName(name string) {
|
||||||
daemon.containersReplica.ReleaseName(name)
|
daemon.containersReplica.ReleaseName(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (daemon *Daemon) generateNewName(id string) (string, error) {
|
func (daemon *Daemon) generateAndReserveName(id string) (string, error) {
|
||||||
var name string
|
var name string
|
||||||
for i := 0; i < 6; i++ {
|
for i := 0; i < 6; i++ {
|
||||||
name = namesgenerator.GetRandomName(i)
|
name = namesgenerator.GetRandomName(i)
|
||||||
|
|
Loading…
Reference in a new issue