summaryrefslogtreecommitdiff
path: root/daemon/rename.go
diff options
context:
space:
mode:
authorAaron Lehmann <aaron.lehmann@docker.com>2017-06-29 18:56:22 -0700
committerAaron Lehmann <aaron.lehmann@docker.com>2017-07-13 12:35:00 -0700
commit1128fc1add66a849c12d2045aed39605e673abc6 (patch)
tree9519eb438e9ed686021f74a7a646732637542ca8 /daemon/rename.go
parent53a75ee05072cf5e59e9fb5b9e5cc5fb91fdb5be (diff)
downloaddocker-1128fc1add66a849c12d2045aed39605e673abc6.tar.gz
Store container names in memdb
Currently, names are maintained by a separate system called "registrar". This means there is no way to atomically snapshot the state of containers and the names associated with them. We can add this atomicity and simplify the code by storing name associations in the memdb. This removes the need for pkg/registrar, and makes snapshots a lot less expensive because they no longer need to copy all the names. This change also avoids some problematic behavior from pkg/registrar where it returns slices which may be modified later on. Note that while this change makes the *snapshotting* atomic, it doesn't yet do anything to make sure containers are named at the same time that they are added to the database. We can do that by adding a transactional interface, either as a followup, or as part of this PR. Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
Diffstat (limited to 'daemon/rename.go')
-rw-r--r--daemon/rename.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/daemon/rename.go b/daemon/rename.go
index 2a8d0b22c7..686fbd3b99 100644
--- a/daemon/rename.go
+++ b/daemon/rename.go
@@ -55,7 +55,7 @@ func (daemon *Daemon) ContainerRename(oldName, newName string) error {
}
for k, v := range links {
- daemon.nameIndex.Reserve(newName+k, v.ID)
+ daemon.containersReplica.ReserveName(newName+k, v.ID)
daemon.linkIndex.link(container, v, newName+k)
}
@@ -68,10 +68,10 @@ func (daemon *Daemon) ContainerRename(oldName, newName string) error {
container.NetworkSettings.IsAnonymousEndpoint = oldIsAnonymousEndpoint
daemon.reserveName(container.ID, oldName)
for k, v := range links {
- daemon.nameIndex.Reserve(oldName+k, v.ID)
+ daemon.containersReplica.ReserveName(oldName+k, v.ID)
daemon.linkIndex.link(container, v, oldName+k)
daemon.linkIndex.unlink(newName+k, v, container)
- daemon.nameIndex.Release(newName + k)
+ daemon.containersReplica.ReleaseName(newName + k)
}
daemon.releaseName(newName)
}
@@ -79,7 +79,7 @@ func (daemon *Daemon) ContainerRename(oldName, newName string) error {
for k, v := range links {
daemon.linkIndex.unlink(oldName+k, v, container)
- daemon.nameIndex.Release(oldName + k)
+ daemon.containersReplica.ReleaseName(oldName + k)
}
daemon.releaseName(oldName)
if err = container.CheckpointTo(daemon.containersReplica); err != nil {