Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion app/models.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
require 'models/runtime/droplet_model'
require 'models/runtime/buildpack_lifecycle_data_model'
require 'models/runtime/buildpack_lifecycle_buildpack_model'
require 'models/runtime/kpack_lifecycle_data_model'
require 'models/runtime/cnb_lifecycle_data_model'
require 'models/runtime/docker_lifecycle_data_model'
require 'models/runtime/task_model'
Expand Down
6 changes: 0 additions & 6 deletions app/models/runtime/app_model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ class AppModel < Sequel::Model(:apps)
key: :app_guid,
primary_key: :guid

one_to_one :kpack_lifecycle_data,
class: 'VCAP::CloudController::KpackLifecycleDataModel',
key: :app_guid,
primary_key: :guid

one_to_one :cnb_lifecycle_data,
class: 'VCAP::CloudController::CNBLifecycleDataModel',
key: :app_guid,
Expand All @@ -66,7 +61,6 @@ class AppModel < Sequel::Model(:apps)
serializes_via_json :environment_variables

add_association_dependencies buildpack_lifecycle_data: :destroy
add_association_dependencies kpack_lifecycle_data: :destroy
add_association_dependencies cnb_lifecycle_data: :destroy
add_association_dependencies labels: :destroy
add_association_dependencies annotations: :destroy
Expand Down
6 changes: 1 addition & 5 deletions app/models/runtime/build_model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ class BuildModel < Sequel::Model(:builds)
class: 'VCAP::CloudController::BuildpackLifecycleDataModel',
key: :build_guid,
primary_key: :guid
one_to_one :kpack_lifecycle_data,
class: 'VCAP::CloudController::KpackLifecycleDataModel',
key: :build_guid,
primary_key: :guid
one_to_one :cnb_lifecycle_data,
class: 'VCAP::CloudController::CNBLifecycleDataModel',
key: :build_guid,
Expand All @@ -49,7 +45,7 @@ class BuildModel < Sequel::Model(:builds)
one_to_many :labels, class: 'VCAP::CloudController::BuildLabelModel', key: :resource_guid, primary_key: :guid
one_to_many :annotations, class: 'VCAP::CloudController::BuildAnnotationModel', key: :resource_guid, primary_key: :guid

add_association_dependencies buildpack_lifecycle_data: :destroy, kpack_lifecycle_data: :destroy, cnb_lifecycle_data: :destroy
add_association_dependencies buildpack_lifecycle_data: :destroy, cnb_lifecycle_data: :destroy

add_association_dependencies labels: :destroy
add_association_dependencies annotations: :destroy
Expand Down
5 changes: 0 additions & 5 deletions app/models/runtime/droplet_model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ class DropletModel < Sequel::Model(:droplets)
class: 'VCAP::CloudController::BuildpackLifecycleDataModel',
key: :droplet_guid,
primary_key: :guid
one_to_one :kpack_lifecycle_data,
class: 'VCAP::CloudController::KpackLifecycleDataModel',
key: :droplet_guid,
primary_key: :guid
one_to_one :cnb_lifecycle_data,
class: 'VCAP::CloudController::CNBLifecycleDataModel',
key: :droplet_guid,
Expand All @@ -45,7 +41,6 @@ class DropletModel < Sequel::Model(:droplets)
one_to_many :annotations, class: 'VCAP::CloudController::DropletAnnotationModel', key: :resource_guid, primary_key: :guid

add_association_dependencies buildpack_lifecycle_data: :destroy
add_association_dependencies kpack_lifecycle_data: :destroy
add_association_dependencies cnb_lifecycle_data: :destroy
add_association_dependencies labels: :destroy
add_association_dependencies annotations: :destroy
Expand Down
54 changes: 0 additions & 54 deletions app/models/runtime/kpack_lifecycle_data_model.rb

This file was deleted.

77 changes: 0 additions & 77 deletions spec/request/builds_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -748,83 +748,6 @@
it_behaves_like 'permissions for single object endpoint', ALL_PERMISSIONS
end
end

context 'updating state' do
let(:build_model) do
VCAP::CloudController::BuildModel.make(:kpack, package: package_model,
state: VCAP::CloudController::BuildModel::STAGING_STATE, app: app_model)
end
let(:request) do
{
state: 'STAGED',
lifecycle: {
type: 'kpack',
data: {
image: 'some-fake-image:tag'
}
}
}
end

it 'allows admins to update the state' do
patch "/v3/builds/#{build_model.guid}", request.to_json, admin_headers
expect(last_response.status).to eq(200), last_response.body
expect(build_model.reload.state).to eq('STAGED')
parsed_response = Oj.load(last_response.body)
expect(parsed_response['state']).to eq('STAGED')
end

context 'when the cloud_controller.update_build_state scope is present' do
context 'when a build was successfully completed' do
it 'updates the state to STAGED' do
patch "/v3/builds/#{build_model.guid}", request.to_json, build_state_updater_headers
parsed_response = Oj.load(last_response.body)
expect(last_response.status).to eq(200)

expect(build_model.reload.state).to eq('STAGED')
expect(parsed_response['state']).to eq('STAGED')
end

it 'creates a droplet with the appropriate image reference' do
patch "/v3/builds/#{build_model.guid}", request.to_json, build_state_updater_headers

expect(build_model.reload.droplet.docker_receipt_image).to eq('some-fake-image:tag')
expect(build_model.reload.droplet.state).to eq('STAGED')
end
end

context 'when a build failed to complete' do
let(:request) do
{
state: 'FAILED',
error: 'failed to stage build'
}
end

it 'returns 200' do
patch "/v3/builds/#{build_model.guid}", request.to_json, build_state_updater_headers
expect(last_response.status).to eq(200), last_response.body
end
end
end

context 'when the cloud_controller.update_build_state scope is NOT present' do
it '403s' do
patch "/v3/builds/#{build_model.guid}", { state: 'STAGED' }.to_json, developer_headers
expect(last_response.status).to eq(403), last_response.body
end
end

context 'when the the developer is looking in the wrong space' do
let(:wrong_developer) { make_developer_for_space(VCAP::CloudController::Space.make) }
let(:wrong_developer_headers) { headers_for(wrong_developer, user_name: user_name, email: 'bob@loblaw.com') }

it '404s' do
patch "/v3/builds/#{build_model.guid}", { state: 'STAGED' }.to_json, wrong_developer_headers
expect(last_response.status).to eq(404), last_response.body
end
end
end
end
end
end
2 changes: 1 addition & 1 deletion spec/request/droplets_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1924,7 +1924,7 @@
let(:rebased_image_reference) { 'rebased-image-reference' }
let!(:og_docker_droplet) do
VCAP::CloudController::DropletModel.make(
:kpack,
:docker,
state: VCAP::CloudController::DropletModel::STAGED_STATE,
app_guid: app_model.guid,
package_guid: package_model.guid,
Expand Down
43 changes: 0 additions & 43 deletions spec/support/fakes/blueprints.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,6 @@ module VCAP::CloudController
buildpack_cache_sha256_checksum { Sham.guid }
end

AppModel.blueprint(:kpack) do
name { Sham.name }
space { Space.make }
buildpack_lifecycle_data { nil.tap { |_| object.save } }
kpack_lifecycle_data { KpackLifecycleDataModel.make(app: object.save) }
end

AppModel.blueprint(:cnb) do
name { Sham.name }
space { Space.make }
Expand Down Expand Up @@ -89,15 +82,6 @@ module VCAP::CloudController
buildpack_lifecycle_data { nil.tap { |_| object.save } }
end

BuildModel.blueprint(:kpack) do
guid { Sham.guid }
state { VCAP::CloudController::DropletModel::STAGING_STATE }
app { AppModel.make(droplet: DropletModel.make) }
kpack_lifecycle_data { KpackLifecycleDataModel.make(build: object.save) }
package { PackageModel.make(app:) }
droplet { DropletModel.make(:docker, build: object.save) }
end

BuildModel.blueprint(:buildpack) do
guid { Sham.guid }
state { VCAP::CloudController::DropletModel::STAGING_STATE }
Expand Down Expand Up @@ -164,7 +148,6 @@ module VCAP::CloudController
app { AppModel.make(:cnb, droplet: object.save) }
cnb_lifecycle_data { CNBLifecycleDataModel.make(droplet: object.save) }
buildpack_lifecycle_data { nil.tap { |_| object.save } }
kpack_lifecycle_data { nil.tap { |_| object.save } }
end

DropletModel.blueprint(:docker) do
Expand All @@ -174,18 +157,6 @@ module VCAP::CloudController
state { VCAP::CloudController::DropletModel::STAGED_STATE }
app { AppModel.make(droplet: object.save) }
buildpack_lifecycle_data { nil.tap { |_| object.save } }
kpack_lifecycle_data { nil.tap { |_| object.save } }
end

DropletModel.blueprint(:kpack) do
guid { Sham.guid }
droplet_hash { nil }
sha256_checksum { nil }
docker_receipt_image { nil }
app { AppModel.make(:kpack, droplet: object.save) }
state { VCAP::CloudController::DropletModel::STAGED_STATE }
buildpack_lifecycle_data { nil.tap { |_| object.save } }
kpack_lifecycle_data { KpackLifecycleDataModel.make(droplet: object.save) }
end

DeploymentModel.blueprint do
Expand Down Expand Up @@ -532,15 +503,6 @@ module VCAP::CloudController
metadata { {} }
end

ProcessModel.blueprint(:kpack) do
app { AppModel.make(:kpack, droplet: DropletModel.make(:kpack)) }
diego { true }
instances { 1 }
type { Sham.name }
metadata { {} }
state { 'STARTED' }
end

ProcessModel.blueprint(:nonmatching_guid) do
instances { 1 }
type { 'web' }
Expand Down Expand Up @@ -710,11 +672,6 @@ module VCAP::CloudController
build { BuildModel.make }
end

KpackLifecycleDataModel.blueprint do
build { BuildModel.make }
buildpacks { [] }
end

BuildpackLifecycleBuildpackModel.blueprint do
admin_buildpack_name { Buildpack.make(name: 'ruby').name }
buildpack_url { nil }
Expand Down
10 changes: 0 additions & 10 deletions spec/unit/actions/build_delete_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,6 @@ module VCAP::CloudController
end.to change(BuildpackLifecycleDataModel, :count).by(-2).and change(BuildpackLifecycleBuildpackModel, :count).by(-2)
[lifecycle_data1, lifecycle_data2, lifecycle_buildpack1, lifecycle_buildpack2].each { |l| expect(l).not_to exist }
end

it 'deletes associated kpack lifecycle data' do
lifecycle1 = KpackLifecycleDataModel.make(build: build1)
lifecycle2 = KpackLifecycleDataModel.make(build: build2)

expect do
build_delete.delete_for_app(app.guid)
end.to change(KpackLifecycleDataModel, :count).by(-2)
[lifecycle1, lifecycle2].each { |l| expect(l).not_to exist }
end
end
end
end
46 changes: 0 additions & 46 deletions spec/unit/actions/build_update_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,52 +125,6 @@ module VCAP::CloudController
end
end
end

context 'when updating state' do
let(:build) { BuildModel.make(:kpack) }

context 'when a build was successfully completed' do
let(:body) do
{
state: 'STAGED',
lifecycle: {
type: 'kpack',
data: {
image: 'some-fake-image:tag',
processTypes: {
foo: 'foo start',
bar: 'bar start'
}
}
}
}
end

it 'updates the build state as STAGED and updates the droplet with correct metadata' do
build_update.update(build, message)

expect(build.state).to eq('STAGED')
expect(build.droplet.state).to eq('STAGED')
expect(build.droplet.docker_receipt_image).to eq('some-fake-image:tag')
expect(build.droplet.process_types).to eq({ 'foo' => 'foo start', 'bar' => 'bar start' })
end
end

context 'when the state is FAILED' do
let(:body) do
{
state: 'FAILED',
error: 'failed to stage build'
}
end

it 'updates the state to FAILED' do
build_update.update(build, message)
expect(build.state).to eq 'FAILED'
expect(build.error_description).to include 'failed to stage build'
end
end
end
end
end
end
2 changes: 1 addition & 1 deletion spec/unit/actions/droplet_update_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ module VCAP::CloudController

context 'image updates' do
context 'when the droplet is not STAGED' do
let!(:droplet) { DropletModel.make(:kpack, state: VCAP::CloudController::DropletModel::STAGING_STATE, app: nil) }
let!(:droplet) { DropletModel.make(:docker, state: VCAP::CloudController::DropletModel::STAGING_STATE, app: nil) }

let(:message) do
VCAP::CloudController::DropletUpdateMessage.new({
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/messages/build_update_message_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ module VCAP::CloudController
state: 'STAGED',
error: 'error',
lifecycle: {
type: 'kpack',
type: 'docker',
data: {
image: 'some-image:tag'
}
Expand All @@ -65,7 +65,7 @@ module VCAP::CloudController
{
state: 'STAGED',
lifecycle: {
type: 'kpack',
type: 'docker',
data: {
image: 'some-image:tag'
}
Expand Down
Loading
Loading