Skip to content

Commit

Permalink
clean up after remote build
Browse files Browse the repository at this point in the history
when performing an image build over a varlink connection, we should
clean up tmp files that are a result of sending the file to the host and
untarring it for the build.

Fixes: containers#3869

Signed-off-by: baude <bbaude@redhat.com>
  • Loading branch information
baude authored and weirdwiz committed Sep 5, 2019
1 parent 68a1fbf commit bbc321a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/varlinkapi/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,14 @@ func (i *LibpodAPI) BuildImage(call iopodman.VarlinkCall, config iopodman.BuildI
return call.ReplyErrorOccurred(fmt.Sprintf("unable to untar context dir %s", contextDir))
}
logrus.Debugf("untar of %s successful", contextDir)

defer func() {
if err := os.Remove(contextDir); err != nil {
logrus.Errorf("unable to delete file '%s': %q", contextDir, err)
}
if err := os.RemoveAll(newContextDir); err != nil {
logrus.Errorf("unable to delete directory '%s': %q", newContextDir, err)
}
}()
// All output (stdout, stderr) is captured in output as well
var output bytes.Buffer

Expand Down

0 comments on commit bbc321a

Please sign in to comment.