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
84adfb20
Commit
84adfb20
authored
Jan 05, 2021
by
David Fernandez
Committed by
Lin Jen-Shin
Jan 05, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add error handling in Gitlab DeleteTagsService
Properly translate any error into a service error response
parent
8467c199
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
5 deletions
+25
-5
app/services/projects/container_repository/gitlab/delete_tags_service.rb
...ojects/container_repository/gitlab/delete_tags_service.rb
+2
-2
changelogs/unreleased/288812-properly-catch-tags-delete-errors-and-mark-repository-as-cleanup-u.yml
...h-tags-delete-errors-and-mark-repository-as-cleanup-u.yml
+5
-0
spec/services/projects/container_repository/delete_tags_service_spec.rb
...projects/container_repository/delete_tags_service_spec.rb
+2
-2
spec/services/projects/container_repository/gitlab/delete_tags_service_spec.rb
...s/container_repository/gitlab/delete_tags_service_spec.rb
+16
-1
No files found.
app/services/projects/container_repository/gitlab/delete_tags_service.rb
View file @
84adfb20
...
...
@@ -24,9 +24,9 @@ module Projects
return
success
(
deleted:
[])
if
@tag_names
.
empty?
delete_tags
rescue
TimeoutError
=>
e
rescue
=>
e
::
Gitlab
::
ErrorTracking
.
track_exception
(
e
,
tags_count:
@tag_names
&
.
size
,
container_repository_id:
@container_repository
&
.
id
)
error
(
'
timeout while deleting tags'
,
nil
,
pass_back:
{
deleted:
@deleted_tags
})
error
(
'
error while deleting tags'
,
nil
,
pass_back:
{
deleted:
@deleted_tags
,
exception_class_name:
e
.
class
.
name
})
end
private
...
...
changelogs/unreleased/288812-properly-catch-tags-delete-errors-and-mark-repository-as-cleanup-u.yml
0 → 100644
View file @
84adfb20
---
title
:
Add error handling in the container registry delete tags service
merge_request
:
50763
author
:
type
:
changed
spec/services/projects/container_repository/delete_tags_service_spec.rb
View file @
84adfb20
...
...
@@ -119,9 +119,9 @@ RSpec.describe Projects::ContainerRepository::DeleteTagsService do
end
end
it
{
is_expected
.
to
include
(
status: :error
,
message:
'
timeout
while deleting tags'
)
}
it
{
is_expected
.
to
include
(
status: :error
,
message:
'
error
while deleting tags'
)
}
it_behaves_like
'logging an error response'
,
message:
'
timeout
while deleting tags'
,
extra_log:
{
deleted_tags_count:
0
}
it_behaves_like
'logging an error response'
,
message:
'
error
while deleting tags'
,
extra_log:
{
deleted_tags_count:
0
}
end
end
end
...
...
spec/services/projects/container_repository/gitlab/delete_tags_service_spec.rb
View file @
84adfb20
...
...
@@ -67,7 +67,7 @@ RSpec.describe Projects::ContainerRepository::Gitlab::DeleteTagsService do
stub_delete_reference_requests
(
'A'
=>
200
)
end
it
{
is_expected
.
to
eq
(
status: :error
,
message:
'
timeout while deleting tags'
,
deleted:
[
'A'
]
)
}
it
{
is_expected
.
to
eq
(
status: :error
,
message:
'
error while deleting tags'
,
deleted:
[
'A'
],
exception_class_name:
Projects
::
ContainerRepository
::
Gitlab
::
DeleteTagsService
::
TimeoutError
.
name
)
}
it
'tracks the exception'
do
expect
(
::
Gitlab
::
ErrorTracking
)
...
...
@@ -89,6 +89,21 @@ RSpec.describe Projects::ContainerRepository::Gitlab::DeleteTagsService do
it_behaves_like
'deleting tags'
end
end
context
'with a network error'
do
before
do
expect
(
service
).
to
receive
(
:delete_tags
).
and_raise
(
::
Faraday
::
TimeoutError
)
end
it
{
is_expected
.
to
eq
(
status: :error
,
message:
'error while deleting tags'
,
deleted:
[],
exception_class_name:
::
Faraday
::
TimeoutError
.
name
)
}
it
'tracks the exception'
do
expect
(
::
Gitlab
::
ErrorTracking
)
.
to
receive
(
:track_exception
).
with
(
::
Faraday
::
TimeoutError
,
tags_count:
tags
.
size
,
container_repository_id:
repository
.
id
)
subject
end
end
end
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