Commit 227e70b9 authored by Stan Hu's avatar Stan Hu

Log exceptions in Lfs::PushService

This would help provide some visibility in silent failures in pushing
LFS files to remote mirrors. However, it might create some noise for
repositories with invalid credentials.

Relates to https://gitlab.com/gitlab-org/gitlab/-/issues/328675

Changelog: changed
parent 29e7ec58
...@@ -17,11 +17,16 @@ module Lfs ...@@ -17,11 +17,16 @@ module Lfs
success success
rescue => err rescue => err
Gitlab::ErrorTracking.log_exception(err, extra_context)
error(err.message) error(err.message)
end end
private private
def extra_context
{ project_id: project.id, user_id: current_user&.id }.compact
end
# Currently we only set repository_type for design repository objects, so # Currently we only set repository_type for design repository objects, so
# push mirroring must send objects with a `nil` repository type - but if the # push mirroring must send objects with a `nil` repository type - but if the
# wiki repository uses LFS, its objects will also be sent. This will be # wiki repository uses LFS, its objects will also be sent. This will be
......
---
title: Log exceptions in Lfs::PushService
merge_request: 59960
author:
type: changed
...@@ -63,6 +63,7 @@ RSpec.describe Lfs::PushService do ...@@ -63,6 +63,7 @@ RSpec.describe Lfs::PushService do
it 'returns a failure when submitting a batch fails' do it 'returns a failure when submitting a batch fails' do
expect(lfs_client).to receive(:batch!) { raise 'failed' } expect(lfs_client).to receive(:batch!) { raise 'failed' }
expect(Gitlab::ErrorTracking).to receive(:log_exception).and_call_original
expect(service.execute).to eq(status: :error, message: 'failed') expect(service.execute).to eq(status: :error, message: 'failed')
end end
...@@ -70,6 +71,7 @@ RSpec.describe Lfs::PushService do ...@@ -70,6 +71,7 @@ RSpec.describe Lfs::PushService do
stub_lfs_batch(lfs_object) stub_lfs_batch(lfs_object)
expect(lfs_client).to receive(:upload!) { raise 'failed' } expect(lfs_client).to receive(:upload!) { raise 'failed' }
expect(Gitlab::ErrorTracking).to receive(:log_exception).and_call_original
expect(service.execute).to eq(status: :error, message: 'failed') expect(service.execute).to eq(status: :error, message: 'failed')
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment