Switch to ondisk also when unpacking FS

From benchmarks it seems to be still faster. Add a note for a future
improvement
This commit is contained in:
Ettore Di Giacinto 2021-10-26 13:37:39 +02:00
parent aea3cdff8d
commit 35fcd868ee
3 changed files with 7 additions and 2 deletions

View File

@ -156,7 +156,7 @@ RUN echo bar > /test2`))
Expect(err).ToNot(HaveOccurred())
defer os.RemoveAll(result) // clean up
img, err := b.ImageReference(resultingImage, false)
img, err := b.ImageReference(resultingImage, true)
Expect(err).ToNot(HaveOccurred())
_, _, err = image.ExtractTo(
ctx,

View File

@ -140,6 +140,11 @@ func (s *SimpleDocker) Push(opts Options) error {
}
func (s *SimpleDocker) ImageReference(a string, ondisk bool) (v1.Image, error) {
// TODO: We could also handle this from docker's pipe, but needs benchmarking:
// daemon.Image takes a client optionally. Otherwise we can return a new image
// from a tarball by providing ourselves a reader from docker stdout pipe.
// See daemon.Image implementation below for an example (which returns the tarball stream
// from the HTTP api endpoint instead ).
if ondisk {
f, err := s.ctx.Config.GetSystem().TempFile("snapshot")
if err != nil {

View File

@ -234,7 +234,7 @@ func (cs *LuetCompiler) unpackFs(concurrency int, keepPermissions bool, p *compi
}
}
img, err := cs.Backend.ImageReference(runnerOpts.ImageName, false)
img, err := cs.Backend.ImageReference(runnerOpts.ImageName, true)
if err != nil {
return nil, err
}