Skip to content

examples: Fix OCI tempfile garbage

Dduvall requested to merge main-Ibc2168ca2b8432a013f2be54962d49b9db7e56a4 into main

Close the imagefs.FS at the end of every scenario to ensure its
temporary directory is removed.

Fixed a bug caused by the return of a new imagefs.lazyFS pointer in
lazyFS.WithContext when the underlying FS has not yet been
initialized. Since there is a no real FS pointer in that case, the
initialization of the real underlying filesystem is effectively lost
between calls to WithContext, resulting in orphaned FS objects for
every call to Open and no garbage collection of the temporary files
created by each initialization, not to mention tons of duplicate
initialization and wasted resources.

Fixing the above bug surfaced another bug in imagefs where tar files
could only be read once. This was fixed by creating a new bytes.Reader
upon each call to Open for the given file.

Bug: T365285

Edited by Dduvall

Merge request reports