From 85430e5acf546a11338c6ba1757f203a2d6cf99d Mon Sep 17 00:00:00 2001 From: Tim Downey Date: Mon, 7 Aug 2023 16:43:19 -0600 Subject: [PATCH 1/2] Add instance_internal_ip field to ProcessStats endpoint - Allows users to see the internal container IP address for a process --- app/presenters/v3/process_stats_presenter.rb | 13 +++++++------ spec/request/processes_spec.rb | 4 +++- .../presenters/v3/process_stats_presenter_spec.rb | 6 ++++++ 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/app/presenters/v3/process_stats_presenter.rb b/app/presenters/v3/process_stats_presenter.rb index 4c17c083c62..e76fd063662 100644 --- a/app/presenters/v3/process_stats_presenter.rb +++ b/app/presenters/v3/process_stats_presenter.rb @@ -32,12 +32,13 @@ def instance_stats_hash(index, stats) def found_instance_stats_hash(index, stats) { - type: @type, - index: index, - state: stats[:state], - host: stats[:stats][:host], - uptime: stats[:stats][:uptime], - mem_quota: stats[:stats][:mem_quota], + type: @type, + index: index, + state: stats[:state], + host: stats[:stats][:host], + instance_internal_ip: stats[:stats][:net_info][:instance_address], + uptime: stats[:stats][:uptime], + mem_quota: stats[:stats][:mem_quota], disk_quota: stats[:stats][:disk_quota], log_rate_limit: stats[:stats][:log_rate_limit], fds_quota: stats[:stats][:fds_quota], diff --git a/spec/request/processes_spec.rb b/spec/request/processes_spec.rb index 79e4c894c1b..b268262bf99 100644 --- a/spec/request/processes_spec.rb +++ b/spec/request/processes_spec.rb @@ -475,6 +475,7 @@ let(:net_info_1) { { address: '1.2.3.4', + instance_address: '5.6.7.8', ports: [ { host_port: 8080, @@ -538,7 +539,8 @@ 'disk' => 1024, 'log_rate' => 1024, }, - 'host' => 'toast', + 'host' => 'toast', + 'instance_internal_ip' => '5.6.7.8', 'instance_ports' => [ { 'external' => 8080, diff --git a/spec/unit/presenters/v3/process_stats_presenter_spec.rb b/spec/unit/presenters/v3/process_stats_presenter_spec.rb index 1599806f5ce..694b3bde9a5 100644 --- a/spec/unit/presenters/v3/process_stats_presenter_spec.rb +++ b/spec/unit/presenters/v3/process_stats_presenter_spec.rb @@ -12,6 +12,7 @@ module VCAP::CloudController::Presenters::V3 let(:net_info_1) { { address: '1.2.3.4', + instance_address: '5.6.7.8', ports: [ { host_port: 8080, @@ -31,6 +32,7 @@ module VCAP::CloudController::Presenters::V3 let(:net_info_2) { { address: '', + instance_address: '', ports: nil } } @@ -116,6 +118,7 @@ module VCAP::CloudController::Presenters::V3 expect(result[0][:details]).to eq(nil) expect(result[0][:isolation_segment]).to eq('hecka-compliant') expect(result[0][:host]).to eq('myhost') + expect(result[0][:instance_internal_ip]).to eq('5.6.7.8') expect(result[0][:instance_ports]).to eq(instance_ports_1) expect(result[0][:uptime]).to eq(12345) expect(result[0][:mem_quota]).to eq(process[:memory] * 1024 * 1024) @@ -156,6 +159,7 @@ module VCAP::CloudController::Presenters::V3 let(:net_info_1) { { address: '1.2.3.4', + instance_address: '5.6.7.8', ports: [ { host_port: 8080, @@ -193,6 +197,7 @@ module VCAP::CloudController::Presenters::V3 expect(result[0][:details]).to eq(nil) expect(result[0][:isolation_segment]).to eq('hecka-compliant') expect(result[0][:host]).to eq('myhost') + expect(result[0][:instance_internal_ip]).to eq('5.6.7.8') expect(result[0][:instance_ports]).to eq(instance_ports_1) expect(result[0][:uptime]).to eq(12345) expect(result[0][:mem_quota]).to eq(process[:memory] * 1024 * 1024) @@ -235,6 +240,7 @@ module VCAP::CloudController::Presenters::V3 expect(result[0][:details]).to eq(nil) expect(result[0][:isolation_segment]).to eq('hecka-compliant') expect(result[0][:host]).to eq('myhost') + expect(result[0][:instance_internal_ip]).to eq('5.6.7.8') expect(result[0][:instance_ports]).to eq(instance_ports_1) expect(result[0][:uptime]).to eq(12345) expect(result[0][:mem_quota]).to be_nil From d6bb6f44cbfb2b82b3531f4814cd0158b90855d2 Mon Sep 17 00:00:00 2001 From: Tim Downey Date: Thu, 10 Aug 2023 15:49:03 -0600 Subject: [PATCH 2/2] Add docs for instance_internal_ip field Authored-by: Tim Downey --- docs/v3/source/includes/api_resources/_processes.erb | 2 ++ .../v3/source/includes/resources/processes/_stats_object.md.erb | 1 + 2 files changed, 3 insertions(+) diff --git a/docs/v3/source/includes/api_resources/_processes.erb b/docs/v3/source/includes/api_resources/_processes.erb index 02e6bb0e34b..4619a69a2d2 100644 --- a/docs/v3/source/includes/api_resources/_processes.erb +++ b/docs/v3/source/includes/api_resources/_processes.erb @@ -188,6 +188,7 @@ "disk": 69705728 }, "host": "10.244.16.10", + "instance_internal_ip": "10.255.93.167", "instance_ports": [ { "external": 64546, @@ -218,6 +219,7 @@ "disk_quota": null, "fds_quota": 16384, "host": "", + "instance_internal_ip": "", "instance_ports": null, "isolation_segment": null, "log_rate_limit": null, diff --git a/docs/v3/source/includes/resources/processes/_stats_object.md.erb b/docs/v3/source/includes/resources/processes/_stats_object.md.erb index 9d68a47a70e..2f1d1af0aee 100644 --- a/docs/v3/source/includes/resources/processes/_stats_object.md.erb +++ b/docs/v3/source/includes/resources/processes/_stats_object.md.erb @@ -21,6 +21,7 @@ Name | Type | Description **usage.disk** | _integer_ | The current disk usage of the instance **usage.log_rate** | _integer_ | The current logging usage of the instance **host** | _string_ | The host the instance is running on +**instance_internal_ip** | _string_ | The internal IP address of the instance **instance_ports** | _object_ | JSON array of port mappings between the network-exposed port used to communicate with the app (`external`) and port opened to the running process that it can listen on (`internal`) **uptime** | _integer_ | The uptime in seconds for the instance **mem_quota** | _integer_ | The current maximum memory allocated for the instance; the value is `null` when memory quota data is unavailable