-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Harbor Proxy should serve manifests from local repository if the remote manifest digest matches a local manifest #21122
Comments
Could you please double check the artifact with the same tag and same digest exist in the proxy cache project? It seems that the artifact didn't cached yet from the log. There are two caches, one is the registry, another is the redis cache, the following log is refer the redis cache. |
Sure, I've performed multiple GET manifest requests referencing the tag.
The corresponding artifact in the Harbor portal does not seem to have a tag associated with it, but was already created before the last GET request. On the other hand when performing a GET manifest request referencing the digest, logs of the form |
So the problem is the tag is not created, not proxied image is not served? |
Hello yes, the images are currently proxied in this case, The cause for this behavior seems to be that the manifest was initially only pushed with a reference to the digest, but not the tag. |
The root cause is the tag is not created in proxy cache project, and the request is pull image by tag, then it cause the image is not served with cached content. is that correct? |
Yes I think so, I've created the following PR to push not only the manifest referenced by digest but also push the manifest referenced by tag if it is known, which aims to solve this. @stonezdj was this PR intentionally closed? |
Is your feature request related to a problem? Please describe.
DockerHub Proxy GET /manifest requests referencing a tag are not served from cache even when the remote manifest matches a manifest in the local repository.
This leads to requests reducing the users remainder of the rate limit.
This can be observed by running harbor with log level debug and fetching a manifest multiple times.
GET https://harbor.example.com/v2/docker-hub/goharbor/harbor-exporter/manifests/v2.10.2
https://github.com/goharbor/harbor/blob/v2.10.2/src/controller/proxy/controller.go#L193-L201C1
https://github.com/goharbor/harbor/blob/v2.10.2/src/server/middleware/repoproxy/proxy.go#L203-L209
Describe the solution you'd like
Harbor should serve the manifest from the local repository if the remote manifest digest matches the digest of the manifest in the local repository.
Describe the main design/architecture of your solution
Since Harbor already attempts to use a cache for ManifestLists I suggest to extend this behavior to Manifests by attempting to pull the manifest from the local repository.
https://github.com/goharbor/harbor/blob/v2.10.2/src/controller/proxy/controller.go#L159
Update:
Since middlewares would be skipped by the extended behavior described above, I suggest to push the manifest to the local repository with reference to the digest and tag if both are known instead.
harbor/src/controller/proxy/manifestcache.go
Line 201 in a0d27d3
The text was updated successfully, but these errors were encountered: