diff options
Diffstat (limited to 'libpod')
-rw-r--r-- | libpod/image/image.go | 7 | ||||
-rw-r--r-- | libpod/lock/shm/shm_lock_test.go | 4 | ||||
-rw-r--r-- | libpod/reset.go | 18 |
3 files changed, 21 insertions, 8 deletions
diff --git a/libpod/image/image.go b/libpod/image/image.go index 6106084d5..dee2ce0ee 100644 --- a/libpod/image/image.go +++ b/libpod/image/image.go @@ -1246,7 +1246,12 @@ func areParentAndChild(parent, child *imgspecv1.Image) bool { // the child and candidate parent should share all of the // candidate parent's diff IDs, which together would have // controlled which layers were used - if len(parent.RootFS.DiffIDs) > len(child.RootFS.DiffIDs) { + + // issue #7444 describes a panic where the length of child.RootFS.DiffIDs + // is checked but child is nil. Adding a simple band-aid approach to prevent + // the problem until the origin of the problem can be worked out in the issue + // itself. + if child == nil || len(parent.RootFS.DiffIDs) > len(child.RootFS.DiffIDs) { return false } childUsesCandidateDiffs := true diff --git a/libpod/lock/shm/shm_lock_test.go b/libpod/lock/shm/shm_lock_test.go index 362821c62..cb83c7c2c 100644 --- a/libpod/lock/shm/shm_lock_test.go +++ b/libpod/lock/shm/shm_lock_test.go @@ -27,6 +27,8 @@ const lockPath = "/libpod_test" // We need a test main to ensure that the SHM is created before the tests run func TestMain(m *testing.M) { + // Remove prior /dev/shm/libpod_test + os.RemoveAll("/dev/shm" + lockPath) shmLock, err := CreateSHMLock(lockPath, numLocks) if err != nil { fmt.Fprintf(os.Stderr, "Error creating SHM for tests: %v\n", err) @@ -73,6 +75,8 @@ func runLockTest(t *testing.T, testFunc func(*testing.T, *SHMLocks)) { // Test that creating an SHM with a bad size rounds up to a good size func TestCreateNewSHMBadSizeRoundsUp(t *testing.T) { + // Remove prior /dev/shm/test1 + os.RemoveAll("/dev/shm/test1") // Odd number, not a power of 2, should never be a word size on a system lock, err := CreateSHMLock("/test1", 7) assert.NoError(t, err) diff --git a/libpod/reset.go b/libpod/reset.go index cae4d3a04..f8828fed4 100644 --- a/libpod/reset.go +++ b/libpod/reset.go @@ -2,12 +2,14 @@ package libpod import ( "context" + "fmt" "os" "path/filepath" "github.com/containers/podman/v2/libpod/define" "github.com/containers/podman/v2/pkg/rootless" "github.com/containers/podman/v2/pkg/util" + "github.com/containers/storage" "github.com/pkg/errors" "github.com/sirupsen/logrus" ) @@ -103,14 +105,16 @@ func (r *Runtime) Reset(ctx context.Context) error { prevError = err } - if rootless.IsRootless() { - configPath := filepath.Join(os.Getenv("HOME"), ".config/containers") - if err := os.RemoveAll(configPath); err != nil { - if prevError != nil { - logrus.Error(prevError) - } - prevError = err + if storageConfPath, err := storage.DefaultConfigFile(rootless.IsRootless()); err == nil { + if _, err = os.Stat(storageConfPath); err == nil { + fmt.Printf("A storage.conf file exists at %s\n", storageConfPath) + fmt.Println("You should remove this file if you did not modified the configuration.") } + } else { + if prevError != nil { + logrus.Error(prevError) + } + prevError = err } return prevError |