Skip to content
This repository has been archived by the owner on May 4, 2021. It is now read-only.

Commit

Permalink
fix the bug of deleting file from disk (#313)
Browse files Browse the repository at this point in the history
* fix the bug of deleting file from disk

* resolve comments

* add integration test
  • Loading branch information
jockeych authored Apr 2, 2020
1 parent 0b31a90 commit b8d2b1b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/snapshot/mem_fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func (fs *MemFS) UpdateFromTarReader(r *tar.Reader, untar bool) error {
return fmt.Errorf("untar one item %s: %s", path, err)
}
}
if err := fs.maybeAddToLayer(l, "", pathutils.AbsPath(hdr.Name), hdr, false); err != nil {
if err := fs.maybeAddToLayer(l, pathutils.AbsPath(hdr.Name), pathutils.AbsPath(hdr.Name), hdr, false); err != nil {
return fmt.Errorf("add hdr from tar to layer: %s", err)
}
}
Expand All @@ -229,7 +229,7 @@ func (fs *MemFS) UpdateFromTarReader(r *tar.Reader, untar bool) error {
return fmt.Errorf("untar one item %s: %s", path, err)
}
}
if err := fs.maybeAddToLayer(l, "", pathutils.AbsPath(hdr.Name), hdr, false); err != nil {
if err := fs.maybeAddToLayer(l, pathutils.AbsPath(hdr.Name), pathutils.AbsPath(hdr.Name), hdr, false); err != nil {
return fmt.Errorf("add hdr from tar to layer: %s", err)
}
}
Expand Down
11 changes: 10 additions & 1 deletion test/python/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import image


def test_build_simple(registry1, registry2, storage_dir):
new_image = utils.new_image_name()
replica_image = utils.new_image_name()
Expand All @@ -22,6 +21,16 @@ def test_build_simple(registry1, registry2, storage_dir):
assert code == 0, err


def test_build_remove(registry1, storage_dir):
new_image = utils.new_image_name()
context_dir = os.path.join(
os.getcwd(), 'testdata/build-context/remove')
utils.makisu_build_image(
new_image, context_dir, storage_dir, registry=registry1.addr)
code, err = utils.docker_run_image(registry1.addr, new_image)
assert code == 0, err


def test_build_symlink(registry1, storage_dir):
new_image = utils.new_image_name()
context_dir = os.path.join(
Expand Down
3 changes: 3 additions & 0 deletions testdata/build-context/remove/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM centos:7
RUN rm -vf /etc/yum.repos.d/*
ENTRYPOINT ["/bin/bash", "-c", "echo $(ls -la /etc/yum.repos.d/)"]

0 comments on commit b8d2b1b

Please sign in to comment.