Hide Forgot
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.
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?
Commit pushed to master at https://github.com/openshift/origin-server https://github.com/openshift/origin-server/commit/086363bdce6736849064e3a683ca1294a9fdec34 Bug 1007455 - Added primary_cartridge methods to Ruby SDK
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: first_ip_in_manifest=$(primary_cartridge_private_ip_name) prim_cart_ip="OPENSHIFT_${prim_cart}_${first_ip_in_manifest}" first_port_in_manifest=$(primary_cartridge_private_port_name) prim_cart_port="OPENSHIFT_${prim_cart}_${first_port_in_manifest}" at step 4: OPENSHIFT_PERL_VERSION=5.10 PERL5LIB=/var/lib/openshift/52424f7e617cec7634000007/app-root/runtime/repo/libs:/var/lib/openshift/52424f7e617cec7634000007/perl/perl5lib/lib/perl5/ OPENSHIFT_PERL_IDENT=redhat:perl:5.10:0.0.5 OPENSHIFT_PERL_PROXY_PORT=38031 OPENSHIFT_PERL_PORT=8080 OPENSHIFT_PERL_DIR=/var/lib/openshift/52424f7e617cec7634000007/perl/ OPENSHIFT_PERL_IP=127.1.244.1 OPENSHIFT_PERL_LOG_DIR=/var/lib/openshift/52424f7e617cec7634000007/perl//logs/