Skip to content

Commit 6522224

Browse files
yongtangruncom
authored andcommitted
Clean up tmp files for interrupted docker build
This fix tries to fix the issue raised in 29486 where interrupted `docker build` leaves some tmp files in `/var/lib/docker/tmp`. With tmp file name prefixed with `/var/lib/docker/tmp/docker-builderXXXXXX`. The reason for the issue is that in `MakeTarSumContext()`: ``` if err := chrootarchive.Untar(sum, root, nil); err != nil { return nil, err } ``` the `err` is shadowed and caused the clean up function in `defer func()` not being called. This fix fixes the issue. This fix is tested manually, as was specified in 29486: ``` rm -rf /var/lib/docker/tmp mkdir repro && cd repro fallocate -l 300M bigfile cat > Dockerfile <<EOF FROM scratch COPY ./bigfile / EOF docker build . {Cancel} ls -la /var/lib/docker/tmp ``` This fix fixes 29486. Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
1 parent 9bff9de commit 6522224

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

builder/tarsum.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ func MakeTarSumContext(tarStream io.Reader) (ModifiableContext, error) {
104104
return nil, err
105105
}
106106

107-
if err := chrootarchive.Untar(sum, root, nil); err != nil {
107+
err = chrootarchive.Untar(sum, root, nil)
108+
if err != nil {
108109
return nil, err
109110
}
110111

0 commit comments

Comments
 (0)