1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

image/cache: fix isValidParent logic

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
(cherry picked from commit 1cf4b2b8bd)
Signed-off-by: Victor Vieux <victorvieux@gmail.com>
This commit is contained in:
Antonio Murdaca 2017-02-20 17:16:11 +01:00 committed by Victor Vieux
parent ce07fb6b0f
commit 91d33f250b
2 changed files with 22 additions and 1 deletions

View file

@ -215,7 +215,7 @@ func isValidParent(img, parent *image.Image) bool {
if len(parent.History) >= len(img.History) {
return false
}
if len(parent.RootFS.DiffIDs) >= len(img.RootFS.DiffIDs) {
if len(parent.RootFS.DiffIDs) > len(img.RootFS.DiffIDs) {
return false
}

View file

@ -7081,6 +7081,27 @@ func (s *DockerSuite) TestBuildWithFailure(c *check.C) {
c.Assert(stdout, checker.Not(checker.Contains), "Step 2/2 : RUN nobody")
}
func (s *DockerSuite) TestBuildCacheFromEqualDiffIDsLength(c *check.C) {
dockerfile := `
FROM busybox
RUN echo "test"
ENTRYPOINT ["sh"]`
ctx, err := fakeContext(dockerfile, map[string]string{
"Dockerfile": dockerfile,
})
c.Assert(err, checker.IsNil)
defer ctx.Close()
id1, err := buildImageFromContext("build1", ctx, true)
c.Assert(err, checker.IsNil)
// rebuild with cache-from
id2, out, err := buildImageFromContextWithOut("build2", ctx, true, "--cache-from=build1")
c.Assert(err, checker.IsNil)
c.Assert(id1, checker.Equals, id2)
c.Assert(strings.Count(out, "Using cache"), checker.Equals, 2)
}
func (s *DockerSuite) TestBuildCacheFrom(c *check.C) {
testRequires(c, DaemonIsLinux) // All tests that do save are skipped in windows
dockerfile := `