Commit 4a3c9122 authored by Sean McGivern's avatar Sean McGivern

Merge branch '331101-expiry-notification-worker-slowness' into 'master'

Speed up SSH key expiration notification queries

See merge request gitlab-org/gitlab!61907
parents 8c77a798 06ab9732
...@@ -14,7 +14,8 @@ module SshKeys ...@@ -14,7 +14,8 @@ module SshKeys
def perform def perform
return unless ::Feature.enabled?(:ssh_key_expiration_email_notification, default_enabled: :yaml) return unless ::Feature.enabled?(:ssh_key_expiration_email_notification, default_enabled: :yaml)
User.with_ssh_key_expired_today.find_each do |user| # rubocop:disable CodeReuse/ActiveRecord
User.with_ssh_key_expired_today.find_each(batch_size: 10_000) do |user|
with_context(user: user) do with_context(user: user) do
Gitlab::AppLogger.info "#{self.class}: Notifying User #{user.id} about expired ssh key(s)" Gitlab::AppLogger.info "#{self.class}: Notifying User #{user.id} about expired ssh key(s)"
...@@ -22,6 +23,7 @@ module SshKeys ...@@ -22,6 +23,7 @@ module SshKeys
Keys::ExpiryNotificationService.new(user, { keys: keys, expiring_soon: false }).execute Keys::ExpiryNotificationService.new(user, { keys: keys, expiring_soon: false }).execute
end end
# rubocop:enable CodeReuse/ActiveRecord
end end
end end
end end
......
...@@ -14,7 +14,8 @@ module SshKeys ...@@ -14,7 +14,8 @@ module SshKeys
def perform def perform
return unless ::Feature.enabled?(:ssh_key_expiration_email_notification, default_enabled: :yaml) return unless ::Feature.enabled?(:ssh_key_expiration_email_notification, default_enabled: :yaml)
User.with_ssh_key_expiring_soon.find_each do |user| # rubocop:disable CodeReuse/ActiveRecord
User.with_ssh_key_expiring_soon.find_each(batch_size: 10_000) do |user|
with_context(user: user) do with_context(user: user) do
Gitlab::AppLogger.info "#{self.class}: Notifying User #{user.id} about expiring soon ssh key(s)" Gitlab::AppLogger.info "#{self.class}: Notifying User #{user.id} about expiring soon ssh key(s)"
...@@ -23,6 +24,7 @@ module SshKeys ...@@ -23,6 +24,7 @@ module SshKeys
Keys::ExpiryNotificationService.new(user, { keys: keys, expiring_soon: true }).execute Keys::ExpiryNotificationService.new(user, { keys: keys, expiring_soon: true }).execute
end end
end end
# rubocop:enable CodeReuse/ActiveRecord
end end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment