Skip to content

Commit 871e5fd

Browse files
sudo-bmitchjdolitsky
authored andcommitted
Adding upgrade and client fallback specifications.
Signed-off-by: Brandon Mitchell <[email protected]>
1 parent 23f5ead commit 871e5fd

File tree

4 files changed

+62
-40
lines changed

4 files changed

+62
-40
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ The OCI Distribution Spec project defines an API protocol to facilitate and stan
66

77
**[The specification can be found here](spec.md).**
88

9-
This repository also provides [Go types](specs-go), [registry conformance tooling](conformance), and
9+
This repository also provides [Go types](specs-go), [registry conformance tooling](conformance), [registry upgrading requirements](upgrading.md), and
1010
[client implementation guidelines](client-implementation.md).
1111
The Go types and validation should be compatible with the current Go release; earlier Go releases are not supported.
1212

client-implementation.md

Lines changed: 44 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,67 @@
11
# Client Implementations
22

3-
The distribution-spec is mainly concerned with registry behaviour. However,
4-
some registries may not always support all aspects of the spec.
3+
This document describes client implementation recommendations for interoperability with registry servers and other clients using the OCI Distribution Spec.
54

6-
This document is a guide for clients that wish to add backwards compaitibility
7-
for registries which only use older endpoints.
5+
## Backwards Compatibility
86

9-
For the remainder of this document "referrers API" will refer to [end-12](TODO),
10-
and the use of reference types.
7+
Client implementations SHOULD support registries that implement partial or older versions of the OCI Distribution Spec.
8+
This section describes how client fallback procedures when an API is not available.
119

12-
## Digest Tags
10+
### Referrers API
1311

14-
For registries that do not support the referrers API, a tag MUST be pushed containing an index of all manifests that refer to the specified manifest, matching the API response above.
15-
The tag uses the following schema:
12+
The Referrers API here is described by [Listing Referrers](spec.md#listing-referrers) and [end-12](spec.md#endpoints).
13+
14+
A client that pushing an Image or Artifact manifest with a defined `Refers` field MUST verify the Referrers API is available.
15+
A client querying the Referrers API and receiving a 404 MUST fallback to using an Index pushed to a tag described by the following schema.
16+
17+
**Tag Schema**
1618

1719
```text
1820
<alg>-<ref>
1921
```
2022

21-
- E.g. `registry.example.org/project:sha256-0000000000000000000000000000000000000000000000000000000000000000`
22-
- `<alg>`: the digest algorithm
23+
- `<alg>`: the digest algorithm (e.g. `sha256` or `sha512`)
2324
- `<ref>`: the digest from the `refers` field (limit of 64 characters)
24-
- Periodic garbage collection may be performed by clients pushing new referrers, deleting stale referrers that have been replaced with newer versions, and tags that no longer point to an accessible manifest.
25-
- Clients can verify the registry does not support the referrers API by querying the API and checking for a 404.
26-
- Clients should pull the existing tag and extend it with additional entries, minimizing the time between the pull and push to reduce the chance of overwriting changes from other clients.
27-
- Clients should use a conditional push for registries that support ETag conditions to avoid overwriting a tag that has been modified by another client since the previous tag manifest was pulled.
2825

29-
## Client Expectations
26+
For example, a manifest with the `Refers` field digest set to `sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` in the `registry.example.org/project` repository would have a expect an Index at `registry.example.org/project:sha256-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa`
27+
28+
**Pushing Manifests**
29+
30+
When pushing an Image or Artifact manifest with the `Refers` field and the Referrers API returns a 404, the client MUST:
3031

31-
### Creating Artifacts
32+
1. Pull the Index using the tag schema.
33+
1. If the tag returns a manifest other than the expected Index, the client SHOULD report a failure and skip the remaining steps.
34+
1. If the tag returns a 404, the client MUST begin with an empty Index.
35+
1. Verify the descriptor for the manifest is not already in the Index (duplicate entries SHOULD NOT be created).
36+
1. Append a descriptor for the pushed manifest to the Index manifests.
37+
The value of the `artifactType` MUST be set in the descriptor to value of the `artifactType` in the Artifact manifest, or the Config descriptor `mediaType` in the Image manifest.
38+
All annotations from the Image or Artifact manifest MUST be copied to this descriptor.
39+
1. Push the updated Index using the same tag schema.
40+
The client MAY use conditional HTTP requests to prevent overwriting an Index that has changed since it was first pulled.
3241

33-
- For portability, clients should generate artifacts using image-spec until all registries where the artifact is pushed to have been upgraded.
34-
- The descriptor of the manifest this artifact refers to should be set in the `refers` field of the manifest.
35-
- Other metadata should be included in the manifest annotations.
36-
- When pushing, the registry should be checked for the referrers API support.
37-
- If the referrers API is not available, the artifact should be pushed with a tag using the digest schema. Tags with the digest schema should not be pushed if the referrers API is available.
42+
**Listing Referrers**
3843

39-
### Pulling Artifacts
44+
If the Referrers API returns a 404, the client MUST fallback to pulling the tag schema.
45+
The response SHOULD be an Index with the same content that would be expected from the Referrers API.
46+
If the response to the Referrers API is a 404, and the tag schema does not return a valid Index, the client SHOULD assume there are no Referrers to the manifest.
4047

41-
To pull artifacts that reference an existing manifest:
48+
**Deleting Referrers**
4249

43-
- Clients requests artifacts associated with a manifest first query the referrers API using the digest of the requested manifest.
44-
- If the request fails, clients must fall back to listing tags in the repository and pull manifests for each tag with the matching `<alg>` and `<ref>` prefix.
45-
- Clients then pull any artifact matching their criteria from the API response or the list generated from the tag query.
50+
When deleting an Image or Artifact manifest that contains a `Refers` field, and the Referrers API returns a 404, clients SHOULD:
4651

47-
### Copying Images
52+
1. Pull the Index using the tag schema.
53+
1. Delete the descriptor from the manifest list to the deleted manifest.
54+
1. Push the updated Index using the same tag schema.
55+
The client MAY use conditional HTTP requests to prevent overwriting an Index that has changed since it was first pulled.
4856

49-
- Tooling that copies images between registries may recursively query for referrers and copy them.
50-
- Copying an artifact that refers to an image uses the same pull and push steps described above and should support both existing registries and registries with the referrers API on both the pull and push.
57+
**Deleting Manifests**
5158

52-
### Deleting Manifests
59+
Clients MAY delete a tag using the tag schema when it returns a valid Index manifest and the referred manifest has been deleted.
5360

54-
For managing existing registries without the referrers API:
61+
**Recommendations**
5562

56-
- Client tooling that deletes manifests should also delete digest tags that reference that manifest.
57-
- Client tooling may periodically check for dangling digest tags that refer to missing manifest, and prune those tags.
63+
- Clients MAY verify the registry does not support the referrers API by querying the API and checking for a 404.
64+
- When the Referrers API is not available, clients MAY perform periodic garbage collection of stale tag schema tags and descriptors in the Index manifest list that no longer exist.
65+
- Clients MAY use a conditional HTTP push for registries that support ETag conditions to avoid conflicts with other clients.
66+
- For portability, clients MAY generate artifacts using image-spec until all registries where the artifact is pushed to have been upgraded.
67+
- Tooling that copies images between registries MAY recursively query for referrers and copy them.

spec.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -488,9 +488,9 @@ When using the `last` query parameter, the `n` parameter is OPTIONAL.
488488

489489
##### Listing Referrers
490490

491-
*Note: this feature is only available in distibution-spec 1.1+.
492-
Clients should see [client-implementation.md](client-implementation.md)
493-
for more details on implementing this.*
491+
*Note: this feature was added in distibution-spec 1.1.
492+
Clients should see [client-implementation.md](client-implementation.md) for more details on implementing this.
493+
Registries should see [upgrading.md](upgrading.md) before enabling this.*
494494

495495
To fetch the list of referrers, perform a `GET` request to a path in the following format: `/v2/<name>/referrers/<reference>` <sup>[end-12](#endpoints)</sup>
496496

@@ -529,8 +529,8 @@ Upon success, the response MUST be a json body in the following format (an index
529529
}
530530
```
531531

532-
A `Link` header MUST be included in the response when additional results are available, and it MUST be
533-
set to the URL for the next page of results.
532+
A `Link` header MUST be included in the response when additional results are available.
533+
The `Link` header MUST be set according to [RFC5988](https://www.rfc-editor.org/rfc/rfc5988.html) with the Relation Type `rel="next"`.
534534

535535
#### Content Management
536536

upgrading.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Upgrade Procedures
2+
3+
This document describes how registries should add support for new APIs and features.
4+
5+
## Referrers API
6+
7+
The Referrers API here is described by [Listing Referrers](spec.md#listing-referrers) and [end-12](spec.md#endpoints).
8+
When registries add support for the Referrers API, this API needs to account for manifests that were pushed before the API was available using the [Client Implementation's tag schema](client-implementation.md#referrers-api).
9+
10+
1. Registries MUST include preexisting Image and Artifact manifests that are listed in an Index tagged with the tag schema and have a valid Refers field.
11+
1. Registries MAY include all existing Image and Artifact manifests with a Refers field in the API response.
12+
1. Registries MUST include all new Image and Artifact manifests with a valid Refers field in the API response.

0 commit comments

Comments
 (0)