Block calls to CustomersDot when too many namespace name updates
What does this MR do and why?
Related to https://gitlab.com/gitlab-org/gitlab/-/issues/416705
In an effort to throttle calls made to CustomersDot (in a context of API abuse - see related issue for more details), this MR adds a check to the EE Namespace model module: whenever an existing namespace has its name updated more than once within a short amount of time (1 minute), then we cancel related calls to CustomersDot.
Alternative solution?
Here's more context to this fix: this MR here is the second attempt to address the related issue. The first attempt was done through this MR, where a new Application setting was proposed. However, it was suggested from a database reviewer to find an alternative to making the application_settings
table wider.
How to set up and validate locally
-
Tail the Sidekiq logs:
gdk tail rails-background-jobs
-
In another terminal window, open GitLab Rails console and run these two commands (within a few seconds from one another):
Namespace.last.update!(name: 'new_name_1') Namespace.last.update!(name: 'new_name_2')
In the
rails-background-jobs
logs, you should see only one jobNamespaces::SyncNamespaceNameWorker
job being enqueued, not two. It will fail if you don't have CustomersDot setup (maybe this is an opportunity to clear your Sidekiq RetrySet?Sidekiq::RetrySet.new.map(&:delete)
) but this is outside the scope of testing this MR. -
Wait for one minute to pass, then run:
Namespace.last.update!(name: 'new_name_3')
A new job should be enqueued.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #416705