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
bedc9243
Commit
bedc9243
authored
Jan 04, 2022
by
Marius Bobin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove running build entries when calling doom on a build
Changelog: fixed
parent
cdeccbce
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
4 deletions
+54
-4
app/models/ci/build.rb
app/models/ci/build.rb
+12
-0
app/services/ci/stuck_builds/drop_helpers.rb
app/services/ci/stuck_builds/drop_helpers.rb
+11
-1
spec/factories/ci/builds.rb
spec/factories/ci/builds.rb
+4
-0
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+27
-3
No files found.
app/models/ci/build.rb
View file @
bedc9243
...
...
@@ -1021,7 +1021,15 @@ module Ci
transaction
do
update_columns
(
status: :failed
,
failure_reason: :data_integrity_failure
)
all_queuing_entries
.
delete_all
all_runtime_metadata
.
delete_all
end
Gitlab
::
AppLogger
.
info
(
message:
'Build doomed'
,
class:
self
.
class
.
name
,
build_id:
id
,
pipeline_id:
pipeline_id
,
project_id:
project_id
)
end
def
degradation_threshold
...
...
@@ -1067,6 +1075,10 @@ module Ci
::
Ci
::
PendingBuild
.
upsert_from_build!
(
self
)
end
def
create_runtime_metadata!
::
Ci
::
RunningBuild
.
upsert_shared_runner_build!
(
self
)
end
##
# We can have only one queuing entry or running build tracking entry,
# because there is a unique index on `build_id` in each table, but we need
...
...
app/services/ci/stuck_builds/drop_helpers.rb
View file @
bedc9243
...
...
@@ -34,7 +34,7 @@ module Ci
# rubocop: enable CodeReuse/ActiveRecord
def
drop_build
(
type
,
build
,
reason
)
Gitlab
::
AppLogger
.
info
"
#{
self
.
class
}
: Dropping
#{
type
}
build
#{
build
.
id
}
for runner
#{
build
.
runner_id
}
(status:
#{
build
.
status
}
, failure_reason:
#{
reason
}
)"
log_dropping_message
(
type
,
build
,
reason
)
Gitlab
::
OptimisticLocking
.
retry_lock
(
build
,
3
,
name:
'stuck_ci_jobs_worker_drop_build'
)
do
|
b
|
b
.
drop
(
reason
)
end
...
...
@@ -53,6 +53,16 @@ module Ci
project_id:
build
.
project_id
)
end
def
log_dropping_message
(
type
,
build
,
reason
)
Gitlab
::
AppLogger
.
info
(
class:
self
.
class
.
name
,
message:
"Dropping
#{
type
}
build"
,
build_stuck_type:
type
,
build_id:
build
.
id
,
runner_id:
build
.
runner_id
,
build_status:
build
.
status
,
build_failure_reason:
reason
)
end
end
end
end
spec/factories/ci/builds.rb
View file @
bedc9243
...
...
@@ -335,6 +335,10 @@ FactoryBot.define do
running
runner
factory: :ci_runner
after
(
:create
)
do
|
build
|
build
.
create_runtime_metadata!
end
end
trait
:artifacts
do
...
...
spec/models/ci/build_spec.rb
View file @
bedc9243
...
...
@@ -5427,7 +5427,8 @@ RSpec.describe Ci::Build do
describe
'#doom!'
do
subject
{
build
.
doom!
}
let_it_be
(
:build
)
{
create
(
:ci_build
,
:queued
)
}
let
(
:traits
)
{
[]
}
let
(
:build
)
{
create
(
:ci_build
,
*
traits
,
pipeline:
pipeline
)
}
it
'updates status and failure_reason'
,
:aggregate_failures
do
subject
...
...
@@ -5436,6 +5437,18 @@ RSpec.describe Ci::Build do
expect
(
build
.
failure_reason
).
to
eq
(
"data_integrity_failure"
)
end
it
'logs a message'
do
expect
(
Gitlab
::
AppLogger
)
.
to
receive
(
:info
)
.
with
(
a_hash_including
(
message:
'Build doomed'
,
class:
build
.
class
.
name
,
build_id:
build
.
id
))
.
and_call_original
subject
end
context
'with queued builds'
do
let
(
:traits
)
{
[
:queued
]
}
it
'drops associated pending build'
do
subject
...
...
@@ -5443,6 +5456,17 @@ RSpec.describe Ci::Build do
end
end
context
'with running builds'
do
let
(
:traits
)
{
[
:picked
]
}
it
'drops associated runtime metadata'
do
subject
expect
(
build
.
reload
.
runtime_metadata
).
not_to
be_present
end
end
end
it
'does not generate cross DB queries when a record is created via FactoryBot'
do
with_cross_database_modification_prevented
do
create
(
:ci_build
)
...
...
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