-
Notifications
You must be signed in to change notification settings - Fork 52
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
Add suport for layer mounting + garbage collector refactor #92
Conversation
- Fix config blobs were delete when referenced - Add manifest-list support for multi-arch images - Add layer mounting support cross-repository
# Conflicts: # src/router.ts # test/index.test.ts
Hello, I noticed that the For now I've added a method with |
Unimplemented for http client is OK as its not supposed to support uploads. |
Amazing work @Dramelac, lgtm. Just one nit comment. |
Thanks @gabivlj !
|
I am ok with doing this as an alternative for now. I agree its a very expensive operation though. I think garbage collection with R2 only will always be a harder problem to solve, for now lets just make it work with a small |
Updated ! |
Sorry for the delay to merge this. LGTM :). Thank you! |
Hello,
Here is a PR to add support for layer mounting operations (issue #85).
Overview
I have chosen to create pseudo-symlink system with R2 file and customMetadata to link a blob file to an existing blob on any other repository inside the registry.
An R2 symlink will include a
customMetadata
:X-Serverless-Registry-Symlink
as key and the name of the targeted repository in its value (to avoid parsing the repository name from the full path of the targeted blob). The content of this symlink file is the full path to the targeted blob as text.Changes
Registry
mountExistingLayer
method for creating a new blob as an R2 symlink targeting another existing blob in another repository (if it exists).Router
When uploading a new blob, if the client successfully mounts a layer, the registry should reply with code 201. If there is any error during the layer mounting operation, it will automatically fallback to the classic layer uploading process with response code 202.
Garbage collector
The garbage collector
collectInner
function has been refactored to address many changes, including some existing bugs and limitations:With the new refactored function, it can now:
unreferenced
anduntagged
modeLimitation of the new method / design
deleteThreshold
/ number of blobs to delete at once, I don't know if this limit is still needed or not.customMetadata
of an existing R2 object with the Worker R2 API, we could update a referenced counter on each symlink target blob and skip this heavy step but as far as I know it doesn't seem possible at the moment. However, if it's planned / soon-to-be release feature, it should be added in this first implementation to avoid adding an upgrade task later on.The garbage collector
list
function now includescustomMetadata
to detect R2 symlinks.Tests
To check the new features, I've added several tests.
I'm also waiting for PR #89 to be merged as it'll introduce some test changes that will cause a conflict with this PR.Updated !
Updating existing tests
generateManifest
function allow to generate a simple v1 or v2 manifest and upload referenced blobs to a repository.This function had several problems:
The new version of this function generates random layer data and a unique config blob for each manifest, allowing different bugs to be detected. This change has introduced the need to update several tests to handle the new number of unique blobs.
v2 manifests
/PUT then list tags with GET /v2/:name/tags/list
test had to be reduced down from 50 images to 40 as it introduced some vitest instability, sometimes it works and sometime I get aNetwork error
without any change or reason...Generic methods
generateManifestList
method to generate a manifest-list v2 from 2 manifests for AMD and ARM architectures.getLayersFromManifest
method to extract every blob referenced by a given v1 or v2 manifest.mountLayersFromManifest
method to mount every blob of a manifest from one repository to another.createManifestList
method to generate two manifest and a manifest-list and upload all three to a repository with or without a tag.runGarbageCollector
method to run the garbage collector on a given repository in a given mode (unreferenced, untagged or both).New tests
v2 manifest
Added a new test with recursive layers mounting of a simple image manifest
v2 manifest-list
Added a new tests to upload manifest-list images with or without layer mounting
garbage collector
Added a few tests to check that the garbage collector deletes blobs and manifests as required, no more and no less.