Skip to content

Maven virtual registries: add event store subscriptions

⚖️ Context

This MR is extracted from !210882 (merged) to ensure compatibility with canary deployments.

According to the EventStore documentation:

To ensure compatibility with canary deployments when registering subscriptions, the Sidekiq workers must be introduced in a previous deployment or we must use a feature flag.

🤔 What does this MR do and why?

This MR adds the event store subscriptions for VirtualRegistries::DestroyLocalUpstreamsWorker to listen to:

  • ::Projects::ProjectDeletedEvent
  • ::Groups::GroupDeletedEvent

The worker itself was introduced in !210882 (merged), and this MR completes the integration by registering the subscriptions.

⚙️ How to set up and validate locally

Requirements:

  • Have an EE license as virtual registries are EE only feature.
  • Make sure that :Gitlab.config.dependency_proxy.enabled returns true as the event in EventStore has guard based on it.↵
    • Either enable the registry or
    • Enable it manually in config/gitlab.yml.↵

(Make sure that the rails-background-jobs gdk process is running as the EventStore callback is baked by Sidekiq.)

There are no APIs or UIs for this feature (yet), so we are going to test it in a Rails console:

project_to_delete = FactoryBot.create(:project) # if the path is already taken, just re-run the command until it succeeds.
top_level_group = Group.all.select(&:root?).sample
upstream = ::VirtualRegistries::Packages::Maven::Upstream.create!(name: 'testing', url: project_to_delete.to_global_id.to_s, group: top_level_group)

current_user = User.first # this user should have the rights to destroy the project. In gdk, this one is root.

# delete the project
::Projects::DestroyService.new(project_to_delete, current_user).execute
=> true

# check that both the project and the upstream are deleted
project_to_delete.reload
# ActiveRecord::RecordNotFound: Couldn't find Project with [WHERE "projects"."id" = $1]

# check that the upstream are deleted
upstream.reload
# ActiveRecord::RecordNotFound: Couldn't find VirtualRegistries::Packages::Maven::Upstream with [WHERE "virtual_registries_packages_maven_upstreams"."id" = $1]

You can try the exact same scenario but with a group_to_delete = FactoryBot.create(:group). It will work the same way

📚 References

🏎️ MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by David Fernandez

Merge request reports

Loading