Bug 1007455 - Cartridge sdk should expose a function to get the primary endpoint for a gear
Cartridge sdk should expose a function to get the primary endpoint for a gear
Product: OpenShift Online
Classification: Red Hat
Component: Containers (Show other bugs)
Unspecified Unspecified
medium Severity medium
: ---
: ---
Assigned To: Michal Fojtik
libra bugs
Depends On:
  Show dependency treegraph
Reported: 2013-09-12 10:10 EDT by Paul Morie
Modified: 2015-05-14 19:28 EDT (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2013-10-17 09:28:35 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 Paul Morie 2013-09-12 10:10:18 EDT
Currently the haproxy cartridge uses grep to search the manifest for the web framework cartridge in an app.  Instead, the cartridge sdk should expose a function for this, backed by an oo- script which actually parses the manifest.
Comment 1 Michal Fojtik 2013-09-18 08:19:40 EDT
While I'm working on the oo- script for parsing the cartridge manifest, I discovered that the haproxy grep/sed/tr magic could be replaced by a bash function in the OpenShift Bash SDK:

function primary_cart_manifest {
  ruby -ryaml -e "p YAML.load_file('$OPENSHIFT_PRIMARY_CARTRIDGE_DIR/metadata/manifest.yml')$1"

Then you can call this function using:

first_ip_in_manifest=$(primary_cart_manifest "['Endpoints'].first['Private-IP-Name']")

If you look at v2_cart_model.rb 'primary_cartridge' method, this function is not very different
as what the method is doing.

The difficulty I have with creating the oo- script for manifest parsing is the YAML format
of the manifest... You need to deal with things like Array's and Hash'es, so the syntax
could be pretty wild:

$ oo-cartridge-manifest -c 52398bc711fae092a1000007 primary -n 'Private-IP-Name' --endpoint 1

The same applies for other properties in manifest.yaml (--compatible-versions, etc..) Basically
the oo- script will need to map the YAML keys into 'options', which might turn into maintenance
nightmare ;-)

What do you guys think?
Comment 2 openshift-github-bot 2013-09-24 11:09:20 EDT
Commit pushed to master at https://github.com/openshift/origin-server

Bug 1007455 - Added primary_cartridge methods to Ruby SDK
Comment 3 chunchen 2013-09-25 00:38:04 EDT
It's fixed, verified on devenv_3821, please refer to the following results:

1. Create a scaled app
rhc app create cpl0s0 perl-5.1 -s --no-git
2. SSH into this app
rhc ssh cpl0s0
3. Check scripts code
grep -e first_ip_in_manifest -e first_port_in_manifest haproxy/hooks/set-proxy
4. Check the primary endpoint variables
env |grep  PERL

at step 3: 

at step 4:

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