Skip to content

Commit 5877fb2

Browse files
committed
Add STOPPING state for process instances
1 parent 9621038 commit 5877fb2

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

lib/cloud_controller/diego/reporters/instances_stats_reporter.rb

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,16 @@ def instances_for_processes(processes)
4848
# Fill in the instances up to the max of desired instances and actual instances
4949
[process.instances, newest_lrp_by_index.length].max.times do |idx|
5050
lrp = newest_lrp_by_index[idx]
51-
instances[idx] = if lrp
51+
52+
instances[idx] = if lrp.nil?
53+
{ state: VCAP::CloudController::Diego::LRP_DOWN }
54+
elsif process.stopped?
55+
{ state: app_instance_stopping_state }
56+
else
5257
{
5358
state: LrpStateTranslator.translate_lrp_state(lrp),
5459
since: nanoseconds_to_seconds(current_time_since_epoch_ns - lrp.since)
5560
}
56-
else
57-
{ state: VCAP::CloudController::Diego::LRP_DOWN }
5861
end
5962
end
6063

@@ -129,7 +132,7 @@ def handle_no_running_instances(process)
129132
if bbs_instances_client.lrp_instances(process).empty?
130133
[fill_unreported_instances_with_down_instances({}, process, flat: false), []]
131134
else
132-
state = Config.config.get(:app_instance_stopping_state) ? VCAP::CloudController::Diego::LRP_STOPPING : VCAP::CloudController::Diego::LRP_DOWN
135+
state = app_instance_stopping_state
133136
# case when no desired_lrp exists but an actual_lrp
134137
logger.debug("Actual LRP found, setting state to #{state}", process_guid: process.guid)
135138
actual_lrp_info(process, nil, nil, nil, nil, state)
@@ -249,6 +252,10 @@ def port_mapping_to_hash(port_mapping)
249252
port_mapping.send(field_name)
250253
end
251254
end
255+
256+
def app_instance_stopping_state
257+
@app_instance_stopping_state ||= Config.config.get(:app_instance_stopping_state) ? VCAP::CloudController::Diego::LRP_STOPPING : VCAP::CloudController::Diego::LRP_DOWN
258+
end
252259
end
253260
end
254261
end

0 commit comments

Comments
 (0)