Loading
Add a v3 package metadata connector for OCI registries
What does this MR do and why?
Adds Gitlab::PackageMetadata::Connector::Oci, which streams v3 archives from a registry using the earlier MRs. TarZstReader gains an output cap.
- Delta layers are named by decimal sequence and snapshot shards by hex chunk, as
OfflineV3reads them. - Archives are read lazily and capped at 100 times the layer size, between 16 MiB and 3 GiB (
MAX_DECOMPRESSED_LIMIT). The ceiling is about 4 times the largest published v3 archive once decompressed, which is 744 MiB. - The cap is checked on the streamed output, which is the only pass over the archive. A stream that ends before the tar trailer is refused, and one that returns no output and takes no input raises.
- The connector takes the sync's stop signal. A stop while it lists tags and manifests returns nil.
- A stop once it reads layers raises
Connector::Oci::Interruptedbefore the next layer. - A window annotation or layer title with more than 19 digits, or a chunk name with more than 16 hex digits, is refused.
- A snapshot shard above 32,767 (
smallint) and a delta stem above 2,147,483,647 (int4) are not archives. A delta entry numbered outside 0 to 32,767 is rejected before any of its files is yielded. - Each blob gets the time
StopSignal#work_remainingreports as its download budget.StopSignalcounts time left only while the lease key still holds this run's lease. - A layer that cannot be read raises
Client::Errornaming the layer and the repository. Each tag thatTimelineleaves out is logged once at warn. - A missing repository, a
Gapor a registry error before streaming returns nil, so the checkpoint stays put. A bad blob raises.
Safe alone: nothing selects this connector yet.
Part 6 of 7. Previous: feature/pmdb-oci-5-timeline. Next: feature/pmdb-oci-7-sync-switch.
sequenceDiagram
participant S as V3SyncService
participant C as Connector::Oci
participant R as Registry
S->>C: data_after(checkpoint)
C->>R: tags/list
C->>R: manifest for each planned tag
Note over C: nil here leaves the checkpoint alone
C-->>S: lazy stream of archives
S->>C: read next archive
C->>R: blob, size and sha256 checked
Note over C: an error here propagatesRelated to #642401
How to set up and validate locally
bundle exec rspec ee/spec/lib/gitlab/package_metadata/connector/oci_spec.rb
bundle exec rspec ee/spec/lib/gitlab/package_metadata/connector/archive/tar_zst_reader_spec.rbMR acceptance checklist
- The specs that cover this slice pass at
49fbc61a6a: 739 examples in 16 spec files, 0 failures. - RuboCop reports no offenses on the changed files.
An AI coding assistant wrote this change. The assistant also ran RuboCop on the changed files and the specs above on a self-managed GitLab development instance on a test VM.
Edited by Andrew Dunn