Skip to content

Commit 86a2387

Browse files
committed
Fix LrpStateTranslator: Add STOPPING state
1 parent d71ab6a commit 86a2387

3 files changed

Lines changed: 21 additions & 0 deletions

File tree

lib/cloud_controller/diego/reporters/instances_reporter.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ def self.translate_lrp_state(lrp)
146146
lrp.placement_error.present? ? VCAP::CloudController::Diego::LRP_DOWN : VCAP::CloudController::Diego::LRP_STARTING
147147
when ::Diego::ActualLRPState::CRASHED
148148
VCAP::CloudController::Diego::LRP_CRASHED
149+
when ::Diego::ActualLRPState::STOPPING
150+
VCAP::CloudController::Diego::LRP_STOPPING
149151
else
150152
VCAP::CloudController::Diego::LRP_UNKNOWN
151153
end

lib/diego/lrp_constants.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ module ActualLRPState
44
CLAIMED = 'CLAIMED'.freeze
55
RUNNING = 'RUNNING'.freeze
66
CRASHED = 'CRASHED'.freeze
7+
STOPPING = 'STOPPING'.freeze
78
end
89
end

spec/unit/lib/cloud_controller/diego/reporters/instances_reporter_spec.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,24 @@ def make_actual_lrp(instance_guid:, index:, state:, error:, since:, routable: ni
453453
end
454454
end
455455
end
456+
457+
context 'when an LRP is STOPPING' do
458+
let(:desired_instances) { 1 }
459+
let(:bbs_instances_response) do
460+
[
461+
make_actual_lrp(instance_guid: 'instance-a', index: 0, state: ::Diego::ActualLRPState::STOPPING, error: '', since: two_days_ago_since_epoch_ns)
462+
]
463+
end
464+
465+
before do
466+
allow(bbs_instances_client).to receive(:lrp_instances).with(process).and_return(bbs_instances_response)
467+
end
468+
469+
it 'translates STOPPING to STOPPING' do
470+
result = instances_reporter.all_instances_for_app(process)
471+
expect(result[0][:state]).to eq(VCAP::CloudController::Diego::LRP_STOPPING)
472+
end
473+
end
456474
end
457475

458476
describe '#instance_count_summary' do

0 commit comments

Comments
 (0)