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
f4877ee1
Commit
f4877ee1
authored
Oct 27, 2020
by
David Fernandez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix transaction usage in ContainerExpirationPolicyWorker
Use a transaction only for `#perform_throttled`
parent
b255fca2
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
12 deletions
+16
-12
app/workers/container_expiration_policy_worker.rb
app/workers/container_expiration_policy_worker.rb
+8
-8
changelogs/unreleased/273140-fix-transaction-issue-in-container-expiration-policy-worker.yml
...ansaction-issue-in-container-expiration-policy-worker.yml
+5
-0
spec/workers/container_expiration_policy_worker_spec.rb
spec/workers/container_expiration_policy_worker_spec.rb
+3
-4
No files found.
app/workers/container_expiration_policy_worker.rb
View file @
f4877ee1
...
...
@@ -30,12 +30,14 @@ class ContainerExpirationPolicyWorker # rubocop:disable Scalability/IdempotentWo
def
perform_throttled
try_obtain_lease
do
with_runnable_policy
do
|
policy
|
ContainerExpirationPolicy
.
transaction
do
policy
.
schedule_next_run!
ContainerRepository
.
for_project_id
(
policy
.
id
)
.
each_batch
do
|
relation
|
relation
.
update_all
(
expiration_policy_cleanup_status: :cleanup_scheduled
)
end
end
end
ContainerExpirationPolicies
::
CleanupContainerRepositoryWorker
.
perform_with_capacity
end
...
...
@@ -53,9 +55,7 @@ class ContainerExpirationPolicyWorker # rubocop:disable Scalability/IdempotentWo
scope
.
each
do
|
policy
|
if
policy
.
valid?
ContainerExpirationPolicy
.
transaction
do
yield
policy
end
else
disable_invalid_policy!
(
policy
)
end
...
...
changelogs/unreleased/273140-fix-transaction-issue-in-container-expiration-policy-worker.yml
0 → 100644
View file @
f4877ee1
---
title
:
Fix transaction usage in ContainerExpirationPolicyWorker
merge_request
:
46217
author
:
type
:
fixed
spec/workers/container_expiration_policy_worker_spec.rb
View file @
f4877ee1
...
...
@@ -106,12 +106,11 @@ RSpec.describe ContainerExpirationPolicyWorker do
context
'a valid policy'
do
it
'runs the policy'
do
service
=
instance_double
(
ContainerExpirationPolicyService
,
execute:
true
)
expect
(
ContainerExpirationPolicyService
)
.
to
receive
(
:new
).
with
(
container_expiration_policy
.
project
,
user
).
and_return
(
service
)
.
to
receive
(
:new
).
with
(
container_expiration_policy
.
project
,
user
).
and_call_original
expect
(
CleanupContainerRepositoryWorker
).
to
receive
(
:perform_async
).
once
.
and_call_original
subject
expect
{
subject
}.
not_to
raise_error
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