Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
06ab9732
Commit
06ab9732
authored
May 17, 2021
by
Max Woolf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Speed up SSH key expiration notification queries
parent
0cf021ab
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
2 deletions
+6
-2
app/workers/ssh_keys/expired_notification_worker.rb
app/workers/ssh_keys/expired_notification_worker.rb
+3
-1
app/workers/ssh_keys/expiring_soon_notification_worker.rb
app/workers/ssh_keys/expiring_soon_notification_worker.rb
+3
-1
No files found.
app/workers/ssh_keys/expired_notification_worker.rb
View file @
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
...
...
app/workers/ssh_keys/expiring_soon_notification_worker.rb
View file @
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_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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment