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

remotecache: allow exporting root cache records #4803

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

tonistiigi
Copy link
Member

Allow exporting layers of root sources, like base images to
remote cache. Normally, this is not done as it is considered
wasteful as pulling cache vs. pulling source image again
does not have benefits.

Skipping base images in cache has other side effects though,
for example provenance of a cached build that is on top of
previous base image does not list the layers for the
LLB image step because that step did not run (because its
children were fully cached) and the image step itself
does not have a layer chain associated with it in the cache.

Local source exports roots by default to allow air-gapped builds
with local cache sources if they only match the base image and
no records on top of them. A future follow-up could be to consider
exporting roots by default all the time but marking them in a
special way so they can be skipped from loading.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Allow exporting layers of root sources, like base images to
remote cache. Normally, this is not done as it is considered
wasteful as pulling cache vs. pulling source image again
does not have benefits.

Skipping base images in cache has other side effects though,
for example provenance of a cached build that is on top of
previous base image does not list the layers for the
LLB image step because that step did not run (because its
children were fully cached) and the image step itself
does not have a layer chain associated with it in the cache.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
@@ -36,6 +36,7 @@ type Exporter interface {

type Config struct {
Compression compression.Config
WithRoots bool
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a godoc comment to explain the "roots"?

Copy link
Member

@jedevc jedevc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Local source exports roots by default to allow air-gapped builds
with local cache sources if they only match the base image and
no records on top of them.

I'm not sure I understand this case - does this happen particularly often?

@@ -75,13 +78,24 @@ func getConfig(attrs map[string]string) (*Config, error) {
return nil, errors.Wrap(err, "failed to parse timeout for github actions cache")
}
}

rootfs := false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
rootfs := false
roots := false

@tonistiigi
Copy link
Member Author

tonistiigi commented Apr 3, 2024

I'm not sure I understand this case - does this happen particularly often?

Not sure I understand. Are you asking if --cache-from=type=local is used often without internet access?

@thompson-shaun thompson-shaun marked this pull request as draft May 9, 2024 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants