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
a9e9bfc8
Commit
a9e9bfc8
authored
Aug 12, 2021
by
Keith Richardson
Committed by
Vitali Tatarintev
Aug 12, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix expired artifacts causing dependency failures on locked pipelines
parent
6e1e1bf5
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
60 additions
and
11 deletions
+60
-11
app/models/ci/build.rb
app/models/ci/build.rb
+1
-1
lib/api/entities/ci/job_request/dependency.rb
lib/api/entities/ci/job_request/dependency.rb
+1
-1
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+33
-3
spec/serializers/build_details_entity_spec.rb
spec/serializers/build_details_entity_spec.rb
+1
-0
spec/services/ci/register_job_service_spec.rb
spec/services/ci/register_job_service_spec.rb
+24
-6
No files found.
app/models/ci/build.rb
View file @
a9e9bfc8
...
...
@@ -891,7 +891,7 @@ module Ci
end
def
valid_dependency?
return
false
if
artifacts_expired?
return
false
if
artifacts_expired?
&&
!
pipeline
.
artifacts_locked?
return
false
if
erased?
true
...
...
lib/api/entities/ci/job_request/dependency.rb
View file @
a9e9bfc8
...
...
@@ -6,7 +6,7 @@ module API
module
JobRequest
class
Dependency
<
Grape
::
Entity
expose
:id
,
:name
,
:token
expose
:artifacts_file
,
using:
Entities
::
Ci
::
JobArtifactFile
,
if:
->
(
job
,
_
)
{
job
.
artifacts?
}
expose
:artifacts_file
,
using:
Entities
::
Ci
::
JobArtifactFile
,
if:
->
(
job
,
_
)
{
job
.
a
vailable_a
rtifacts?
}
end
end
end
...
...
spec/models/ci/build_spec.rb
View file @
a9e9bfc8
...
...
@@ -3743,7 +3743,21 @@ RSpec.describe Ci::Build do
context
'when artifacts of depended job has been expired'
do
let!
(
:pre_stage_job
)
{
create
(
:ci_build
,
:success
,
:expired
,
pipeline:
pipeline
,
name:
'test'
,
stage_idx:
0
)
}
it
{
expect
(
job
).
not_to
have_valid_build_dependencies
}
context
'when pipeline is not locked'
do
before
do
build
.
pipeline
.
unlocked!
end
it
{
expect
(
job
).
not_to
have_valid_build_dependencies
}
end
context
'when pipeline is locked'
do
before
do
build
.
pipeline
.
artifacts_locked!
end
it
{
expect
(
job
).
to
have_valid_build_dependencies
}
end
end
context
'when artifacts of depended job has been erased'
do
...
...
@@ -4763,8 +4777,24 @@ RSpec.describe Ci::Build do
let!
(
:pre_stage_job_invalid
)
{
create
(
:ci_build
,
:success
,
:expired
,
pipeline:
pipeline
,
name:
'test2'
,
stage_idx:
1
)
}
let!
(
:job
)
{
create
(
:ci_build
,
:pending
,
pipeline:
pipeline
,
stage_idx:
2
,
options:
{
dependencies:
%w(test1 test2)
})
}
it
'returns invalid dependencies'
do
expect
(
job
.
invalid_dependencies
).
to
eq
([
pre_stage_job_invalid
])
context
'when pipeline is locked'
do
before
do
build
.
pipeline
.
unlocked!
end
it
'returns invalid dependencies when expired'
do
expect
(
job
.
invalid_dependencies
).
to
eq
([
pre_stage_job_invalid
])
end
end
context
'when pipeline is not locked'
do
before
do
build
.
pipeline
.
artifacts_locked!
end
it
'returns no invalid dependencies when expired'
do
expect
(
job
.
invalid_dependencies
).
to
eq
([])
end
end
end
...
...
spec/serializers/build_details_entity_spec.rb
View file @
a9e9bfc8
...
...
@@ -133,6 +133,7 @@ RSpec.describe BuildDetailsEntity do
let
(
:message
)
{
subject
[
:callout_message
]
}
before
do
build
.
pipeline
.
unlocked!
build
.
drop!
(
:missing_dependency_failure
)
end
...
...
spec/services/ci/register_job_service_spec.rb
View file @
a9e9bfc8
...
...
@@ -5,8 +5,8 @@ require 'spec_helper'
module
Ci
RSpec
.
describe
RegisterJobService
do
let_it_be
(
:group
)
{
create
(
:group
)
}
let_it_be
(
:project
,
reload:
true
)
{
create
(
:project
,
group:
group
,
shared_runners_enabled:
false
,
group_runners_enabled:
false
)
}
let_it_be
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
let_it_be
_with_reload
(
:project
)
{
create
(
:project
,
group:
group
,
shared_runners_enabled:
false
,
group_runners_enabled:
false
)
}
let_it_be
_with_reload
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
let!
(
:shared_runner
)
{
create
(
:ci_runner
,
:instance
)
}
let!
(
:specific_runner
)
{
create
(
:ci_runner
,
:project
,
projects:
[
project
])
}
...
...
@@ -467,13 +467,27 @@ module Ci
context
'when depended job has not been completed yet'
do
let!
(
:pre_stage_job
)
{
create
(
:ci_build
,
:pending
,
:queued
,
:manual
,
pipeline:
pipeline
,
name:
'test'
,
stage_idx:
0
)
}
it
{
expect
(
subject
)
.
to
eq
(
pending_job
)
}
it
{
is_expected
.
to
eq
(
pending_job
)
}
end
context
'when artifacts of depended job has been expired'
do
let!
(
:pre_stage_job
)
{
create
(
:ci_build
,
:success
,
:expired
,
pipeline:
pipeline
,
name:
'test'
,
stage_idx:
0
)
}
it_behaves_like
'not pick'
context
'when the pipeline is locked'
do
before
do
pipeline
.
artifacts_locked!
end
it
{
is_expected
.
to
eq
(
pending_job
)
}
end
context
'when the pipeline is unlocked'
do
before
do
pipeline
.
unlocked!
end
it_behaves_like
'not pick'
end
end
context
'when artifacts of depended job has been erased'
do
...
...
@@ -490,8 +504,12 @@ module Ci
let!
(
:pre_stage_job
)
{
create
(
:ci_build
,
:success
,
:expired
,
pipeline:
pipeline
,
name:
'test'
,
stage_idx:
0
)
}
before
do
allow_any_instance_of
(
Ci
::
Build
).
to
receive
(
:drop!
)
.
and_raise
(
ActiveRecord
::
StaleObjectError
.
new
(
pending_job
,
:drop!
))
pipeline
.
unlocked!
allow_next_instance_of
(
Ci
::
Build
)
do
|
build
|
expect
(
build
).
to
receive
(
:drop!
)
.
and_raise
(
ActiveRecord
::
StaleObjectError
.
new
(
pending_job
,
:drop!
))
end
end
it
'does not drop nor pick'
do
...
...
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