Sync v3 package metadata from a configured OCI registry
What does this MR do and why?
Makes SyncConfiguration pick Connector::Oci when package_metadata.oci.url is set, so an offline instance can sync from a registry mirror.
- Advisories use it when their v3 flag is on. Licenses and malware have no flag.
- A configured registry wins over a vendored directory.
- With no registry, nothing changes.
- A dataset the registry lacks is recorded as
skipped_unsupported. - A
usernamewhosepassword_fileis unset, missing, a directory or empty raisesConfigError. The advisory and license workers and the two sync services (SyncServiceandV3SyncService, which the malware sync inherits) log it and return, so the checkpoints stay put. It stops the malware and license syncs, and stops the advisory sync only while its v3 flag is on. - The sync hands its stop signal to the connector. A stop while the connector lists tags and manifests is reported as
skipped_stop_signal. - A stop between layers ends the run as interrupted. A request that fails after the budget has lapsed is still reported as failed.
- The connector bounds every registry read: responses at 20 MiB, blob error bodies at 64 KiB, a repository at 50,000 tags, a layer at 325 MiB compressed and 3 GiB decompressed, and each blob download by the time the run has left.
- A checkpoint write is skipped, and logged at warn, once the lease has ended, because the next run holds it. A run whose final write was skipped is logged and tracked as interrupted, not completed.
- A failed run's log line reports the checkpoint position the database holds, not one assigned in memory by a save that raised.
- Each run writes one lifecycle line per outcome. An interrupt carries its reason, and a failure writes an error-level
failedline with its error type. - A source that rejects a request now logs its
storage_type, and theskipped_unsupportedevent and metric descriptions name the OCI registry case. - The docs gain a section with tabs for the Linux package, the Helm chart and a self-compiled install. The malware sync developer doc lists the connector.
Configuration is the gate; no feature flag. If review wants one, use type beta with default_enabled: true.
Part 7 of 7. Previous: feature/pmdb-oci-6-connector.
flowchart TD
S[Sync starts] --> A{OCI url set and, for advisories, the v3 flag on? Licenses and malware need the url only}
A -->|yes| P{Username set and password_file readable and not empty?}
P -->|no| L[Log the error and stop, checkpoints untouched]
P -->|yes| B[Connector::Oci]
A -->|no| C{Vendored directory present?}
C -->|yes| D[Connector::OfflineV3]
C -->|no| E[Existing selection]The stop signal
A stop during staging commits nothing. A stop between layers, or a lease that ends before the last write, leaves every unit before the one in flight committed.
flowchart TD
S["Sync run, stop signal arrives"] --> W{"Where is the connector?"}
W -->|"listing tags and manifests"| A["Connector returns nil"]
A --> B["Run reported as skipped_stop_signal, checkpoint unchanged"]
W -->|"reading layers"| C["Connector raises Connector::Oci::Interrupted before the next layer"]
C --> D["Service keeps every unit before the one in flight committed"]
D --> E["Next run reads the last unit again"]
W -->|"lease ended before the last unit is written"| F["Write skipped and logged at warn"]
F --> G["Run logged and tracked as interrupted"]
G --> EThe series
| MR | Branch | Adds | Files | Lines (code, spec, docs) |
|---|---|---|---|---|
| 1 | feature/pmdb-oci-1-auth-challenge |
Shared auth challenge parser | 4 | 53, 70 |
| 2 | feature/pmdb-oci-2-settings |
package_metadata.oci setting |
4 | 136, 194 |
| 3 | feature/pmdb-oci-3-client |
Registry client | 2 | 208, 395 |
| 4 | feature/pmdb-oci-4-blobs |
Verified blob download | 2 | 181, 406 |
| 5 | feature/pmdb-oci-5-timeline |
Timeline planner | 2 | 148, 249 |
| 6 | feature/pmdb-oci-6-connector |
OCI connector | 7 | 335, 731 |
| 7 | this MR | Sync switch, error handling and docs | 19 | 214, 443, 156 |
End to end
These arms ran on the series tip before the review fixes, which the specs cover. They were not run again.
The connector read a TLS registry whose Bearer token service runs on a separate host, behind a private CA, on a development instance. Credentials reached only the registry and the token service. The arms:
- a snapshot, then a delta from it
- the token flow: a basic-credential 401, then a Bearer token
- a realm on a host not in
token_hosts: refused, host logged - a realm that redirects: the redirect target is never requested
- a realm on the registry's host and another port: refused, nothing reaches that port
- a token service on a non-443 port named in
token_hosts: read to the newest checkpoint - a revoked token: one fresh token request per blob, then a logged error with checkpoints unchanged; a token revoked once recovers
- a
password_filethat is missing, empty, a directory, unreadable, not valid UTF-8 or not a string: logged, no request sent. With the v3 advisory flag off only the malware and license syncs stop; with it on, all three stop
The data also went through the packaging path in the docs (signed, pushed, verified, promoted and assembled), and the connector read it: the snapshot on the first run, the newest delta on the second, and no change on a third.
Limit: a development install with these patches applied, not a Linux package or Helm install, because no installable build carries them yet. The Linux package and Helm chart expose the setting in two companion MRs, omnibus-gitlab!10121 and gitlab-org/charts/gitlab!5618. The docs for moving the data through a registry are in !271790. Those three MRs should merge before this one or with it, because the docs name settings that exist only in the companions.
Related to #642401
How to set up and validate locally
bundle exec rspec ee/spec/models/package_metadata/sync_configuration_spec.rb ee/spec/services/package_metadata/malware_advisory_sync_service_spec.rb ee/spec/services/package_metadata/advisory_v3_sync_service_spec.rb ee/spec/services/package_metadata/license_v3_sync_service_spec.rb ee/spec/services/package_metadata/v3_sync_service_spec.rb ee/spec/services/package_metadata/sync_service_spec.rb ee/spec/workers/package_metadata/oci_misconfiguration_spec.rbMR acceptance checklist
- At each slice head, the specs that slice and the slices below it touch pass, with 0 failures: 521, 546, 583, 621, 657, 739 and 802 examples in 11, 12, 13, 13, 14, 16 and 18 spec files. The last count is at
3b39716903. - Every live mutation was killed: 56 before review and 24 on the first review fixes.
- Each added limit has a spec that fails without it.
- Changed-line coverage, measured with SimpleCov on a rig build, covers every changed line of each slice. The last change, to
Sink#time_left, was not measured again and has its own example. - RuboCop reports no offenses on the 28 changed Ruby files. The docs are unchanged since markdownlint reported no offenses and Vale no errors on them.
An AI coding assistant wrote this change. The assistant also ran RuboCop, markdownlint, Vale and the specs above on a self-managed GitLab development instance on a test VM.