moby / moby/buildkit

Cache Manifest: duplicate entries in a manifest ? Is a sha an identifier ?

Open
#4,398 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
10.3k
Forks
1.5k
Avg merge
1d 23h
Merged PRs (30d)
48

Description

Hello there, I'm currently trying to deeply understand what's in a cache manifest and I have a bunch of questions, feel free to just redirect me to a blog post or something, I couldn't find any that would answer these.

1/ In some builds a cache manifest can have more than one layer with the same digest, but I see that the code treats those as a single, same thing; for example in here :
https://github.com/moby/buildkit/blob/36c5550a84d5ef558c1b9ac733cba128feb37929/cache/remotecache/import.go#L76-L79

Here are some questions:

  • Can a layer be identified by its blob (digest) ? Or should it rather be identified by its full path eg: $parent_digests + $digest ?
  • what gives a digest ?
  • if two digests are identical, can we only assume that the operation was the same ?
  • Could duplicate digests cause some issues down the line ?
  • Would it be a correct thing to sort of rewrite a manifest and merge the duplicate entries together ? ( it feels like no because then we would end up with an incorrect result and sometimes the result would be an invalid loopey dag )

2/ Same paragraph and same questions but for cache records instead of layers. A cache manifest can have more than one records with a similar digest.

3/ cacheManager.Query

  • What will a cacheManager.Query actually lookup ? A digest ? but if the digest can be duplicate, won't that operation be incorrect then ? Or will it rather ask for the full path leading there ?

  • I also saw that upon loading a cache manifest, the loaded digests are randomized here :

https://github.com/moby/buildkit/blob/36c5550a84d5ef558c1b9ac733cba128feb37929/cache/remotecache/v1/cachestorage.go#L47-L52

When the cache item has links. But, would it be possible to rename things before saving the manifest ? So as to have each entry be a unique one ?

Thanks :)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading cache/remotecache/import.go at lines 76-79 and cache/remotecache/v1/cachestorage.go at lines 47-52, then trace cacheManager.Query. The issue provides no test or concrete change to run. Done would require an agreed explanation or documentation covering duplicate layer and cache-record digests, lookup identity, and manifest rewriting.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend, build-system
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.