Skip to content
Draft
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
15 changes: 11 additions & 4 deletions lib/cloud_controller/diego/reporters/instances_stats_reporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,16 @@ def instances_for_processes(processes)
# Fill in the instances up to the max of desired instances and actual instances
[process.instances, newest_lrp_by_index.length].max.times do |idx|
lrp = newest_lrp_by_index[idx]
instances[idx] = if lrp

instances[idx] = if lrp.nil?
{ state: VCAP::CloudController::Diego::LRP_DOWN }
elsif process.stopped?
{ state: app_instance_stopping_state }
else
{
state: LrpStateTranslator.translate_lrp_state(lrp),
since: nanoseconds_to_seconds(current_time_since_epoch_ns - lrp.since)
}
else
{ state: VCAP::CloudController::Diego::LRP_DOWN }
end
end

Expand Down Expand Up @@ -129,7 +132,7 @@ def handle_no_running_instances(process)
if bbs_instances_client.lrp_instances(process).empty?
[fill_unreported_instances_with_down_instances({}, process, flat: false), []]
else
state = Config.config.get(:app_instance_stopping_state) ? VCAP::CloudController::Diego::LRP_STOPPING : VCAP::CloudController::Diego::LRP_DOWN
state = app_instance_stopping_state
# case when no desired_lrp exists but an actual_lrp
logger.debug("Actual LRP found, setting state to #{state}", process_guid: process.guid)
actual_lrp_info(process, nil, nil, nil, nil, state)
Expand Down Expand Up @@ -249,6 +252,10 @@ def port_mapping_to_hash(port_mapping)
port_mapping.send(field_name)
end
end

def app_instance_stopping_state
@app_instance_stopping_state ||= Config.config.get(:app_instance_stopping_state) ? VCAP::CloudController::Diego::LRP_STOPPING : VCAP::CloudController::Diego::LRP_DOWN
end
end
end
end
Loading