Internal cleanup: use the mounted container filesystem instead of manipulating the aufs layers directly
This commit is contained in:
parent
4d90e91243
commit
77ae9789d3
2 changed files with 10 additions and 13 deletions
12
api_test.go
12
api_test.go
|
@ -676,7 +676,7 @@ func TestPostContainersCreate(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if _, err := os.Stat(path.Join(container.rwPath(), "test")); err != nil {
|
||||
if _, err := os.Stat(path.Join(container.RootfsPath(), "test")); err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
utils.Debugf("Err: %s", err)
|
||||
t.Fatalf("The test file has not been created")
|
||||
|
@ -1145,7 +1145,7 @@ func TestDeleteContainers(t *testing.T) {
|
|||
t.Fatalf("The container as not been deleted")
|
||||
}
|
||||
|
||||
if _, err := os.Stat(path.Join(container.rwPath(), "test")); err == nil {
|
||||
if _, err := os.Stat(path.Join(container.RootfsPath(), "test")); err == nil {
|
||||
t.Fatalf("The test file has not been deleted")
|
||||
}
|
||||
}
|
||||
|
@ -1276,13 +1276,7 @@ func TestDeleteImages(t *testing.T) {
|
|||
t.Errorf("Expected %d image, %d found", len(initialImages), len(images))
|
||||
}
|
||||
|
||||
/* if c := runtime.Get(container.Id); c != nil {
|
||||
t.Fatalf("The container as not been deleted")
|
||||
}
|
||||
|
||||
if _, err := os.Stat(path.Join(container.rwPath(), "test")); err == nil {
|
||||
t.Fatalf("The test file has not been deleted")
|
||||
} */
|
||||
// FIXME: check that container has been deleted, and its filesystem too
|
||||
}
|
||||
|
||||
func TestJsonContentType(t *testing.T) {
|
||||
|
|
11
container.go
11
container.go
|
@ -380,12 +380,11 @@ func (settings *NetworkSettings) PortMappingAPI() []APIPort {
|
|||
|
||||
// Inject the io.Reader at the given path. Note: do not close the reader
|
||||
func (container *Container) Inject(file io.Reader, pth string) error {
|
||||
// Make sure the directory exists
|
||||
if err := os.MkdirAll(path.Join(container.rwPath(), path.Dir(pth)), 0755); err != nil {
|
||||
return err
|
||||
if err := container.EnsureMounted(); err != nil {
|
||||
return fmt.Errorf("inject: error mounting container %s: %s", container.ID, err)
|
||||
}
|
||||
// FIXME: Handle permissions/already existing dest
|
||||
dest, err := os.Create(path.Join(container.rwPath(), pth))
|
||||
dest, err := os.Create(path.Join(container.RootfsPath(), pth))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -1463,6 +1462,10 @@ func (container *Container) GetSize() (int64, int64) {
|
|||
return nil
|
||||
})
|
||||
|
||||
if err := container.EnsureMounted(); err != nil {
|
||||
utils.Errorf("Warning: failed to compute size of container rootfs %s: %s", container.ID, err)
|
||||
return sizeRw, sizeRootfs
|
||||
}
|
||||
_, err := os.Stat(container.RootfsPath())
|
||||
if err == nil {
|
||||
filepath.Walk(container.RootfsPath(), func(path string, fileInfo os.FileInfo, err error) error {
|
||||
|
|
Loading…
Reference in a new issue