mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
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>
This commit is contained in:
@@ -12,7 +12,6 @@ import (
|
||||
"github.com/docker/docker/container"
|
||||
_ "github.com/docker/docker/pkg/discovery/memory"
|
||||
"github.com/docker/docker/pkg/idtools"
|
||||
"github.com/docker/docker/pkg/registrar"
|
||||
"github.com/docker/docker/pkg/truncindex"
|
||||
"github.com/docker/docker/volume"
|
||||
volumedrivers "github.com/docker/docker/volume/drivers"
|
||||
@@ -65,10 +64,15 @@ func TestGetContainer(t *testing.T) {
|
||||
index.Add(c4.ID)
|
||||
index.Add(c5.ID)
|
||||
|
||||
containersReplica, err := container.NewViewDB()
|
||||
if err != nil {
|
||||
t.Fatalf("could not create ViewDB: %v", err)
|
||||
}
|
||||
|
||||
daemon := &Daemon{
|
||||
containers: store,
|
||||
idIndex: index,
|
||||
nameIndex: registrar.NewRegistrar(),
|
||||
containers: store,
|
||||
containersReplica: containersReplica,
|
||||
idIndex: index,
|
||||
}
|
||||
|
||||
daemon.reserveName(c1.ID, c1.Name)
|
||||
|
||||
Reference in New Issue
Block a user