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
aa43c1a1
Commit
aa43c1a1
authored
Sep 20, 2018
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'upstream/master' into ce-to-ee-2018-09-20
parents
8fd04fe7
e7df8070
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
24 additions
and
7 deletions
+24
-7
app/models/container_repository.rb
app/models/container_repository.rb
+0
-2
app/services/projects/container_repository/destroy_service.rb
...services/projects/container_repository/destroy_service.rb
+2
-0
app/services/projects/destroy_service.rb
app/services/projects/destroy_service.rb
+15
-4
changelogs/unreleased/sh-delete-tags-outside-transaction.yml
changelogs/unreleased/sh-delete-tags-outside-transaction.yml
+5
-0
spec/services/projects/container_repository/destroy_service_spec.rb
...ces/projects/container_repository/destroy_service_spec.rb
+1
-0
spec/services/projects/destroy_service_spec.rb
spec/services/projects/destroy_service_spec.rb
+1
-1
No files found.
app/models/container_repository.rb
View file @
aa43c1a1
...
...
@@ -8,8 +8,6 @@ class ContainerRepository < ActiveRecord::Base
delegate
:client
,
to: :registry
before_destroy
:delete_tags!
# rubocop: disable CodeReuse/ServiceClass
def
registry
@registry
||=
begin
...
...
app/services/projects/container_repository/destroy_service.rb
View file @
aa43c1a1
...
...
@@ -6,6 +6,8 @@ module Projects
def
execute
(
container_repository
)
return
false
unless
can?
(
current_user
,
:update_container_image
,
project
)
# Delete tags outside of the transaction to avoid hitting an idle-in-transaction timeout
container_repository
.
delete_tags!
container_repository
.
destroy
end
end
...
...
app/services/projects/destroy_service.rb
View file @
aa43c1a1
...
...
@@ -134,11 +134,11 @@ module Projects
end
def
attempt_destroy_transaction
(
project
)
Project
.
transaction
do
unless
remove_legacy_registry_tags
raise_error
(
'Failed to remove some tags in project container registry. Please try again or contact administrator.'
)
end
unless
remove_registry_tags
raise_error
(
'Failed to remove some tags in project container registry. Please try again or contact administrator.'
)
end
Project
.
transaction
do
log_destroy_event
trash_repositories!
...
...
@@ -157,6 +157,17 @@ module Projects
log_info
(
"Attempting to destroy
#{
project
.
full_path
}
(
#{
project
.
id
}
)"
)
end
def
remove_registry_tags
return
false
unless
remove_legacy_registry_tags
project
.
container_repositories
.
find_each
do
|
container_repository
|
service
=
Projects
::
ContainerRepository
::
DestroyService
.
new
(
project
,
current_user
)
service
.
execute
(
container_repository
)
end
true
end
##
# This method makes sure that we correctly remove registry tags
# for legacy image repository (when repository path equals project path).
...
...
changelogs/unreleased/sh-delete-tags-outside-transaction.yml
0 → 100644
View file @
aa43c1a1
---
title
:
Delete container repository tags outside of transaction
merge_request
:
21679
author
:
type
:
fixed
spec/services/projects/container_repository/destroy_service_spec.rb
View file @
aa43c1a1
...
...
@@ -33,6 +33,7 @@ describe Projects::ContainerRepository::DestroyService do
end
it
'deletes the repository'
do
expect
(
repository
).
to
receive
(
:delete_tags!
).
and_call_original
expect
{
described_class
.
new
(
project
,
user
).
execute
(
repository
)
}.
to
change
{
ContainerRepository
.
all
.
count
}.
by
(
-
1
)
end
end
...
...
spec/services/projects/destroy_service_spec.rb
View file @
aa43c1a1
...
...
@@ -204,7 +204,7 @@ describe Projects::DestroyService do
context
'when image repository deletion fails'
do
it
'raises an exception'
do
expect_any_instance_of
(
ContainerRepository
)
.
to
receive
(
:delete_tags!
).
and_r
eturn
(
false
)
.
to
receive
(
:delete_tags!
).
and_r
aise
(
RuntimeError
)
expect
(
destroy_project
(
project
,
user
)).
to
be
false
end
...
...
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