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
5f2b8d0d
Commit
5f2b8d0d
authored
Sep 30, 2021
by
drew cimino
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure lease cancellation in StuckCiJobsWorker
parent
fe980078
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
4 deletions
+20
-4
app/workers/stuck_ci_jobs_worker.rb
app/workers/stuck_ci_jobs_worker.rb
+5
-3
spec/workers/ci/stuck_builds/drop_running_worker_spec.rb
spec/workers/ci/stuck_builds/drop_running_worker_spec.rb
+1
-1
spec/workers/stuck_ci_jobs_worker_spec.rb
spec/workers/stuck_ci_jobs_worker_spec.rb
+14
-0
No files found.
app/workers/stuck_ci_jobs_worker.rb
View file @
5f2b8d0d
...
...
@@ -21,9 +21,11 @@ class StuckCiJobsWorker # rubocop:disable Scalability/IdempotentWorker
return
unless
try_obtain_lease
Ci
::
StuckBuilds
::
DropService
.
new
.
execute
remove_lease
begin
Ci
::
StuckBuilds
::
DropService
.
new
.
execute
ensure
remove_lease
end
end
private
...
...
spec/workers/ci/stuck_builds/drop_running_worker_spec.rb
View file @
5f2b8d0d
...
...
@@ -57,7 +57,7 @@ RSpec.describe Ci::StuckBuilds::DropRunningWorker do
expect_to_cancel_exclusive_lease
(
worker_lease_key
,
worker_lease_uuid
)
allow_next_instance_of
(
Ci
::
StuckBuilds
::
DropRunningService
)
do
|
service
|
allow
(
service
).
to
receive
(
:execute
)
do
expect
(
service
).
to
receive
(
:execute
)
do
raise
'The query timed out'
end
end
...
...
spec/workers/stuck_ci_jobs_worker_spec.rb
View file @
5f2b8d0d
...
...
@@ -55,6 +55,20 @@ RSpec.describe StuckCiJobsWorker do
worker
.
perform
end
context
'when the DropService fails'
do
it
'ensures cancellation of the exclusive lease'
do
expect_to_cancel_exclusive_lease
(
worker_lease_key
,
worker_lease_uuid
)
allow_next_instance_of
(
Ci
::
StuckBuilds
::
DropService
)
do
|
service
|
expect
(
service
).
to
receive
(
:execute
)
do
raise
'The query timed out'
end
end
expect
{
worker
.
perform
}.
to
raise_error
(
/The query timed out/
)
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