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
1553ea1b
Commit
1553ea1b
authored
Aug 26, 2021
by
Furkan Ayhan
Committed by
Fabio Pitino
Aug 26, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix stuck bridge jobs when downstream project is invalid
parent
fff7ebeb
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
14 deletions
+49
-14
app/models/ci/bridge.rb
app/models/ci/bridge.rb
+10
-8
ee/spec/models/ci/bridge_spec.rb
ee/spec/models/ci/bridge_spec.rb
+2
-2
spec/models/ci/bridge_spec.rb
spec/models/ci/bridge_spec.rb
+4
-4
spec/services/ci/pipeline_processing/shared_processing_service.rb
...vices/ci/pipeline_processing/shared_processing_service.rb
+33
-0
No files found.
app/models/ci/bridge.rb
View file @
1553ea1b
...
...
@@ -28,10 +28,10 @@ module Ci
state_machine
:status
do
after_transition
[
:created
,
:manual
,
:waiting_for_resource
]
=>
:pending
do
|
bridge
|
next
unless
bridge
.
downstream_project
next
unless
bridge
.
triggers_downstream_pipeline?
bridge
.
run_after_commit
do
bridge
.
schedule_downstream_pipeline!
::
Ci
::
CreateCrossProjectPipelineWorker
.
perform_async
(
bridge
.
id
)
end
end
...
...
@@ -64,12 +64,6 @@ module Ci
)
end
def
schedule_downstream_pipeline!
raise
InvalidBridgeTypeError
unless
downstream_project
::
Ci
::
CreateCrossProjectPipelineWorker
.
perform_async
(
self
.
id
)
end
def
inherit_status_from_downstream!
(
pipeline
)
case
pipeline
.
status
when
'success'
...
...
@@ -112,10 +106,18 @@ module Ci
pipeline
if
triggers_child_pipeline?
end
def
triggers_downstream_pipeline?
triggers_child_pipeline?
||
triggers_cross_project_pipeline?
end
def
triggers_child_pipeline?
yaml_for_downstream
.
present?
end
def
triggers_cross_project_pipeline?
downstream_project_path
.
present?
end
def
tags
[
:bridge
]
end
...
...
ee/spec/models/ci/bridge_spec.rb
View file @
1553ea1b
...
...
@@ -42,9 +42,9 @@ RSpec.describe Ci::Bridge do
end
it
'does not schedule downstream pipeline creation'
do
expect
(
bridge
).
not_to
receive
(
:schedule_downstream_pipeline!
)
bridge
.
enqueue!
expect
(
::
Ci
::
CreateCrossProjectPipelineWorker
.
jobs
).
to
be_empty
end
end
end
...
...
spec/models/ci/bridge_spec.rb
View file @
1553ea1b
...
...
@@ -74,18 +74,18 @@ RSpec.describe Ci::Bridge do
it
"schedules downstream pipeline creation when the status is
#{
status
}
"
do
bridge
.
status
=
status
expect
(
bridge
).
to
receive
(
:schedule_downstream_pipeline!
)
bridge
.
enqueue!
expect
(
::
Ci
::
CreateCrossProjectPipelineWorker
.
jobs
.
last
[
'args'
]).
to
eq
([
bridge
.
id
])
end
end
it
"schedules downstream pipeline creation when the status is waiting for resource"
do
bridge
.
status
=
:waiting_for_resource
expect
(
bridge
).
to
receive
(
:schedule_downstream_pipeline!
)
bridge
.
enqueue_waiting_for_resource!
expect
(
::
Ci
::
CreateCrossProjectPipelineWorker
.
jobs
.
last
[
'args'
]).
to
eq
([
bridge
.
id
])
end
it
'raises error when the status is failed'
do
...
...
spec/services/ci/pipeline_processing/shared_processing_service.rb
View file @
1553ea1b
...
...
@@ -908,6 +908,39 @@ RSpec.shared_examples 'Pipeline Processing Service' do
end
end
context
'when a bridge job has invalid downstream project'
,
:sidekiq_inline
do
let
(
:config
)
do
<<-
EOY
test:
stage: test
script: echo test
deploy:
stage: deploy
trigger:
project: invalid-project
EOY
end
let
(
:pipeline
)
do
Ci
::
CreatePipelineService
.
new
(
project
,
user
,
{
ref:
'master'
}).
execute
(
:push
).
payload
end
before
do
stub_ci_pipeline_yaml_file
(
config
)
end
it
'creates a pipeline, then fails the bridge job'
do
expect
(
all_builds_names
).
to
contain_exactly
(
'test'
,
'deploy'
)
expect
(
all_builds_statuses
).
to
contain_exactly
(
'pending'
,
'created'
)
succeed_pending
expect
(
all_builds_names
).
to
contain_exactly
(
'test'
,
'deploy'
)
expect
(
all_builds_statuses
).
to
contain_exactly
(
'success'
,
'failed'
)
end
end
private
def
all_builds
...
...
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