Commit 85920e7c authored by Stan Hu's avatar Stan Hu

Fix import of LFS files in GitHub import

https://gitlab.com/gitlab-org/gitlab/-/merge_requests/48512 may have
exposed a bug in GitHub LFS import that caused LFS objects to be
downloaded sequentially via `LfsImportService` rather than in
parallel. Instead of returning individual `LfsObject` objects, the
service would import all files and return a Hash indicating success or
failure. This error was caught by an exception handler with the message:

```
undefined method `oid' for [:status, :success]:Array
```

This caught exception prevented the failure from stalling out the
importer process. We may want to reintroduce that behavior.

Relates to https://gitlab.com/gitlab-org/gitlab/-/issues/289669
parent fe826fc3
---
title: Fix import of LFS files in GitHub import
merge_request: 48722
author:
type: fixed
...@@ -23,7 +23,7 @@ module Gitlab ...@@ -23,7 +23,7 @@ module Gitlab
end end
def each_object_to_import def each_object_to_import
lfs_objects = Projects::LfsPointers::LfsImportService.new(project).execute lfs_objects = Projects::LfsPointers::LfsObjectDownloadListService.new(project).execute
lfs_objects.each do |object| lfs_objects.each do |object|
yield object yield object
......
...@@ -56,9 +56,9 @@ RSpec.describe Gitlab::GithubImport::Importer::LfsObjectsImporter do ...@@ -56,9 +56,9 @@ RSpec.describe Gitlab::GithubImport::Importer::LfsObjectsImporter do
importer = described_class.new(project, client, parallel: false) importer = described_class.new(project, client, parallel: false)
lfs_object_importer = double(:lfs_object_importer) lfs_object_importer = double(:lfs_object_importer)
allow(importer) expect_next_instance_of(Projects::LfsPointers::LfsObjectDownloadListService) do |service|
.to receive(:each_object_to_import) expect(service).to receive(:execute).and_return([lfs_download_object])
.and_yield(lfs_download_object) end
expect(Gitlab::GithubImport::Importer::LfsObjectImporter) expect(Gitlab::GithubImport::Importer::LfsObjectImporter)
.to receive(:new) .to receive(:new)
...@@ -79,9 +79,9 @@ RSpec.describe Gitlab::GithubImport::Importer::LfsObjectsImporter do ...@@ -79,9 +79,9 @@ RSpec.describe Gitlab::GithubImport::Importer::LfsObjectsImporter do
it 'imports each lfs object in parallel' do it 'imports each lfs object in parallel' do
importer = described_class.new(project, client) importer = described_class.new(project, client)
allow(importer) expect_next_instance_of(Projects::LfsPointers::LfsObjectDownloadListService) do |service|
.to receive(:each_object_to_import) expect(service).to receive(:execute).and_return([lfs_download_object])
.and_yield(lfs_download_object) end
expect(Gitlab::GithubImport::ImportLfsObjectWorker) expect(Gitlab::GithubImport::ImportLfsObjectWorker)
.to receive(:perform_async) .to receive(:perform_async)
......
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