Skip to content

Commit

Permalink
Clean up expired package blobs on k8s
Browse files Browse the repository at this point in the history
We will never have a package_hash (sha1 checksum) when using a package
registry, but will have a sha256 checksum. We don't expect this change
to negatively effect "legacy" configurations.

[#175080280]

Co-authored-by: Matt Royal <[email protected]>
Co-authored-by: Tim Downey <[email protected]>
  • Loading branch information
matt-royal and tcdowney committed Oct 8, 2020
1 parent caa24ca commit 32f1466
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/jobs/runtime/expired_blob_cleanup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def perform
enqueue_droplet_delete_job(droplet.guid)
end

PackageModel.where(state: PackageModel::EXPIRED_STATE).exclude(package_hash: nil).each do |package|
PackageModel.where(state: PackageModel::EXPIRED_STATE).exclude(package_hash: nil, sha256_checksum: '').each do |package|
enqueue_package_delete_job(package.guid)
end
end
Expand Down
9 changes: 8 additions & 1 deletion spec/unit/jobs/runtime/expired_blob_cleanup_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,16 @@ module Jobs::Runtime
expect(Delayed::Job.last.handler).to include('DeleteExpiredPackageBlob')
end

it 'does nothing when package_hash is nil' do
it 'enqueues a deletion job when only package_hash is nil' do
expired_package.update(package_hash: nil)

expect { job.perform }.to change { Delayed::Job.count }.by(1)
expect(Delayed::Job.last.handler).to include('DeleteExpiredPackageBlob')
end

it 'does nothing when both package_hash and sha256_checksum are blank' do
expired_package.update(package_hash: nil, sha256_checksum: '')

expect { job.perform }.not_to change { Delayed::Job.count }.from(0)
end
end
Expand Down

0 comments on commit 32f1466

Please sign in to comment.