Coder Social home page Coder Social logo

Comments (5)

 avatar commented on May 28, 2024 1

I've just run into this myself - was using img.Cleanup per the basic example, only to find ~32gb of tmp files from stereoscope😅

Switching to stereoscope.Cleanup() looks like it's resolved the problem - it would be good to know the backstory on the comment @slimdevl you've indicated, since it does seem like that should be called instead (or maybe in addition to?) img.Cleanup.

I did a little digging this weekend and discovered the following:

  1. One cannot call stereoscope.Cleanup if the process uses the library for subsequent scan calls. This is because rootTempDirGenerator is the foundation of all allocated temp dirs, and the base directory attached to it is gone after first cleanup. This cascades into subsequent scan failures. So calling stereoscope.Cleanup is not a good option for long running processes.
  2. selectImageProvider() allocates a child tempDirGenerator. It passes that to the Provider (in my case DaemonProvider), which in turn passes only the directory to the image.NewImage() call. This passes the responsibility to the Image.Cleanup() method to cleanup directories. However this cannot work because *only the passed directory is cleaned up by the image, and the DaemonProvider directory is leaked at this point.

This feels like an incomplete chain of responsibility. Because the DaemonProvider allocates a separate directory for the image.tar, which must exist until after the client.go calls image.Read(). This is partially because of the way v1.Image lazy load feature behaves. Thus the relationships are broken during the Provide sequence.

IMHO - A better solution is to complete the chain of responsibility but having selectImageProvider() allocated a rootTempDirGenerator and pass it to the provider; which in turn passes the tempDirGenerator to the image.NewImage(), this completes the chain of responsibility.

If providers make a new generators, or directories, they are all passed to the image for cleanup after the image is no longer needed.

from stereoscope.

ltsonov-cb avatar ltsonov-cb commented on May 28, 2024

+1 on this - we noticed abnormal disk usage when utilizing syft and narrowed down the issue to this root cause as well.
The code to work around it is a bit clunky as users of our wrapper APIs expect that image.Cleanup() is enough - but that leaves .tar files hanging around.

from stereoscope.

 avatar commented on May 28, 2024

I think this is an interesting problem. There are a few options here:

Personally I am a fan of option 1... but would like a recommendations from the team - I am happy to open a PR with a little guidance ☺️

from stereoscope.

 avatar commented on May 28, 2024

I think this is an interesting problem. There are a few options here:

Personally I am a fan of option 1... but would like a recommendations from the team - I am happy to open a PR with a little guidance ☺️

nm... I think I was wrong.

Based on a further research - only thing really needed is to call client.go Cleanup(). which releases the root generator and all children generators....effectively cleaning up the directories.

The comment above cleanup is misleading and what leads to the leak of files I believe.

from stereoscope.

G-Rath avatar G-Rath commented on May 28, 2024

I've just run into this myself - was using img.Cleanup per the basic example, only to find ~32gb of tmp files from stereoscope😅

Switching to stereoscope.Cleanup() looks like it's resolved the problem - it would be good to know the backstory on the comment @slimdevl you've indicated, since it does seem like that should be called instead of (or maybe in addition to?) img.Cleanup.

from stereoscope.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.