1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/builder
Yong Tang 847564fa49 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>
2016-12-16 21:11:53 -08:00
..
dockerfile Fix processing of unset build-args during build 2016-12-07 07:41:55 -08:00
dockerignore add defer file.Close to avoid potential fd leak 2016-08-10 08:36:09 +08:00
builder.go fix some wrong vars or funcs in builder.go 2016-12-12 17:11:41 +08:00
context.go Fix directory walker error checking 2016-05-26 14:59:38 -07:00
context_test.go Builder unit tests refactoring 2016-05-03 19:00:35 +02:00
context_unix.go Move validateContextDirectory to builder package. 2016-02-09 22:19:09 +01:00
context_windows.go Move validateContextDirectory to builder package. 2016-02-09 22:19:09 +01:00
dockerignore.go add defer file.Close to avoid potential fd leak 2016-08-10 08:36:09 +08:00
dockerignore_test.go Builder unit tests refactoring 2016-05-03 19:00:35 +02:00
git.go utils: move git functions to pkg/gitutils 2015-12-14 14:59:52 +01:00
remote.go pkg/archive: remove unnecessary Archive and Reader type 2016-10-20 19:31:24 -07:00
remote_test.go pkg/archive: remove unnecessary Archive and Reader type 2016-10-20 19:31:24 -07:00
tarsum.go Clean up tmp files for interrupted docker build 2016-12-16 21:11:53 -08:00
tarsum_test.go fix using wrong function name for MakeTarSumContext 2016-11-08 17:16:13 +08:00
utils_test.go Builder unit tests refactoring 2016-05-03 19:00:35 +02:00