mirror of https://github.com/docker/docs.git
Migrate AUFS containers to devmapper
Conflicts: hack/make.sh runtime.go
This commit is contained in:
parent
b440ec0136
commit
a263e07678
|
@ -44,7 +44,7 @@ if [ -n "$(git status --porcelain)" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Use these flags when compiling the tests and final binary
|
# Use these flags when compiling the tests and final binary
|
||||||
LDFLAGS='-X main.GITCOMMIT "'$GITCOMMIT'" -X main.VERSION "'$VERSION'" -w -linkmode external -extldflags "-static -Wl,--unresolved-symbols=ignore-in-shared-libs"'
|
LDFLAGS='-X main.GITCOMMIT "'$GITCOMMIT'" -X main.VERSION "'$VERSION'" -w -linkmode external -extldflags "-lpthread -static -Wl,--unresolved-symbols=ignore-all"'
|
||||||
BUILDFLAGS='-tags netgo'
|
BUILDFLAGS='-tags netgo'
|
||||||
|
|
||||||
bundle() {
|
bundle() {
|
||||||
|
|
68
runtime.go
68
runtime.go
|
@ -134,7 +134,7 @@ func (runtime *Runtime) containerRoot(id string) string {
|
||||||
// Load reads the contents of a container from disk and registers
|
// Load reads the contents of a container from disk and registers
|
||||||
// it with Register.
|
// it with Register.
|
||||||
// This is typically done at startup.
|
// This is typically done at startup.
|
||||||
func (runtime *Runtime) Load(id string) (*Container, error) {
|
func (runtime *Runtime) load(id string) (*Container, error) {
|
||||||
container := &Container{root: runtime.containerRoot(id)}
|
container := &Container{root: runtime.containerRoot(id)}
|
||||||
if err := container.FromDisk(); err != nil {
|
if err := container.FromDisk(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -145,9 +145,6 @@ func (runtime *Runtime) Load(id string) (*Container, error) {
|
||||||
if container.State.Running {
|
if container.State.Running {
|
||||||
container.State.Ghost = true
|
container.State.Ghost = true
|
||||||
}
|
}
|
||||||
if err := runtime.Register(container); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return container, nil
|
return container, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -289,9 +286,11 @@ func (runtime *Runtime) restore() error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
containers := []*Container{}
|
||||||
for i, v := range dir {
|
for i, v := range dir {
|
||||||
id := v.Name()
|
id := v.Name()
|
||||||
container, err := runtime.Load(id)
|
container, err := runtime.load(id)
|
||||||
if i%21 == 0 && os.Getenv("DEBUG") == "" && os.Getenv("TEST") == "" {
|
if i%21 == 0 && os.Getenv("DEBUG") == "" && os.Getenv("TEST") == "" {
|
||||||
fmt.Printf("\b%c", wheel[i%4])
|
fmt.Printf("\b%c", wheel[i%4])
|
||||||
}
|
}
|
||||||
|
@ -300,7 +299,66 @@ func (runtime *Runtime) restore() error {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
utils.Debugf("Loaded container %v", container.ID)
|
utils.Debugf("Loaded container %v", container.ID)
|
||||||
|
containers = append(containers, container)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deviceSet := runtime.deviceSet
|
||||||
|
for _, container := range containers {
|
||||||
|
|
||||||
|
// Perform a migration for aufs containers
|
||||||
|
if !deviceSet.HasDevice(container.ID) {
|
||||||
|
contents, err := ioutil.ReadDir(container.rwPath())
|
||||||
|
if err != nil {
|
||||||
|
if !os.IsNotExist(err) {
|
||||||
|
utils.Debugf("[migration] Error reading rw dir %s", err)
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(contents) > 0 {
|
||||||
|
utils.Debugf("[migration] Begin migration of %s", container.ID)
|
||||||
|
|
||||||
|
image, err := runtime.graph.Get(container.Image)
|
||||||
|
if err != nil {
|
||||||
|
utils.Debugf("[migratoin] Failed to get image %s", err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
unmount := func() {
|
||||||
|
if err := image.Unmount(runtime, container.RootfsPath(), container.ID); err != nil {
|
||||||
|
utils.Debugf("[migraton] Failed to unmount image %s", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := image.Mount(runtime, container.RootfsPath(), container.rwPath(), container.ID); err != nil {
|
||||||
|
utils.Debugf("[migratoin] Failed to mount image %s", err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := image.applyLayer(container.rwPath(), container.RootfsPath()); err != nil {
|
||||||
|
utils.Debugf("[migration] Failed to apply layer %s", err)
|
||||||
|
unmount()
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
unmount()
|
||||||
|
|
||||||
|
if err := os.RemoveAll(container.rwPath()); err != nil {
|
||||||
|
utils.Debugf("[migration] Failed to remove rw dir %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
utils.Debugf("[migration] End migration of %s", container.ID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, container := range containers {
|
||||||
|
if err := runtime.Register(container); err != nil {
|
||||||
|
utils.Debugf("Failed to register container %s: %s", container.ID, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if os.Getenv("DEBUG") == "" && os.Getenv("TEST") == "" {
|
if os.Getenv("DEBUG") == "" && os.Getenv("TEST") == "" {
|
||||||
fmt.Printf("\bdone.\n")
|
fmt.Printf("\bdone.\n")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue