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
b336b2f4
Commit
b336b2f4
authored
Jun 29, 2020
by
Amy Troschinetz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Follow-up on cancel review app deployments MR
parent
df90c6e4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
2 deletions
+21
-2
app/models/environment.rb
app/models/environment.rb
+12
-2
changelogs/unreleased/merge-cancel-deploy-followup.yml
changelogs/unreleased/merge-cancel-deploy-followup.yml
+5
-0
spec/services/merge_requests/post_merge_service_spec.rb
spec/services/merge_requests/post_merge_service_spec.rb
+4
-0
No files found.
app/models/environment.rb
View file @
b336b2f4
...
...
@@ -228,8 +228,18 @@ class Environment < ApplicationRecord
end
def
cancel_deployment_jobs!
jobs
=
all_deployments
.
active
.
with_deployable
jobs
.
each
{
|
deployment
|
deployment
.
deployable
.
cancel!
}
jobs
=
active_deployments
.
with_deployable
jobs
.
each
do
|
deployment
|
# guard against data integrity issues,
# for example https://gitlab.com/gitlab-org/gitlab/-/issues/218659#note_348823660
next
unless
deployment
.
deployable
Gitlab
::
OptimisticLocking
.
retry_lock
(
deployment
.
deployable
)
do
|
deployable
|
deployable
.
cancel!
if
deployable
&
.
cancelable?
end
rescue
=>
e
Gitlab
::
ErrorTracking
.
track_exception
(
e
,
environment_id:
id
,
deployment_id:
deployment
.
id
)
end
end
def
stop_with_action!
(
current_user
)
...
...
changelogs/unreleased/merge-cancel-deploy-followup.yml
0 → 100644
View file @
b336b2f4
---
title
:
Guard against data integrity issues when canceling review app jobs
merge_request
:
35555
author
:
type
:
fixed
spec/services/merge_requests/post_merge_service_spec.rb
View file @
b336b2f4
...
...
@@ -90,6 +90,8 @@ RSpec.describe MergeRequests::PostMergeService do
pipeline:
pipeline
,
project:
project
,
environment:
review_env_a
.
name
)
review_job_a2
=
create
(
:ci_build
,
:with_deployment
,
:start_review_app
,
pipeline:
pipeline
,
project:
project
,
environment:
review_env_a
.
name
)
finished_review_job_a
=
create
(
:ci_build
,
:with_deployment
,
:start_review_app
,
pipeline:
pipeline
,
project:
project
,
status: :success
,
environment:
review_env_a
.
name
)
review_job_b1
=
create
(
:ci_build
,
:with_deployment
,
:start_review_app
,
pipeline:
pipeline
,
project:
project
,
environment:
review_env_b
.
name
)
review_job_b2
=
create
(
:ci_build
,
:start_review_app
,
...
...
@@ -103,6 +105,8 @@ RSpec.describe MergeRequests::PostMergeService do
expect
(
review_job_a1
.
reload
.
canceled?
).
to
be
true
expect
(
review_job_a2
.
reload
.
canceled?
).
to
be
true
expect
(
finished_review_job_a
.
reload
.
status
).
to
eq
"success"
expect
(
finished_review_job_a
.
reload
.
canceled?
).
to
be
false
expect
(
review_job_b1
.
reload
.
canceled?
).
to
be
true
expect
(
review_job_b2
.
reload
.
canceled?
).
to
be
false
expect
(
review_job_c1
.
reload
.
canceled?
).
to
be
false
...
...
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