summaryrefslogtreecommitdiff
path: root/app/workers/repository_remove_remote_worker.rb
blob: c95393e7d2198c97ee63679ce1230f40f9827038 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# frozen_string_literal: true

class RepositoryRemoveRemoteWorker # rubocop:disable Scalability/IdempotentWorker
  include ApplicationWorker

  data_consistency :always

  sidekiq_options retry: 3
  include ExclusiveLeaseGuard

  feature_category :source_code_management
  loggable_arguments 1

  LEASE_TIMEOUT = 1.hour

  attr_reader :project, :remote_name

  def perform(project_id, remote_name)
    # On-disk remotes are slated for removal, and GitLab doesn't create any of
    # them anymore. For backwards compatibility, we need to keep the worker
    # though such that we can be sure to drain all jobs on an update. Making
    # this a no-op is fine though: the worst that can happen is that we still
    # have old remotes lingering in the repository's config, but Gitaly will
    # start to clean these up in repository maintenance.
    # https://gitlab.com/gitlab-org/gitlab/-/issues/336745
  end

  def lease_timeout
    LEASE_TIMEOUT
  end

  def lease_key
    "remove_remote_#{project.id}_#{remote_name}"
  end
end