Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-01-24 18:07:34 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-01-24 18:07:34 +0300
commitdf9890e9a702e2f12bbc8f022b916ca72820a292 (patch)
tree26ff255cfb6843fe963fcafea9ee70121ee5e913 /app/services
parent17c1c66eefd05243dd8ed2c8fd49d17ab1a52522 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services')
-rw-r--r--app/services/ci/list_config_variables_service.rb4
-rw-r--r--app/services/ci/runners/stale_machines_cleanup_service.rb33
-rw-r--r--app/services/keys/revoke_service.rb28
-rw-r--r--app/services/notes/destroy_service.rb8
4 files changed, 72 insertions, 1 deletions
diff --git a/app/services/ci/list_config_variables_service.rb b/app/services/ci/list_config_variables_service.rb
index df4963d1b33..dbea270b7c6 100644
--- a/app/services/ci/list_config_variables_service.rb
+++ b/app/services/ci/list_config_variables_service.rb
@@ -17,7 +17,9 @@ module Ci
new(project, user)
end
- def execute(sha)
+ def execute(ref)
+ sha = project.commit(ref).try(:sha)
+
with_reactive_cache(sha) { |result| result }
end
diff --git a/app/services/ci/runners/stale_machines_cleanup_service.rb b/app/services/ci/runners/stale_machines_cleanup_service.rb
new file mode 100644
index 00000000000..3e5706d24a6
--- /dev/null
+++ b/app/services/ci/runners/stale_machines_cleanup_service.rb
@@ -0,0 +1,33 @@
+# frozen_string_literal: true
+
+module Ci
+ module Runners
+ class StaleMachinesCleanupService
+ MAX_DELETIONS = 1000
+
+ def execute
+ ServiceResponse.success(payload: {
+ # the `stale` relationship can return duplicates, so we don't try to return a precise count here
+ deleted_machines: delete_stale_runner_machines > 0
+ })
+ end
+
+ private
+
+ def delete_stale_runner_machines
+ total_deleted_count = 0
+ loop do
+ sub_batch_limit = [100, MAX_DELETIONS].min
+
+ # delete_all discards part of the `stale` scope query, so we expliclitly wrap it with a SELECT as a workaround
+ deleted_count = Ci::RunnerMachine.id_in(Ci::RunnerMachine.stale.limit(sub_batch_limit)).delete_all
+ total_deleted_count += deleted_count
+
+ break if deleted_count == 0 || total_deleted_count >= MAX_DELETIONS
+ end
+
+ total_deleted_count
+ end
+ end
+ end
+end
diff --git a/app/services/keys/revoke_service.rb b/app/services/keys/revoke_service.rb
new file mode 100644
index 00000000000..42ea9ab73be
--- /dev/null
+++ b/app/services/keys/revoke_service.rb
@@ -0,0 +1,28 @@
+# frozen_string_literal: true
+
+module Keys
+ class RevokeService < ::Keys::DestroyService
+ def execute(key)
+ key.transaction do
+ unverify_associated_signatures(key)
+
+ raise ActiveRecord::Rollback unless super(key)
+ end
+ end
+
+ private
+
+ def unverify_associated_signatures(key)
+ return unless Feature.enabled?(:revoke_ssh_signatures)
+
+ key.ssh_signatures.each_batch do |batch|
+ batch.update_all(
+ verification_status: CommitSignatures::SshSignature.verification_statuses[:revoked_key],
+ updated_at: Time.zone.now
+ )
+ end
+ end
+ end
+end
+
+Keys::DestroyService.prepend_mod
diff --git a/app/services/notes/destroy_service.rb b/app/services/notes/destroy_service.rb
index eda8bbcbc2e..ccee94a5cea 100644
--- a/app/services/notes/destroy_service.rb
+++ b/app/services/notes/destroy_service.rb
@@ -10,6 +10,7 @@ module Notes
clear_noteable_diffs_cache(note)
track_note_removal_usage_for_issues(note) if note.for_issue?
track_note_removal_usage_for_merge_requests(note) if note.for_merge_request?
+ track_note_removal_usage_for_design(note) if note.for_design?
end
private
@@ -22,6 +23,13 @@ module Notes
def track_note_removal_usage_for_merge_requests(note)
Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter.track_remove_comment_action(note: note)
end
+
+ def track_note_removal_usage_for_design(note)
+ Gitlab::UsageDataCounters::IssueActivityUniqueCounter.track_issue_design_comment_removed_action(
+ author: note.author,
+ project: project
+ )
+ end
end
end