Skip to content

Commit

Permalink
Display instance internal IP address on Process Stats endpoint (cloud…
Browse files Browse the repository at this point in the history
…foundry#3378)

* Add instance_internal_ip field to ProcessStats endpoint

- Allows users to see the internal container IP address for a process

* Add docs for instance_internal_ip field

Authored-by: Tim Downey <[email protected]>
Co-authored-by: Geoff Franks <[email protected]>
  • Loading branch information
2 people authored and jrussett committed Oct 19, 2023
1 parent 63777d1 commit 5ace3be
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 7 deletions.
13 changes: 7 additions & 6 deletions app/presenters/v3/process_stats_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
2 changes: 2 additions & 0 deletions docs/v3/source/includes/api_resources/_processes.erb
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@
"disk": 69705728
},
"host": "10.244.16.10",
"instance_internal_ip": "10.255.93.167",
"instance_ports": [
{
"external": 64546,
Expand Down Expand Up @@ -242,6 +243,7 @@
"disk_quota": null,
"fds_quota": 16384,
"host": "",
"instance_internal_ip": "",
"instance_ports": null,
"isolation_segment": null,
"log_rate_limit": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion spec/request/processes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@
let(:net_info_1) {
{
address: '1.2.3.4',
instance_address: '5.6.7.8',
ports: [
{
host_port: 8080,
Expand Down Expand Up @@ -562,7 +563,8 @@
'disk' => 1024,
'log_rate' => 1024,
},
'host' => 'toast',
'host' => 'toast',
'instance_internal_ip' => '5.6.7.8',
'instance_ports' => [
{
'external' => 8080,
Expand Down
6 changes: 6 additions & 0 deletions spec/unit/presenters/v3/process_stats_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -31,6 +32,7 @@ module VCAP::CloudController::Presenters::V3
let(:net_info_2) {
{
address: '',
instance_address: '',
ports: nil
}
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5ace3be

Please sign in to comment.