Skip to content
Merged
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
8 changes: 1 addition & 7 deletions lib/cloud_controller/deployment_updater/actions/scale.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ def call

app.lock!

oldest_web_process_with_instances.lock!
deploying_web_process.lock!
app.web_processes.each(&:lock!)

deployment.update(
status_value: DeploymentModel::ACTIVE_STATUS_VALUE,
Expand All @@ -52,11 +51,6 @@ def call

private

def oldest_web_process_with_instances
# TODO: lock all web processes? We might alter all of them, depending on max-in-flight size
@oldest_web_process_with_instances ||= app.web_processes.select { |process| process.instances > 0 }.min_by { |p| [p.created_at, p.id] }
end

def instance_count_summary
@instance_count_summary ||= instance_reporters.instance_count_summary(deploying_web_process)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,15 @@ module VCAP::CloudController
}.by(1)
end

context 'when the app has been scaled to 0 instances' do
let(:current_web_instances) { 0 }
let(:target_total_instance_count) { 0 }

it 'finishes scaling' do
expect(subject.call).to be true
end
end

context 'when the max_in_flight is set to 2' do
let(:deployment) do
DeploymentModel.make(
Expand Down