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
18 changes: 17 additions & 1 deletion lib/cloud_controller/diego/reporters/instances_stats_reporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def build_info(state, actual_lrp, process, stats, quota_stats, log_cache_errors)
host: actual_lrp.actual_lrp_net_info.address,
instance_guid: actual_lrp.actual_lrp_instance_key.instance_guid,
port: get_default_port(actual_lrp.actual_lrp_net_info),
net_info: actual_lrp.actual_lrp_net_info.to_h,
net_info: actual_lrp_net_info_to_hash(actual_lrp.actual_lrp_net_info),
uptime: nanoseconds_to_seconds((Time.now.to_f * 1e9) - actual_lrp.since),
fds_quota: process.file_descriptors
}.merge(metrics_data_for_instance(stats, quota_stats, log_cache_errors, Time.now.to_datetime.rfc3339, actual_lrp.actual_lrp_key.index))
Expand Down Expand Up @@ -198,6 +198,22 @@ def get_default_port(net_info)

0
end

def actual_lrp_net_info_to_hash(net_info)
%i[address instance_address ports preferred_address].index_with do |field_name|
if field_name == :ports
net_info.ports.map(&method(:port_mapping_to_hash))
else
net_info.send(field_name)
end
end
end

def port_mapping_to_hash(port_mapping)
%i[container_port container_tls_proxy_port host_port host_tls_proxy_port].index_with do |field_name|
port_mapping.send(field_name)
end
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,17 @@ def make_actual_lrp(instance_guid:, index:, state:, error:, since:)
[container_metric_batch]
end

let(:expected_lrp_1_net_info) do
{
address: 'lrp-host',
instance_address: '',
ports: [
{ container_port: DEFAULT_APP_PORT, container_tls_proxy_port: 0, host_port: 2222, host_tls_proxy_port: 0 },
{ container_port: 1111, container_tls_proxy_port: 0, host_port: 0, host_tls_proxy_port: 0 }
],
preferred_address: :UNKNOWN
}
end
let(:expected_stats_response) do
{
0 => {
Expand All @@ -90,7 +101,7 @@ def make_actual_lrp(instance_guid:, index:, state:, error:, since:)
host: 'lrp-host',
instance_guid: 'instance-a',
port: 2222,
net_info: lrp_1_net_info.to_h,
net_info: expected_lrp_1_net_info,
uptime: two_days_in_seconds,
mem_quota: 1234,
disk_quota: 10_234,
Expand Down Expand Up @@ -217,7 +228,7 @@ def make_actual_lrp(instance_guid:, index:, state:, error:, since:)
host: 'lrp-host',
instance_guid: 'instance-a',
port: 2222,
net_info: lrp_1_net_info.to_h,
net_info: expected_lrp_1_net_info,
uptime: two_days_in_seconds,
mem_quota: nil,
disk_quota: nil,
Expand Down Expand Up @@ -272,7 +283,7 @@ def make_actual_lrp(instance_guid:, index:, state:, error:, since:)
host: 'lrp-host',
instance_guid: 'instance-a',
port: 2222,
net_info: lrp_1_net_info.to_h,
net_info: expected_lrp_1_net_info,
uptime: two_days_in_seconds,
mem_quota: nil,
disk_quota: nil,
Expand Down Expand Up @@ -519,7 +530,7 @@ def make_actual_lrp(instance_guid:, index:, state:, error:, since:)
host: 'lrp-host',
instance_guid: 'instance-a',
port: 2222,
net_info: lrp_1_net_info.to_h,
net_info: expected_lrp_1_net_info,
uptime: two_days_in_seconds,
mem_quota: nil,
disk_quota: nil,
Expand Down Expand Up @@ -653,7 +664,7 @@ def make_actual_lrp(instance_guid:, index:, state:, error:, since:)
host: 'lrp-host',
instance_guid: 'instance-a',
port: 2222,
net_info: lrp_1_net_info.to_h,
net_info: expected_lrp_1_net_info,
uptime: two_days_in_seconds,
mem_quota: nil,
disk_quota: nil,
Expand Down