Bug 971208

Summary: [RFE] Generic environment variables for IP and PORT are deprecated - now cartridge-specific
Product: OpenShift Online Reporter: Joshua Wulf <jwulf>
Component: DocumentationAssignee: brice <bfallonf>
Status: CLOSED NOTABUG QA Contact: ecs-bugs
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 2.xCC: baulakh, jokerman, mmccomas
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-07-29 01:16:00 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Joshua Wulf 2013-06-06 02:25:10 UTC
https://access.redhat.com/site/documentation/en-US/OpenShift/2.0/html/User_Guide/sect-OpenShift-User_Guide-Environment_Variables.html#sect-OpenShift-User_Guide-Environment_Variables-Informational_Environment_Variables

and also 

https://www.openshift.com/page/openshift-environment-variables

Suggested rewording: 

"These variables provide environment information for your application. Your application can read these environment variables and use the information to configure itself for the OpenShift environment."

Table 7.2. Informational Environment Variables

Environment Variable Name	 Example	 Purpose
OPENSHIFT_APP_DNS	 appname-namespace.example.com	 The application's fully-qualified domain name
OPENSHIFT_APP_NAME	 appname	 The application's name
OPENSHIFT_APP_UUID	 0123456789abcdef0123456789abcdef	 The UUID of the application (32 hex characters)
OPENSHIFT_INTERNAL_IP	 127.0.250.1	 The IP address the application listens on
OPENSHIFT_INTERNAL_PORT	 8080	 The port the application receives requests from

In my node.js app the OPENSHIFT_INTERNAL_IP and OPENSHIFT_INTERNAL_PORT are not available in the environment.

Instead, I need to use the following environment variables:

OPENSHIFT_NODEJS_IP    Purpose: The IP address for a node application
OPENSHIFT_NODEJS_PORT    Purpose: The IP port for a node application

example usage is like this:

// Default to 127.0.0.1 and 8080 for local testing, when the app is not running on OpenShift
myApp.IPAddress = process.env.OPENSHIFT_NODEJS_IP || '127.0.0.1';
myApp.IPPort = process.env.OPENSHIFT_NODEJS_PORT || 8080;

In this case it's obvious when the NODEJS_IP and _PORT variables are available - when you are using a node.js gear. However, when are the OPENSHIFT_INTERNAL_IP and _PORT variables available? That should probably be made explicit, so that peeps know when to, and when not to rely on their existence.

Comment 1 Joshua Wulf 2013-06-06 03:33:26 UTC
mmcgrath: (OPENSHIFT_INTERNAL_IP) is deprecated as of this erelease but still there for older apps for the time being


The NODEJS variables are documented here: https://github.com/openshift/origin-server/tree/master/cartridges/openshift-origin-cartridge-nodejs

Not all the cartridges contain the environment variables, but this one does, for example: 

https://github.com/openshift/origin-server/tree/master/cartridges/openshift-origin-cartridge-jbossas

Here's the list of cartridges: https://github.com/openshift/origin-server/tree/master/cartridges


Here's the cartridge definition guidelines that talk about defining those cartridge-specific variables:

https://github.com/openshift/origin-server/blob/master/node/README.writing_cartridges.md#exposing-services--tcp-endpoints

Yep, that's it. The _PORT and _IP variable is defined per-cartridge in the manifest.yml file in the metadata subdirectory of the cartridge. Here's an example: The Ruby cartridge readme (https://github.com/openshift/origin-server/blob/master/cartridges/openshift-origin-cartridge-ruby/README.md) does not detail the Ruby cartridge variables, but you can see them here: https://github.com/openshift/origin-server/blob/master/cartridges/openshift-origin-cartridge-ruby/metadata/manifest.yml#L29

Comment 2 Joshua Wulf 2013-06-06 04:26:48 UTC
I'd like to request a new section with a series of tables for each cartridge detailing the  specific environment variables defined in each one.

Comment 3 Joshua Wulf 2013-06-08 11:47:01 UTC
Version 1 cartridges provided the environment variables OPENSHIFT_INTERNAL_IP and OPENSHIFT_INTERNAL_PORT. Version 1 cartridges are deprecated, and new gears use Version 2 cartridges.

Version 2 cartridges use cartridge-specific environment variables to provide address and port information for your application. Gears report their Version 2 cartridge support in the welcome message when you ssh into the gear:

<screen>Note: Your application supports version 2 cartridges.</screen>

Comment 4 Joshua Wulf 2013-06-08 11:48:11 UTC
^ Based on https://github.com/ramr/nodejs-custom-version-openshift/issues/2

Comment 6 brice 2015-07-29 01:16:00 UTC
Closing this BZ. 

The focus of the documentation team is going to shift from OpenShift v2 to v3, and only the remaining v2 doc BZs that feature actual errors in the docs will be worked on.

If there are any oppositions for any specific BZs, please contact me or the docs team.