Commit eb632e1d authored by Sean McGivern's avatar Sean McGivern

Merge branch '10io-fix-cleanup-container-repository-worker-logs' into 'master'

Fix log statements in cleanup container repository worker

See merge request gitlab-org/gitlab!47060
parents c607f33d a30e2963
...@@ -16,15 +16,16 @@ module ContainerExpirationPolicies ...@@ -16,15 +16,16 @@ module ContainerExpirationPolicies
return unless throttling_enabled? return unless throttling_enabled?
return unless container_repository return unless container_repository
log_extra_metadata_on_done(:container_repository_id, container_repository.id)
unless allowed_to_run?(container_repository) unless allowed_to_run?(container_repository)
container_repository.cleanup_unscheduled! container_repository.cleanup_unscheduled!
log_info(container_repository_id: container_repository.id, cleanup_status: :skipped) log_extra_metadata_on_done(:cleanup_status, :skipped)
return return
end end
result = ContainerExpirationPolicies::CleanupService.new(container_repository) result = ContainerExpirationPolicies::CleanupService.new(container_repository)
.execute .execute
log_extra_metadata_on_done(:container_repository_id, result.payload[:container_repository_id])
log_extra_metadata_on_done(:cleanup_status, result.payload[:cleanup_status]) log_extra_metadata_on_done(:cleanup_status, result.payload[:cleanup_status])
end end
......
...@@ -47,6 +47,8 @@ RSpec.describe ContainerExpirationPolicies::CleanupContainerRepositoryWorker do ...@@ -47,6 +47,8 @@ RSpec.describe ContainerExpirationPolicies::CleanupContainerRepositoryWorker do
it 'skips the repository' do it 'skips the repository' do
expect(ContainerExpirationPolicies::CleanupService).not_to receive(:new) expect(ContainerExpirationPolicies::CleanupService).not_to receive(:new)
expect(worker).to receive(:log_extra_metadata_on_done).with(:container_repository_id, repository.id)
expect(worker).to receive(:log_extra_metadata_on_done).with(:cleanup_status, :skipped)
expect { subject }.to change { ContainerRepository.waiting_for_cleanup.count }.from(1).to(0) expect { subject }.to change { ContainerRepository.waiting_for_cleanup.count }.from(1).to(0)
expect(repository.reload.cleanup_unscheduled?).to be_truthy expect(repository.reload.cleanup_unscheduled?).to be_truthy
......
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