Commit 1e4b9310 authored by Nick Thomas's avatar Nick Thomas

Merge branch 'sh-respect-retry-date-artifacts' into 'master'

Geo: Respect retry_at when downloading artifacts

Closes #5560

See merge request gitlab-org/gitlab-ee!5239
parents 86a21892 0e4cb898
...@@ -79,7 +79,7 @@ module Geo ...@@ -79,7 +79,7 @@ module Geo
end end
def find_failed_artifact_ids(batch_size:) def find_failed_artifact_ids(batch_size:)
job_artifacts_finder.find_failed_job_artifacts_registries.limit(batch_size) job_artifacts_finder.find_failed_job_artifacts_registries.retry_due.limit(batch_size)
.pluck(:artifact_id).map { |id| [:job_artifact, id] } .pluck(:artifact_id).map { |id| [:job_artifact, id] }
end end
......
...@@ -103,6 +103,22 @@ describe Geo::FileDownloadDispatchWorker, :geo do ...@@ -103,6 +103,22 @@ describe Geo::FileDownloadDispatchWorker, :geo do
subject.perform subject.perform
end end
it 'does not retry failed artifacts when retry_at is tomorrow' do
failed_registry = create(:geo_job_artifact_registry, :with_artifact, bytes: 0, success: false, retry_at: Date.tomorrow)
expect(Geo::FileDownloadWorker).not_to receive(:perform_async).with(:job_artifact, failed_registry.artifact_id)
subject.perform
end
it 'retries failed artifacts when retry_at is in the past' do
failed_registry = create(:geo_job_artifact_registry, :with_artifact, success: false, retry_at: Date.yesterday)
expect(Geo::FileDownloadWorker).to receive(:perform_async).with(:job_artifact, failed_registry.artifact_id)
subject.perform
end
end end
# Test the case where we have: # Test the case where we have:
...@@ -156,7 +172,7 @@ describe Geo::FileDownloadDispatchWorker, :geo do ...@@ -156,7 +172,7 @@ describe Geo::FileDownloadDispatchWorker, :geo do
subject.perform subject.perform
end end
it 'does not retries failed files when retry_at is tomorrow' do it 'does not retry failed files when retry_at is tomorrow' do
failed_registry = create(:geo_file_registry, :lfs, file_id: 999, success: false, retry_at: Date.tomorrow) failed_registry = create(:geo_file_registry, :lfs, file_id: 999, success: false, retry_at: Date.tomorrow)
expect(Geo::FileDownloadWorker).not_to receive(:perform_async).with('lfs', failed_registry.file_id) expect(Geo::FileDownloadWorker).not_to receive(:perform_async).with('lfs', failed_registry.file_id)
...@@ -164,7 +180,7 @@ describe Geo::FileDownloadDispatchWorker, :geo do ...@@ -164,7 +180,7 @@ describe Geo::FileDownloadDispatchWorker, :geo do
subject.perform subject.perform
end end
it 'does not retries failed files when retry_at is in the past' do it 'retries failed files when retry_at is in the past' do
failed_registry = create(:geo_file_registry, :lfs, file_id: 999, success: false, retry_at: Date.yesterday) failed_registry = create(:geo_file_registry, :lfs, file_id: 999, success: false, retry_at: Date.yesterday)
expect(Geo::FileDownloadWorker).to receive(:perform_async).with('lfs', failed_registry.file_id) expect(Geo::FileDownloadWorker).to receive(:perform_async).with('lfs', failed_registry.file_id)
......
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