Skip to content
Snippets Groups Projects
Unverified Commit 2166d684 authored by Maxime Orefice's avatar Maxime Orefice
Browse files

Remove unused artifact worker

This commit removes a worker used to remove artifacts for
a given job. Prefer using ExpireBuildArtifactsWorker which
is more performant.
parent eb924a21
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -773,7 +773,6 @@ Gitlab/NamespacedClass:
- 'app/workers/emails_on_push_worker.rb'
- 'app/workers/error_tracking_issue_link_worker.rb'
- 'app/workers/expire_build_artifacts_worker.rb'
- 'app/workers/expire_build_instance_artifacts_worker.rb'
- 'app/workers/expire_job_cache_worker.rb'
- 'app/workers/expire_pipeline_cache_worker.rb'
- 'app/workers/export_csv_worker.rb'
Loading
Loading
Loading
Loading
@@ -825,7 +825,6 @@ def artifacts_metadata_entry(path, **options)
end
end
 
# and use that for `ExpireBuildInstanceArtifactsWorker`?
def erase_erasable_artifacts!
job_artifacts.erasable.destroy_all # rubocop: disable Cop/DestroyAll
end
Loading
Loading
Loading
Loading
@@ -2272,15 +2272,6 @@
:weight: 1
:idempotent: true
:tags: []
- :name: expire_build_instance_artifacts
:worker_name: ExpireBuildInstanceArtifactsWorker
:feature_category: :build_artifacts
:has_external_dependencies:
:urgency: :low
:resource_boundary: :unknown
:weight: 1
:idempotent:
:tags: []
- :name: export_csv
:worker_name: ExportCsvWorker
:feature_category: :team_planning
Loading
Loading
# frozen_string_literal: true
class ExpireBuildInstanceArtifactsWorker # rubocop:disable Scalability/IdempotentWorker
include ApplicationWorker
data_consistency :always
sidekiq_options retry: 3
feature_category :build_artifacts
def perform(build_id)
# rubocop: disable CodeReuse/ActiveRecord
build = Ci::Build
.with_expired_artifacts
.reorder(nil)
.find_by_id(build_id)
# rubocop: enable CodeReuse/ActiveRecord
return unless build&.project && !build.project.pending_delete
Gitlab::AppLogger.info("Removing artifacts for build #{build.id}...")
build.erase_erasable_artifacts!
end
end
Loading
Loading
@@ -161,8 +161,6 @@
- 1
- - experiments_record_conversion_event
- 1
- - expire_build_instance_artifacts
- 1
- - export_csv
- 1
- - external_service_reactive_caching
Loading
Loading
Loading
Loading
@@ -227,7 +227,6 @@
'Epics::UpdateEpicsDatesWorker' => 3,
'ErrorTrackingIssueLinkWorker' => 3,
'Experiments::RecordConversionEventWorker' => 3,
'ExpireBuildInstanceArtifactsWorker' => 3,
'ExpireJobCacheWorker' => 3,
'ExpirePipelineCacheWorker' => 3,
'ExportCsvWorker' => 3,
Loading
Loading
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe ExpireBuildInstanceArtifactsWorker do
include RepoHelpers
let(:worker) { described_class.new }
describe '#perform' do
before do
worker.perform(build.id)
end
context 'with expired artifacts' do
context 'when associated project is valid' do
let(:build) { create(:ci_build, :artifacts, :expired) }
it 'does expire' do
expect(build.reload.artifacts_expired?).to be_truthy
end
it 'does remove files' do
expect(build.reload.artifacts_file.present?).to be_falsey
end
it 'does remove the job artifact record' do
expect(build.reload.job_artifacts_archive).to be_nil
end
end
end
context 'with not yet expired artifacts' do
let_it_be(:build) do
create(:ci_build, :artifacts, artifacts_expire_at: Time.current + 7.days)
end
it 'does not expire' do
expect(build.reload.artifacts_expired?).to be_falsey
end
it 'does not remove files' do
expect(build.reload.artifacts_file.present?).to be_truthy
end
it 'does not remove the job artifact record' do
expect(build.reload.job_artifacts_archive).not_to be_nil
end
end
context 'without expire date' do
let(:build) { create(:ci_build, :artifacts) }
it 'does not expire' do
expect(build.reload.artifacts_expired?).to be_falsey
end
it 'does not remove files' do
expect(build.reload.artifacts_file.present?).to be_truthy
end
it 'does not remove the job artifact record' do
expect(build.reload.job_artifacts_archive).not_to be_nil
end
end
context 'for expired artifacts' do
let(:build) { create(:ci_build, :expired) }
it 'is still expired' do
expect(build.reload.artifacts_expired?).to be_truthy
end
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment