Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix blobstore errors for droplets from CF Docker apps #2588

Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/cloud_controller/bits_expiration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def expire_droplets!(app)

droplets_to_expire.each do |droplet|
droplet.update(state: DropletModel::EXPIRED_STATE)
enqueue_droplet_delete_job(droplet.guid)
enqueue_droplet_delete_job(droplet.guid) if droplet.droplet_hash
end
end

Expand Down
11 changes: 2 additions & 9 deletions spec/unit/jobs/runtime/expired_blob_cleanup_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,14 @@ module Jobs::Runtime

describe 'droplets' do
context 'expired' do
let!(:expired_droplet) { DropletModel.make(state: DropletModel::EXPIRED_STATE) }
philippthun marked this conversation as resolved.
Show resolved Hide resolved
let!(:expired_droplet) { DropletModel.make(state: DropletModel::EXPIRED_STATE, droplet_hash: 'not-nil', docker_receipt_image: nil) }
DropletModel.make(state: DropletModel::EXPIRED_STATE, droplet_hash: nil, docker_receipt_image: 'repo/test-app')
let!(:non_expired_droplet) { DropletModel.make }

it 'enqueues a deletion job when droplet_hash is not nil' do
expired_droplet.update(droplet_hash: 'not-nil')

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

it 'does nothing when droplet_hash is nil' do
expired_droplet.update(droplet_hash: nil)

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

context 'failed' do
Expand Down
30 changes: 29 additions & 1 deletion spec/unit/lib/cloud_controller/bits_expiration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,47 @@ module VCAP::CloudController
end
end

context 'with docker cf apps' do
before do
t = Time.now
@current = DropletModel.make(
app_guid: app.guid,
created_at: t,
droplet_hash: nil,
docker_receipt_image: 'repo/test-app',
)
app.update(droplet: @current)

10.times do |i|
DropletModel.make(
app_guid: app.guid,
created_at: t + i,
droplet_hash: nil,
docker_receipt_image: 'repo/test-app',
)
end
end

it 'does not enqueue a job to delete the blob' do
expect { BitsExpiration.new.expire_droplets!(app) }.not_to change { Delayed::Job.count }
end
end

context 'with droplets' do
before do
t = Time.now
@current = DropletModel.make(
app_guid: app.guid,
created_at: t
created_at: t,
droplet_hash: 'current_droplet_hash',
)
app.update(droplet: @current)

10.times do |i|
DropletModel.make(
app_guid: app.guid,
created_at: t + i,
droplet_hash: 'current_droplet_hash',
)
end
end
Expand Down