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
7f637e2a
Commit
7f637e2a
authored
May 22, 2019
by
Francisco Javier López
Committed by
Nick Thomas
May 22, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid failing pull mirroring if LFS import fails
parent
a492f341
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
59 additions
and
5 deletions
+59
-5
ee/app/services/projects/update_mirror_service.rb
ee/app/services/projects/update_mirror_service.rb
+21
-1
ee/changelogs/unreleased/fj-61834-log-lfs-error-pull-mirror.yml
...ngelogs/unreleased/fj-61834-log-lfs-error-pull-mirror.yml
+5
-0
ee/lib/gitlab/update_mirror_service_json_logger.rb
ee/lib/gitlab/update_mirror_service_json_logger.rb
+9
-0
ee/spec/services/projects/update_mirror_service_spec.rb
ee/spec/services/projects/update_mirror_service_spec.rb
+24
-4
No files found.
ee/app/services/projects/update_mirror_service.rb
View file @
7f637e2a
...
@@ -98,7 +98,11 @@ module Projects
...
@@ -98,7 +98,11 @@ module Projects
def
update_lfs_objects
def
update_lfs_objects
result
=
Projects
::
LfsPointers
::
LfsImportService
.
new
(
project
).
execute
result
=
Projects
::
LfsPointers
::
LfsImportService
.
new
(
project
).
execute
raise
UpdateError
,
result
[
:message
]
if
result
[
:status
]
==
:error
if
result
[
:status
]
==
:error
log_error
(
result
[
:message
])
# Uncomment once https://gitlab.com/gitlab-org/gitlab-ce/issues/61834 is closed
# raise UpdateError, result[:message]
end
end
end
def
handle_diverged_branch
(
upstream
,
local
,
branch_name
,
errors
)
def
handle_diverged_branch
(
upstream
,
local
,
branch_name
,
errors
)
...
@@ -127,5 +131,21 @@ module Projects
...
@@ -127,5 +131,21 @@ module Projects
def
skip_branch?
(
name
)
def
skip_branch?
(
name
)
project
.
only_mirror_protected_branches
&&
!
ProtectedBranch
.
protected?
(
project
,
name
)
project
.
only_mirror_protected_branches
&&
!
ProtectedBranch
.
protected?
(
project
,
name
)
end
end
def
service_logger
@service_logger
||=
Gitlab
::
UpdateMirrorServiceJsonLogger
.
build
end
def
base_payload
{
user_id:
current_user
.
id
,
project_id:
project
.
id
,
import_url:
project
.
safe_import_url
}
end
def
log_error
(
error_message
)
service_logger
.
error
(
base_payload
.
merge
(
error_message:
error_message
))
end
end
end
end
end
ee/changelogs/unreleased/fj-61834-log-lfs-error-pull-mirror.yml
0 → 100644
View file @
7f637e2a
---
title
:
Avoid failing pull mirroring if LFS import fails
merge_request
:
13133
author
:
type
:
changed
ee/lib/gitlab/update_mirror_service_json_logger.rb
0 → 100644
View file @
7f637e2a
# frozen_string_literal: true
module
Gitlab
class
UpdateMirrorServiceJsonLogger
<
Gitlab
::
JsonLogger
def
self
.
file_name_noext
'update_mirror_service_json'
end
end
end
ee/spec/services/projects/update_mirror_service_spec.rb
View file @
7f637e2a
...
@@ -295,13 +295,33 @@ describe Projects::UpdateMirrorService do
...
@@ -295,13 +295,33 @@ describe Projects::UpdateMirrorService do
end
end
context
'when Lfs import fails'
do
context
'when Lfs import fails'
do
it
'the mirror operation fails'
do
let
(
:error_message
)
{
'error_message'
}
expect_any_instance_of
(
Projects
::
LfsPointers
::
LfsImportService
).
to
receive
(
:execute
).
and_return
(
status: :error
,
message:
'error message'
)
before
do
expect_any_instance_of
(
Projects
::
LfsPointers
::
LfsImportService
).
to
receive
(
:execute
).
and_return
(
status: :error
,
message:
error_message
)
end
# Uncomment once https://gitlab.com/gitlab-org/gitlab-ce/issues/61834 is closed
# it 'fails mirror operation' do
# expect_any_instance_of(Projects::LfsPointers::LfsImportService).to receive(:execute).and_return(status: :error, message: 'error message')
# result = subject.execute
# expect(result[:status]).to eq :error
# expect(result[:message]).to eq 'error message'
# end
# Remove once https://gitlab.com/gitlab-org/gitlab-ce/issues/61834 is closed
it
'does not fail mirror operation'
do
result
=
subject
.
execute
result
=
subject
.
execute
expect
(
result
[
:status
]).
to
eq
:error
expect
(
result
[
:status
]).
to
eq
:success
expect
(
result
[
:message
]).
to
eq
'error message'
end
it
'logs the error'
do
expect_any_instance_of
(
Gitlab
::
UpdateMirrorServiceJsonLogger
).
to
receive
(
:error
).
with
(
hash_including
(
error_message:
error_message
))
subject
.
execute
end
end
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