Bug 971208 - [RFE] Generic environment variables for IP and PORT are deprecated - now cartridge-specific
[RFE] Generic environment variables for IP and PORT are deprecated - now cart...
Product: OpenShift Online
Classification: Red Hat
Component: Documentation (Show other bugs)
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: brice
Depends On:
  Show dependency treegraph
Reported: 2013-06-05 22:25 EDT by Joshua Wulf
Modified: 2015-07-28 21:16 EDT (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2015-07-28 21:16:00 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Joshua Wulf 2013-06-05 22:25:10 EDT

and also 


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	 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 and 8080 for local testing, when the app is not running on OpenShift
myApp.IPAddress = process.env.OPENSHIFT_NODEJS_IP || '';
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-05 23:33:26 EDT
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: 


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:


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 00:26:48 EDT
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 07:47:01 EDT
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 07:48:11 EDT
^ Based on https://github.com/ramr/nodejs-custom-version-openshift/issues/2
Comment 6 brice 2015-07-28 21:16:00 EDT
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.

Note You need to log in before you can comment on or make changes to this bug.