Maven virtual registry: implement multiple upstreams support
⏫ Multiple upstream support
🪑 Table changes
- Add an
positioncolumn tovirtual_registries_packages_maven_registry_upstreams. Required. - Drop the unique constraints for that table. Here and here.
- Add a unique
[registry_id, upstream_id]constraint. - (If possible) add a count constraint where
registry_idcan't only appear20times.
- Add a unique
🦄 Model changes
-
VirtualRegistries::Packages::Maven::Registrymodel- Revisit
has_oneassociations here and here. - Revisit
#destroy_upstream.
- Revisit
-
VirtualRegistries::Packages::Maven::RegistryUpstreammodel- Implementation a validation that only allows
registry_idto appear20times in the table. - Handle the
positionattribute.- Special case: updating the attribute on an existing record which means:
- if the order is not taken: make sure that the ordering is coherent. (
1,2,3) instead of (1,20,100). - if the order is taken: push down all the greater order. (
1,2,3) for upstreams (A,B,C). UpdatingCorder to1should end up in (1,2,3) for (C,A,B).
- if the order is not taken: make sure that the ordering is coherent. (
- We could use a gem for this but honestly, I think we can keep it simple with callbacks that will adjust the
positionvalue for impacted upstreams.
- Special case: updating the attribute on an existing record which means:
- Implementation a validation that only allows
-
VirtualRegistries::Packages::Maven::Upstream.- In the
urlvalidator, add additional parameters:dns_rebind_protection: true
- Make sure that removing a
VirtualRegistries::Packages::Maven::Upstreamalso removes theVirtualRegistries::Packages::Maven::RegistryUpstreamrecord.
- In the
⚙️ Service changes
-
VirtualRegistries::Packages::Maven::HandleFileRequestService.- Update
#cache_entry. This is the code that tries to locate an existing cache entry. - Update
#check_upstream. This is where the logic investigated should be.- Use
typhoeuswith thehydramode with concurrency of3.
- Use
- Update
📻 API changes
- Upstreams API:
- Adding an
UpstreamthroughPOST /api/v4/virtual_registries/packages/maven/registries/:id/upstreamswill append theUpstreamat the end of the list. - Expose the
registry_upstream_id.
- Adding an
- Introduce a new API for
RegistryUpstreamsunder/api/v4/virtual_registries/packages/maven/registry_upstreams- For now, we only need
PUT /api/v4/virtual_registries/packages/maven/registry_upstreams/:idto be able to update theposition.
- For now, we only need
🏋️ Work load
We are looking at 3-4 MRs for the overall work. They are mostly sequential (following the presentation order shown above). The only exception is API changes that can be done as soon as we have model changes.