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
ab27bb66
Commit
ab27bb66
authored
Apr 30, 2021
by
Furkan Ayhan
Committed by
Fabio Pitino
Apr 30, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix resetting upstream bridge to allow subsequent jobs to run [RUN ALL RSPEC] [RUN AS-IF-FOSS]
parent
cf2ca269
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
83 additions
and
14 deletions
+83
-14
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+11
-4
app/services/ci/after_requeue_job_service.rb
app/services/ci/after_requeue_job_service.rb
+3
-3
app/services/ci/retry_pipeline_service.rb
app/services/ci/retry_pipeline_service.rb
+1
-1
config/feature_flags/development/ci_reset_bridge_with_subsequent_jobs.yml
...lags/development/ci_reset_bridge_with_subsequent_jobs.yml
+8
-0
spec/models/ci/pipeline_spec.rb
spec/models/ci/pipeline_spec.rb
+60
-6
No files found.
app/models/ci/pipeline.rb
View file @
ab27bb66
...
...
@@ -1210,11 +1210,18 @@ module Ci
# We need `base_and_ancestors` in a specific order to "break" when needed.
# If we use `find_each`, then the order is broken.
# rubocop:disable Rails/FindEach
def
reset_
ancestor_bridges!
base_and_ancestors
.
includes
(
:source_bridge
).
each
do
|
pipeline
|
break
unless
pipeline
.
bridge_waiting?
def
reset_
source_bridge!
(
current_user
)
if
::
Feature
.
enabled?
(
:ci_reset_bridge_with_subsequent_jobs
,
project
,
default_enabled: :yaml
)
return
unless
bridge_waiting?
pipeline
.
source_bridge
.
pending!
source_bridge
.
pending!
Ci
::
AfterRequeueJobService
.
new
(
project
,
current_user
).
execute
(
source_bridge
)
# rubocop:disable CodeReuse/ServiceClass
else
base_and_ancestors
.
includes
(
:source_bridge
).
each
do
|
pipeline
|
break
unless
pipeline
.
bridge_waiting?
pipeline
.
source_bridge
.
pending!
end
end
end
# rubocop:enable Rails/FindEach
...
...
app/services/ci/after_requeue_job_service.rb
View file @
ab27bb66
...
...
@@ -4,7 +4,7 @@ module Ci
class
AfterRequeueJobService
<
::
BaseService
def
execute
(
processable
)
process_subsequent_jobs
(
processable
)
reset_
ancestor_bridges
(
processable
)
reset_
source_bridge
(
processable
)
end
private
...
...
@@ -15,8 +15,8 @@ module Ci
end
end
def
reset_
ancestor_bridges
(
processable
)
processable
.
pipeline
.
reset_
ancestor_bridges!
def
reset_
source_bridge
(
processable
)
processable
.
pipeline
.
reset_
source_bridge!
(
current_user
)
end
def
process
(
processable
)
...
...
app/services/ci/retry_pipeline_service.rb
View file @
ab27bb66
...
...
@@ -26,7 +26,7 @@ module Ci
retry_optimistic_lock
(
skipped
,
name:
'ci_retry_pipeline'
)
{
|
build
|
build
.
process
(
current_user
)
}
end
pipeline
.
reset_
ancestor_bridges!
pipeline
.
reset_
source_bridge!
(
current_user
)
::
MergeRequests
::
AddTodoWhenBuildFailsService
.
new
(
project
,
current_user
)
...
...
config/feature_flags/development/ci_reset_bridge_with_subsequent_jobs.yml
0 → 100644
View file @
ab27bb66
---
name
:
ci_reset_bridge_with_subsequent_jobs
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/60376
rollout_issue_url
:
https://gitlab.com/gitlab-org/gitlab/-/issues/329194
milestone
:
'
13.12'
type
:
development
group
:
group::pipeline authoring
default_enabled
:
false
spec/models/ci/pipeline_spec.rb
View file @
ab27bb66
...
...
@@ -4303,26 +4303,80 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
end
describe
'reset_ancestor_bridges!'
do
let_it_be
(
:pipeline
)
{
create
(
:ci_pipeline
,
:created
)
}
describe
'#reset_source_bridge!'
do
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
:created
,
project:
project
)
}
subject
(
:reset_bridge
)
{
pipeline
.
reset_source_bridge!
(
project
.
owner
)
}
# This whole block will be removed by https://gitlab.com/gitlab-org/gitlab/-/issues/329194
# It contains some duplicate checks.
context
'when the FF ci_reset_bridge_with_subsequent_jobs is disabled'
do
before
do
stub_feature_flags
(
ci_reset_bridge_with_subsequent_jobs:
false
)
end
context
'when the pipeline is a child pipeline and the bridge is depended'
do
let!
(
:parent_pipeline
)
{
create
(
:ci_pipeline
)
}
let!
(
:bridge
)
{
create_bridge
(
parent_pipeline
,
pipeline
,
true
)
}
it
'marks source bridge as pending'
do
reset_bridge
expect
(
bridge
.
reload
).
to
be_pending
end
context
'when the parent pipeline has subsequent jobs after the bridge'
do
let!
(
:after_bridge_job
)
{
create
(
:ci_build
,
:skipped
,
pipeline:
parent_pipeline
,
stage_idx:
bridge
.
stage_idx
+
1
)
}
it
'does not touch subsequent jobs of the bridge'
do
reset_bridge
expect
(
after_bridge_job
.
reload
).
to
be_skipped
end
end
context
'when the parent pipeline has a dependent upstream pipeline'
do
let!
(
:upstream_bridge
)
do
create_bridge
(
create
(
:ci_pipeline
,
project:
create
(
:project
)),
parent_pipeline
,
true
)
end
it
'marks all source bridges as pending'
do
reset_bridge
expect
(
bridge
.
reload
).
to
be_pending
expect
(
upstream_bridge
.
reload
).
to
be_pending
end
end
end
end
context
'when the pipeline is a child pipeline and the bridge is depended'
do
let!
(
:parent_pipeline
)
{
create
(
:ci_pipeline
)
}
let!
(
:bridge
)
{
create_bridge
(
parent_pipeline
,
pipeline
,
true
)
}
it
'marks source bridge as pending'
do
pipeline
.
reset_ancestor_bridges!
reset_bridge
expect
(
bridge
.
reload
).
to
be_pending
end
context
'when the parent pipeline has subsequent jobs after the bridge'
do
let!
(
:after_bridge_job
)
{
create
(
:ci_build
,
:skipped
,
pipeline:
parent_pipeline
,
stage_idx:
bridge
.
stage_idx
+
1
)
}
it
'marks subsequent jobs of the bridge as processable'
do
reset_bridge
expect
(
after_bridge_job
.
reload
).
to
be_created
end
end
context
'when the parent pipeline has a dependent upstream pipeline'
do
let!
(
:upstream_bridge
)
do
create_bridge
(
create
(
:ci_pipeline
,
project:
create
(
:project
)),
parent_pipeline
,
true
)
end
it
'marks all source bridges as pending'
do
pipeline
.
reset_ancestor_bridges!
reset_bridge
expect
(
bridge
.
reload
).
to
be_pending
expect
(
upstream_bridge
.
reload
).
to
be_pending
...
...
@@ -4335,7 +4389,7 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
let!
(
:bridge
)
{
create_bridge
(
parent_pipeline
,
pipeline
,
false
)
}
it
'does not touch source bridge'
do
pipeline
.
reset_ancestor_bridges!
reset_bridge
expect
(
bridge
.
reload
).
to
be_success
end
...
...
@@ -4346,7 +4400,7 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
end
it
'does not touch any source bridge'
do
pipeline
.
reset_ancestor_bridges!
reset_bridge
expect
(
bridge
.
reload
).
to
be_success
expect
(
upstream_bridge
.
reload
).
to
be_success
...
...
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