Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speedup --reproducible layer stripping #3347

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

bh-tt
Copy link

@bh-tt bh-tt commented Oct 22, 2024

Fixes #862, may mitigate #1960

The layerTime function returns a layer backed by an in-memory buffer, which means during the stripping of timestamps the entire image is loaded into memory. Additionally, it runs gzip after the layer is created, resulting in even an even larger in-memory blob.

This commit changes this method to use a temporary file instead of an in-memory buffer, and to use gzip compression while writing to this layer file, instead of compressing during read.

Fixes #862, may mitigate #1960

Description

This commit changes the layerTime method to use a temporary file instead of an in-memory buffer, and to use gzip compression while writing to this layer file, instead of compressing during read.

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

  • Includes unit tests
  • Adds integration tests if needed.

Covered by existing unit tests, single method change. Integration tests not necessary.

See the contribution guide for more details.

Reviewer Notes

  • The code flow looks good.
  • Unit tests and or integration tests added.

Release Notes

Describe any changes here so maintainer can include it in the release notes, or delete this block.

- improve --reproducible by not loading the entire image into memory, instead writing it to a temporary file

Fixes GoogleContainerTools#862, may mitigate GoogleContainerTools#1960

The layerTime function returns a layer backed by an in-memory buffer, which means during
the stripping of timestamps the entire image is loaded into memory. Additionally, it runs
gzip after the layer is created, resulting in even an even larger in-memory blob.

This commit changes this method to use a temporary file instead of an in-memory buffer,
and to use gzip compression while writing to this layer file, instead of compressing during read.

Signed-off-by: bh <bert@transtrend.com>
Copy link

google-cla bot commented Oct 22, 2024

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Signed-off-by: bh <bert@transtrend.com>
@bh-tt
Copy link
Author

bh-tt commented Oct 22, 2024

Note: the temporary files created by kaniko are not cleaned up, I'm not sure if this is necessary given that kaniko is designed to run in a container. If it is, is there some kind of lifecycle method that can be called to clean the files, preferably through the v1.Layer struct?

@bh-tt
Copy link
Author

bh-tt commented Oct 22, 2024

I'm a developer working at a company so it may take some time before I can get the CLA signed...

@bh-tt
Copy link
Author

bh-tt commented Oct 23, 2024

Hmm should I submit this here or in go-containerregistry?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using --reproducible loads entire image into memory
1 participant