diff --git a/app/models.rb b/app/models.rb index 93e1594b38d..d6f1418c79e 100644 --- a/app/models.rb +++ b/app/models.rb @@ -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' diff --git a/app/models/runtime/app_model.rb b/app/models/runtime/app_model.rb index b02e1550c56..f2a35d17599 100644 --- a/app/models/runtime/app_model.rb +++ b/app/models/runtime/app_model.rb @@ -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, @@ -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 diff --git a/app/models/runtime/build_model.rb b/app/models/runtime/build_model.rb index abc5310866d..617b0b52b21 100644 --- a/app/models/runtime/build_model.rb +++ b/app/models/runtime/build_model.rb @@ -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, @@ -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 diff --git a/app/models/runtime/droplet_model.rb b/app/models/runtime/droplet_model.rb index 9716d1c8585..b4ddf9bf7f1 100644 --- a/app/models/runtime/droplet_model.rb +++ b/app/models/runtime/droplet_model.rb @@ -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, @@ -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 diff --git a/app/models/runtime/kpack_lifecycle_data_model.rb b/app/models/runtime/kpack_lifecycle_data_model.rb deleted file mode 100644 index a60403d1bb3..00000000000 --- a/app/models/runtime/kpack_lifecycle_data_model.rb +++ /dev/null @@ -1,54 +0,0 @@ -require 'cloud_controller/diego/lifecycles/lifecycles' - -module VCAP::CloudController - class KpackLifecycleDataModel < Sequel::Model(:kpack_lifecycle_data) - include Serializer - - many_to_one :app, - class: '::VCAP::CloudController::AppModel', - key: :app_guid, - primary_key: :guid, - without_guid_generation: true - - many_to_one :droplet, - class: '::VCAP::CloudController::DropletModel', - key: :droplet_guid, - primary_key: :guid, - without_guid_generation: true - - many_to_one :build, - class: '::VCAP::CloudController::BuildModel', - key: :build_guid, - primary_key: :guid, - without_guid_generation: true - - # if this gets any thicker, we should model it properly in its own table - serializes_via_json :buildpacks - - def using_custom_buildpack? - false - end - - def buildpack_models - [] - end - - def first_custom_buildpack_url - nil - end - - # def buildpacks=(new_buildpacks) end - - def to_hash - { - buildpacks: - } - end - - def stack - nil - end - - def stack=(new_value) end - end -end diff --git a/spec/request/builds_spec.rb b/spec/request/builds_spec.rb index 5a88e6b7795..89b3fa2bc70 100644 --- a/spec/request/builds_spec.rb +++ b/spec/request/builds_spec.rb @@ -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 diff --git a/spec/request/droplets_spec.rb b/spec/request/droplets_spec.rb index fb60d1d9df6..0db30447dbe 100644 --- a/spec/request/droplets_spec.rb +++ b/spec/request/droplets_spec.rb @@ -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, diff --git a/spec/support/fakes/blueprints.rb b/spec/support/fakes/blueprints.rb index 86a528857b0..480787a3e66 100644 --- a/spec/support/fakes/blueprints.rb +++ b/spec/support/fakes/blueprints.rb @@ -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 } @@ -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 } @@ -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 @@ -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 @@ -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' } @@ -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 } diff --git a/spec/unit/actions/build_delete_spec.rb b/spec/unit/actions/build_delete_spec.rb index f676d4c4d19..d086a2adc15 100644 --- a/spec/unit/actions/build_delete_spec.rb +++ b/spec/unit/actions/build_delete_spec.rb @@ -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 diff --git a/spec/unit/actions/build_update_spec.rb b/spec/unit/actions/build_update_spec.rb index 12a91bf99e5..c8fb38e8a04 100644 --- a/spec/unit/actions/build_update_spec.rb +++ b/spec/unit/actions/build_update_spec.rb @@ -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 diff --git a/spec/unit/actions/droplet_update_spec.rb b/spec/unit/actions/droplet_update_spec.rb index 0737cab6106..ea7c0c35ddd 100644 --- a/spec/unit/actions/droplet_update_spec.rb +++ b/spec/unit/actions/droplet_update_spec.rb @@ -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({ diff --git a/spec/unit/messages/build_update_message_spec.rb b/spec/unit/messages/build_update_message_spec.rb index a9c5c49a9a0..718897a2186 100644 --- a/spec/unit/messages/build_update_message_spec.rb +++ b/spec/unit/messages/build_update_message_spec.rb @@ -46,7 +46,7 @@ module VCAP::CloudController state: 'STAGED', error: 'error', lifecycle: { - type: 'kpack', + type: 'docker', data: { image: 'some-image:tag' } @@ -65,7 +65,7 @@ module VCAP::CloudController { state: 'STAGED', lifecycle: { - type: 'kpack', + type: 'docker', data: { image: 'some-image:tag' } diff --git a/spec/unit/models/runtime/build_model_spec.rb b/spec/unit/models/runtime/build_model_spec.rb index 1655ab6b195..ad40897a054 100644 --- a/spec/unit/models/runtime/build_model_spec.rb +++ b/spec/unit/models/runtime/build_model_spec.rb @@ -173,16 +173,6 @@ module VCAP::CloudController and change(BuildpackLifecycleBuildpackModel, :count).by(-2) end end - - context 'kpack dependencies' do - let!(:lifecycle_data) { KpackLifecycleDataModel.make(build: build_model) } - - it 'deletes the dependent kpack_lifecycle_data_models when a build is deleted' do - expect do - build_model.destroy - end.to change(KpackLifecycleDataModel, :count).by(-1) - end - end end describe '#staged?' do diff --git a/spec/unit/models/runtime/droplet_model_spec.rb b/spec/unit/models/runtime/droplet_model_spec.rb index 7da70f7f4af..554ae2ee192 100644 --- a/spec/unit/models/runtime/droplet_model_spec.rb +++ b/spec/unit/models/runtime/droplet_model_spec.rb @@ -140,26 +140,8 @@ module VCAP::CloudController end end - context 'when there is kpack_lifecycle_data associated to the droplet' do - let(:droplet_model) { DropletModel.make(:kpack, app: nil) } - let!(:lifecycle_data) do - KpackLifecycleDataModel.make(droplet: droplet_model) - end - - before do - droplet_model.kpack_lifecycle_data = lifecycle_data - droplet_model.save - end - - it 'deletes the dependent kpack_lifecycle_data_models when a droplet is deleted' do - expect do - droplet_model.destroy - end.to change(KpackLifecycleDataModel, :count).by(-1) - end - end - context 'when there is cnb_lifecycle_data associated to the droplet' do - let(:droplet_model) { DropletModel.make(:kpack, app: nil) } + let(:droplet_model) { DropletModel.make(:cnb, app: nil) } let!(:lifecycle_data) do CNBLifecycleDataModel.make( droplet: droplet_model, diff --git a/spec/unit/models/runtime/kpack_lifecycle_data_model_spec.rb b/spec/unit/models/runtime/kpack_lifecycle_data_model_spec.rb deleted file mode 100644 index dd908b58af0..00000000000 --- a/spec/unit/models/runtime/kpack_lifecycle_data_model_spec.rb +++ /dev/null @@ -1,33 +0,0 @@ -require 'spec_helper' - -module VCAP::CloudController - RSpec.describe KpackLifecycleDataModel do - subject(:lifecycle_data) { KpackLifecycleDataModel.new } - - describe '#to_hash' do - let(:expected_lifecycle_data) do - { buildpacks: buildpacks || [] } - end - let(:buildpacks) { [buildpack] } - let(:buildpack) { 'ruby' } - - before do - Buildpack.make(name: 'ruby') - lifecycle_data.buildpacks = buildpacks - lifecycle_data.save - end - - it 'returns the lifecycle data as a hash' do - expect(lifecycle_data.to_hash).to eq expected_lifecycle_data - end - - context 'when the user has not specified a buildpack' do - let(:buildpacks) { [] } - - it 'returns the lifecycle data as a hash' do - expect(lifecycle_data.to_hash).to eq expected_lifecycle_data - end - end - end - end -end