From bcbaf5fe3eb10b6558bfb72970c907cc4e52bfe4 Mon Sep 17 00:00:00 2001 From: daisicheng Date: Tue, 1 Nov 2022 20:28:43 +0800 Subject: [PATCH] fix the problem that the /var/lib/isula-build/storage/overlay is still existed when killing daemon --- VERSION-openeuler | 2 +- git-commit | 2 +- isula-build.spec | 8 +- ...that-the-var-lib-isula-build-storage.patch | 86 +++++++++++++++++++ series.conf | 1 + 5 files changed, 96 insertions(+), 3 deletions(-) create mode 100644 patch/0127-Fix-the-problem-that-the-var-lib-isula-build-storage.patch diff --git a/VERSION-openeuler b/VERSION-openeuler index 5b2e3ee..c572154 100644 --- a/VERSION-openeuler +++ b/VERSION-openeuler @@ -1 +1 @@ -0.9.6-12 +0.9.6-13 diff --git a/git-commit b/git-commit index 3f1a08d..50cbfae 100644 --- a/git-commit +++ b/git-commit @@ -1 +1 @@ -716dbdd867b5ee948f741de9958525531b59a31e +de59790370c6bb31408c4317e7dd71d1436fbece diff --git a/isula-build.spec b/isula-build.spec index d9e9cc7..651b201 100644 --- a/isula-build.spec +++ b/isula-build.spec @@ -2,7 +2,7 @@ Name: isula-build Version: 0.9.6 -Release: 12 +Release: 13 Summary: A tool to build container images License: Mulan PSL V2 URL: https://gitee.com/openeuler/isula-build @@ -85,6 +85,12 @@ fi /usr/share/bash-completion/completions/isula-build %changelog +* Tue Nov 01 2022 daisicheng - 0.9.6-13 +- Type:bugfix +- CVE:NA +- SUG:restart +- DESC:fix the problem that the /var/lib/isula-build/storage/overlay is still existed when killing daemon + * Wed Sep 14 2022 xingweizheng - 0.9.6-12 - Type:bugfix - CVE:NA diff --git a/patch/0127-Fix-the-problem-that-the-var-lib-isula-build-storage.patch b/patch/0127-Fix-the-problem-that-the-var-lib-isula-build-storage.patch new file mode 100644 index 0000000..177de5d --- /dev/null +++ b/patch/0127-Fix-the-problem-that-the-var-lib-isula-build-storage.patch @@ -0,0 +1,86 @@ +From 01f6ca6d4be513a17fc454b6c948aa992e2c47d7 Mon Sep 17 00:00:00 2001 +From: daisicheng +Date: Tue, 1 Nov 2022 11:04:22 +0800 +Subject: [PATCH] Fix the problem that the /var/lib/isula-build/storage/overlay + is still existed when killing daemon and an error when executing "isula-build + rm -a" at the first time. + +--- + daemon/remove.go | 43 +++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 43 insertions(+) + +diff --git a/daemon/remove.go b/daemon/remove.go +index e0a9eed..2933dc3 100644 +--- a/daemon/remove.go ++++ b/daemon/remove.go +@@ -15,6 +15,9 @@ package daemon + + import ( + "fmt" ++ "io/ioutil" ++ "os" ++ "path/filepath" + + "github.com/containers/storage" + "github.com/pkg/errors" +@@ -24,6 +27,7 @@ import ( + pb "isula.org/isula-build/api/services" + "isula.org/isula-build/image" + "isula.org/isula-build/store" ++ "isula.org/isula-build/util" + ) + + // Remove to remove store images +@@ -115,6 +119,13 @@ func (b *Backend) Remove(req *pb.RemoveRequest, stream pb.Control_RemoveServer) + if rmFailed { + return errors.New("remove one or more images failed") + } ++ ++ if req.All { ++ if err := resetDataRoot(s.GraphRoot()); err != nil { ++ return errors.Wrap(err, "reset data root failed") ++ } ++ } ++ + return nil + } + +@@ -154,3 +165,35 @@ func getImageIDs(s *store.Store, prune bool) ([]string, error) { + + return imageIDs, nil + } ++ ++func resetDataRoot(dataRoot string) error { ++ emptyOverlayStructure := map[string]string{ ++ "overlay": "l", ++ "overlay-containers": "containers.lock", ++ "overlay-images": "images.lock", ++ } ++ ++ if exist, err := util.IsExist(filepath.Join(dataRoot, "overlay-layers")); err != nil { ++ return err ++ } else if exist { ++ emptyOverlayStructure["overlay-layers"] = "layers.lock" ++ } ++ for upDir, keep := range emptyOverlayStructure { ++ upDirAbs := filepath.Join(dataRoot, upDir) ++ files, err := ioutil.ReadDir(upDirAbs) ++ if err != nil { ++ return nil ++ } ++ ++ for _, file := range files { ++ if file.Name() == keep { ++ continue ++ } ++ if err := os.RemoveAll(filepath.Join(upDirAbs, file.Name())); err != nil { ++ return nil ++ } ++ } ++ } ++ ++ return nil ++} +-- +2.33.0 + diff --git a/series.conf b/series.conf index bed2cd1..3af2a63 100644 --- a/series.conf +++ b/series.conf @@ -35,3 +35,4 @@ patch/0123-modify-the-Makefile-and-README-document.patch patch/0124-add-the-constraints-and-limitations-of-the-doc.patch patch/0125-fix-the-possible-file-leakage-problem-in-util-cipher.patch patch/0126-improve-security-compile-option-of-isula-build-binar.patch +patch/0127-Fix-the-problem-that-the-var-lib-isula-build-storage.patch