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

Split out OCI store #3371

Merged
merged 4 commits into from
Dec 13, 2022
Merged

Split out OCI store #3371

merged 4 commits into from
Dec 13, 2022

Conversation

jedevc
Copy link
Member

@jedevc jedevc commented Dec 7, 2022

⬆️ Follow-up to #2827 #3118
⚠️ Breaks API compatibility with previous OCI implementation (should be alright, as long as it merges before v0.11 is released)

This PR performs a couple of OCI refactors on-top of the ones already done in #3300:

  • Removes unnecessary caps - the feature only requires a single extra cap, instead of the 3 that were previously defined. Since the existence of the main OCI cap implied the existence of the other ones, we don't need to have the other ones, more caps should only be required as we increase the scope of the feature over time.

  • Removes the unnecessary SessionID attachment to the normal docker image resolver, since it's only relevant when loading from OCI stores in the OCI image resolver.

  • Refactors the store id out of the main image reference, and instead attaches the store id as a separate property. This prevent us from needing to do name mangling and de-mangling (preventing us from needing the Hostname call).

  • Finally, since the reference then becomes completely irrelevant except for the digest portion, we can name it appropriately to ensure that we get reasonable error messages. Instead of using the store name as the basis for the dummy ref, we keep the original name, which allows the client to perform content store mappings as it desires - this pairs well with build: refactor reference parsing for oci image layouts docker/buildx#1456, which uses randomly generated identifiers as the store names.

    Before:

    $ buildctl build ... --opt context:x/y=oci-layout://dump@sha256:36e80b557af40b63856575bab09a71739026d1f8e3d31351e6852c06a0e5306a --oci-layout dump=./store
     => [context x/y] load metadata for dump@sha256:36e80b557af40b63856575bab09a71739026d1f8e3d31351e6852c06a0e5306a                                  0.0s
     => [context x/y] OCI load from client                                                                                                            0.0s
     => => resolve foo/bar@sha256:36e80b557af40b63856575bab09a71739026d1f8e3d31351e6852c06a0e5306a                                                    0.0s
     => => sha256:d93dab677ee66a618cb0662f39b2dff30ca7f89fe9beddb9aaad9a17b766fee5 7.00MB / 7.00MB                                                    0.1s
     => => extracting sha256:d93dab677ee66a618cb0662f39b2dff30ca7f89fe9beddb9aaad9a17b766fee5                                                         0.1s
    

    After:

    $ buildctl build ... --opt context:x/y=oci-layout://dump@sha256:36e80b557af40b63856575bab09a71739026d1f8e3d31351e6852c06a0e5306a --oci-layout dump=./store
     => [context x/y] load metadata for docker.io/x/y@sha256:36e80b557af40b63856575bab09a71739026d1f8e3d31351e6852c06a0e5306a                         0.1s
     => [context x/y] OCI load from client                                                                                                            0.3s
     => => resolve docker.io/x/y@sha256:36e80b557af40b63856575bab09a71739026d1f8e3d31351e6852c06a0e5306a                                              0.0s
     => => sha256:d93dab677ee66a618cb0662f39b2dff30ca7f89fe9beddb9aaad9a17b766fee5 7.00MB / 7.00MB                                                    0.1s
     => => extracting sha256:d93dab677ee66a618cb0662f39b2dff30ca7f89fe9beddb9aaad9a17b766fee5                                                         0.1s
    

@jedevc jedevc added this to the v0.11.0 milestone Dec 12, 2022
@tonistiigi
Copy link
Member

@jedevc Needs rebase.

We don't need multiple caps for a single feature - the caps that these
were copied by were addded over time, we don't immediately need all of
them to start with, only the main feature one is initially required.

Signed-off-by: Justin Chadwell <me@jedevc.com>
SessionID is only used by the OCI resolver, so it shouldn't be included
for normal docker image resolution.

Signed-off-by: Justin Chadwell <me@jedevc.com>
This breaking api change refactors the LLB API to prevent reference
mangling and demangling throughout OCI access. Once the session and
store IDs have been determined in the dockerfile frontend, we keep them
the same, and attach them as additional properties.

This has the additional effect of making the actual reference used in
the image resolution arbitrary, since we only parse and access the
digest. The rest of the name can be selected to optimize for log
readability.

Signed-off-by: Justin Chadwell <me@jedevc.com>
Now that the reference is not significant to image resolution, with only
the digest being used to determine what to lookup, the only effect of
the dummy reference is to provide reasonable error messages.

Since the name of the store is likely not significant, using that as the
basis for the reference may be deceiving. We can use the original name
of the image as the dummy reference, except with the targeted digest. We
can't easily require that clients should expose the name of the store,
since that may be a leak of the local path to the store, which may be
private.

Signed-off-by: Justin Chadwell <me@jedevc.com>
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.

None yet

2 participants