mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
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>
This commit is contained in:
parent
4f57b94f0c
commit
847564fa49
1 changed files with 2 additions and 1 deletions
|
@ -104,7 +104,8 @@ func MakeTarSumContext(tarStream io.Reader) (ModifiableContext, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := chrootarchive.Untar(sum, root, nil); err != nil {
|
err = chrootarchive.Untar(sum, root, nil)
|
||||||
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue