image/cache: fix isValidParent logic
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
parent
75843d36aa
commit
1cf4b2b8bd
2 changed files with 22 additions and 1 deletions
2
image/cache/cache.go
vendored
2
image/cache/cache.go
vendored
|
@ -187,7 +187,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
|
||||
}
|
||||
|
||||
|
|
|
@ -5421,6 +5421,27 @@ func (s *DockerSuite) TestBuildWithFailure(c *check.C) {
|
|||
c.Assert(result.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 := fakeContext(c, dockerfile, map[string]string{
|
||||
"Dockerfile": dockerfile,
|
||||
})
|
||||
defer ctx.Close()
|
||||
|
||||
buildImageSuccessfully(c, "build1", withExternalBuildContext(ctx))
|
||||
id1 := getIDByName(c, "build1")
|
||||
|
||||
// rebuild with cache-from
|
||||
result := buildImage("build2", withBuildFlags("--cache-from=build1"), withExternalBuildContext(ctx))
|
||||
result.Assert(c, icmd.Success)
|
||||
id2 := getIDByName(c, "build2")
|
||||
c.Assert(id1, checker.Equals, id2)
|
||||
c.Assert(strings.Count(result.Combined(), "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 := `
|
||||
|
|
Loading…
Add table
Reference in a new issue