fix the problem that the /var/lib/isula-build/storage/overlay is still existed when killing daemon
This commit is contained in:
parent
b5fec76b35
commit
bcbaf5fe3e
@ -1 +1 @@
|
||||
0.9.6-12
|
||||
0.9.6-13
|
||||
|
||||
@ -1 +1 @@
|
||||
716dbdd867b5ee948f741de9958525531b59a31e
|
||||
de59790370c6bb31408c4317e7dd71d1436fbece
|
||||
|
||||
@ -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 <daisicheng@huawei.com> - 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 <xingweizheng@huawei.com> - 0.9.6-12
|
||||
- Type:bugfix
|
||||
- CVE:NA
|
||||
|
||||
@ -0,0 +1,86 @@
|
||||
From 01f6ca6d4be513a17fc454b6c948aa992e2c47d7 Mon Sep 17 00:00:00 2001
|
||||
From: daisicheng <daisicheng@huawei.com>
|
||||
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
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user