summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2018-09-19 09:54:15 -0400
committerAtomic Bot <atomic-devel@projectatomic.io>2018-09-21 09:45:14 +0000
commitfbd1392a46558eb4adb368ba37fdce2b45013c1f (patch)
tree10b7ddb51d19611462421ef22570561f6d4f70c4
parent6191ffb6c563b3739e17c5b953eb68fb47b8a2bc (diff)
downloadpodman-fbd1392a46558eb4adb368ba37fdce2b45013c1f.tar.gz
podman-fbd1392a46558eb4adb368ba37fdce2b45013c1f.tar.bz2
podman-fbd1392a46558eb4adb368ba37fdce2b45013c1f.zip
Don't output inodes created to run a container
There is a group of inodes that get created when running a container if they do not exist. containerMounts = map[string]bool{ "/dev": true, "/etc/hostname": true, "/etc/hosts": true, "/etc/resolv.conf": true, "/proc": true, "/run": true, "/run/.containerenv": true, "/run/secrets": true, "/sys": true, } If the destination inode does not exist, libpod/runc will create the inode. This can cause programs like podman diff to see the image as having changed, when actually it has not. This patch ignores changes in these inodes. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com> Closes: #1508 Approved by: giuseppe
-rw-r--r--contrib/python/podman/test/test_containers.py4
-rw-r--r--libpod/diff.go24
2 files changed, 25 insertions, 3 deletions
diff --git a/contrib/python/podman/test/test_containers.py b/contrib/python/podman/test/test_containers.py
index 70221e33d..3de1e54bc 100644
--- a/contrib/python/podman/test/test_containers.py
+++ b/contrib/python/podman/test/test_containers.py
@@ -111,8 +111,8 @@ class TestContainers(PodmanTestCase):
list(actual.keys())))
# TODO: brittle, depends on knowing history of ctnr
- self.assertGreaterEqual(len(actual['changed']), 2)
- self.assertGreaterEqual(len(actual['added']), 2)
+ self.assertGreaterEqual(len(actual['changed']), 0)
+ self.assertGreaterEqual(len(actual['added']), 0)
self.assertEqual(len(actual['deleted']), 0)
def test_kill(self):
diff --git a/libpod/diff.go b/libpod/diff.go
index e86a186ed..f348e6b81 100644
--- a/libpod/diff.go
+++ b/libpod/diff.go
@@ -6,6 +6,18 @@ import (
"github.com/pkg/errors"
)
+var containerMounts = map[string]bool{
+ "/dev": true,
+ "/etc/hostname": true,
+ "/etc/hosts": true,
+ "/etc/resolv.conf": true,
+ "/proc": true,
+ "/run": true,
+ "/run/.containerenv": true,
+ "/run/secrets": true,
+ "/sys": true,
+}
+
// GetDiff returns the differences between the two images, layers, or containers
func (r *Runtime) GetDiff(from, to string) ([]archive.Change, error) {
toLayer, err := r.getLayerID(to)
@@ -19,7 +31,17 @@ func (r *Runtime) GetDiff(from, to string) ([]archive.Change, error) {
return nil, err
}
}
- return r.store.Changes(fromLayer, toLayer)
+ var rchanges []archive.Change
+ changes, err := r.store.Changes(fromLayer, toLayer)
+ if err == nil {
+ for _, c := range changes {
+ if containerMounts[c.Path] {
+ continue
+ }
+ rchanges = append(rchanges, c)
+ }
+ }
+ return rchanges, err
}
// GetLayerID gets a full layer id given a full or partial id