diff --git a/lib/cloud_controller/deployment_updater/actions/scale.rb b/lib/cloud_controller/deployment_updater/actions/scale.rb index 06b687ff097..0a99a1cdf8c 100644 --- a/lib/cloud_controller/deployment_updater/actions/scale.rb +++ b/lib/cloud_controller/deployment_updater/actions/scale.rb @@ -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, @@ -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 diff --git a/spec/unit/lib/cloud_controller/deployment_updater/actions/scale_spec.rb b/spec/unit/lib/cloud_controller/deployment_updater/actions/scale_spec.rb index c097b576e75..510a6e5fe93 100644 --- a/spec/unit/lib/cloud_controller/deployment_updater/actions/scale_spec.rb +++ b/spec/unit/lib/cloud_controller/deployment_updater/actions/scale_spec.rb @@ -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(