Description of problem: For cartridges based on httpd, OpenShift administrators would like the ability to add to the httpd configuration used by all cartridges without having to create and maintain a custom cartridge to do so. The proposed method for doing this is to designate directories on the node where the administrator can just put .conf files to have them included in gear configurations. Steps to Reproduce: 1. Create perl, php, ruby, and python apps 2. Add directories /etc/openshift/cart.conf.d/httpd{,/perl,/php,/ruby,/python} and put a unique httpd directive in a conf file in each, e.g. put "SetEnv TEST_CART_CONF foo" in env.conf 3. For each app, add something that will demonstrate the change, e.g. that prints the env var(s). Push the change and ensure the app restarts (which should pull in the new httpd conf). Additional info: This covers httpd conf as well as cart-specific httpd conf. We'd like to do this for JBoss too but that is a little more complex approach.
Fix encompasses these origin-server commits: commit e6fb621f318282bbdd4aeba00627bbf89dc680b9 Author: N. Harrison Ripps <hripps> Date: Fri Jan 3 13:30:27 2014 -0500 Applied fix to other affected cartridges commit dc13d789a30e94178abdc9cf3d1fb3b5018273e9 Author: Luke Meyer <lmeyer> Date: Thu Jan 16 11:53:56 2014 -0500 <ruby cart> enable providing custom gear server confs commit 5bd3fdd85c376fe897583bdb9c87a83d83960654 Author: Luke Meyer <lmeyer> Date: Thu Jan 16 15:42:07 2014 -0500 <perl cart> enable providing custom gear server confs commit eb47a28f1159d131bbd5178ec45d3e4e4baebf70 Author: Luke Meyer <lmeyer> Date: Thu Jan 16 15:47:53 2014 -0500 <php cart> enable providing custom gear server confs commit 3c44c059c36ed97ffebf896c7ec8767dc4411be1 Author: Luke Meyer <lmeyer> Date: Thu Jan 16 15:53:46 2014 -0500 <phpmyadmin cart> enable providing custom gear server confs commit 30cb922e1bff6983b73618e23c3add4391a5077d Author: Luke Meyer <lmeyer> Date: Thu Jan 16 18:40:27 2014 -0500 <python cart> enable providing custom gear server confs commit 5139542904ee53a87d4f704aab72409f8401438d Author: Luke Meyer <lmeyer> Date: Sun Jan 19 08:02:33 2014 -0500 <perl,python,phpmyadmin carts> bug 1055095 https://bugzilla.redhat.com/show_bug.cgi?id=1055095 $HTTPD_CMD_CONF needed to be treated literally Also, the python httpd conf dir was wrong
Also adding these upstream commits: commit 011c1518272a258684ed3b5a5aee56bb854e50e4 Author: Luke Meyer <lmeyer> Date: Fri Jan 31 04:36:57 2014 -0500 <httpd carts> bug 1060068: ensure extra httpd conf dirs exist https://bugzilla.redhat.com/show_bug.cgi?id=1060068 httpd cartridges won't see new /etc/openshift/cart.conf.d dirs when restarted commit 507adf14e919ba847c62b8ab24087306f4234781 Author: N. Harrison Ripps <hripps> Date: Fri Jan 3 11:28:46 2014 -0500 Modify PHP stop() to skip httpd stop when the process is already dead
openshift enterprise puddle: 2014-02-06.1 [root@nd216 ~]# rpm -qa|grep openshift-origin-cartridge-ruby openshift-origin-cartridge-ruby-1.17.5-1.el6op.noarch [root@nd216 ~]# rpm -qa|grep openshift-origin-cartridge-python openshift-origin-cartridge-python-1.17.8-1.el6op.noarch [root@nd216 ~]# rpm -qa|grep openshift-origin-cartridge-php openshift-origin-cartridge-php-1.17.3.3-1.el6op.noarch [root@nd216 ~]# rpm -qa|grep openshift-origin-cartridge-perl openshift-origin-cartridge-perl-1.16.7-1.el6op.noarch step 1: 1. Create a perl app 2. Add directories /etc/openshift/cart.conf.d/httpd/perl and put a unique httpd directive in a conf file in each, e.g. put "SetEnv TEST_CART_CONF foo" in env.conf [root@nd216 ~]# cat /etc/openshift/cart.conf.d/httpd/perl/env.conf SetEnv TEST_CART_CONF foo 3. Add something and prints the env var(s) and Push the change Edit index.pl to include: print $ENV{TEST_CART_CONF}; git add .; git commit -amp; git push 4. curl the app URL or visit web page and check that generic_env_var is output some message like this "Print Foo" check php、ruby、python as perl.
Seem like this does NOT work with php cartridge. Puddle: 2.0.z/2014-02-12.1 1. Create php cartridge http config file # cat /etc/openshift/cart.conf.d/httpd/php/foo.conf SetEnv TEST_CART_CONF foo 2.Create a php app 3.Add the following test file to app. $ cat env.php <?php foreach ($_ENV as $key=>$val ) { echo $key."=".$val."\n"; } echo "-----".$_ENV["TEST_CART_CONF"]."-----"."\n"; ?> 4. git push and check <app_url>/env.php Actual results: TEST_CART_CONF var is NOT printed out. Seen from app log, get the following error: [Tue Feb 18 02:27:56 2014] [error] [client 127.1.244.1] PHP Notice: Undefined index: TEST_CART_CONF in /var/lib/openshift/53030af71621ce0977000004/app-root/runtime/repo/php/env.php on line 6 [Tue Feb 18 02:27:56 2014] [error] [client 127.1.244.1] PHP Stack trace: [Tue Feb 18 02:27:56 2014] [error] [client 127.1.244.1] PHP 1. {main}() /var/lib/openshift/53030af71621ce0977000004/app-root/runtime/repo/php/env.php:0 Seem like "SetEnv TEST_CART_CONF foo" does NOT take effect. Log into instance, print this app's http command line: # ps -ef|grep 53030af71621ce0977000004 1000 22036 1 0 02:27 ? 00:00:00 /usr/sbin/httpd -C Include /var/lib/openshift/53030af71621ce0977000004/php//configuration/etc/conf.d/*.conf -f /var/lib/openshift/53030af71621ce0977000004/php//configuration/etc/conf/httpd_nolog.conf -c Include /etc/openshift/cart.conf.d/httpd/*.conf -c Include /etc/openshift/cart.conf.d/httpd/php/*.conf -k start 1000 22038 22036 0 02:27 ? 00:00:00 /usr/sbin/rotatelogs /var/lib/openshift/53030af71621ce0977000004/php/logs/error_log-%Y%m%d-%H%M%S-%Z 86400 1000 22039 22036 0 02:27 ? 00:00:00 /usr/sbin/rotatelogs /var/lib/openshift/53030af71621ce0977000004/php/logs/access_log-%Y%m%d-%H%M%S-%Z 86400 1000 22040 22036 0 02:27 ? 00:00:00 /usr/sbin/httpd -C Include /var/lib/openshift/53030af71621ce0977000004/php//configuration/etc/conf.d/*.conf -f /var/lib/openshift/53030af71621ce0977000004/php//configuration/etc/conf/httpd_nolog.conf -c Include /etc/openshift/cart.conf.d/httpd/*.conf -c Include /etc/openshift/cart.conf.d/httpd/php/*.conf -k start Other cartridge is working well, e.g: perl, python, ruby.
Thanks for testing at this level of detail. I really appreciate the scrutiny (especially because my first commits of this were quite broken). I'm not a PHP programmer, but it seems that $_ENV (and $_SERVER similarly) does not include all env variables. It's unclear to me exactly how it's formed but there seem to be some relevant options that affect it: http://us.php.net/manual/en/reserved.variables.environment.php#98113 In any case, if you use the getenv() function to read the env var, or simply print everything with phpinfo(), you'll see SetEnv sets values in env vars, but not $_ENV. At least, that's how it worked in my testing.
Ah, thanks for your document link. Get the following info: If you wish to define an environment variable in your Apache vhost file, use the directive SetEnv. SetEnv varname "variable value" It is important to note that this new variable will appear in $_SERVER, not $_ENV. Then I change code, $_SERVER["TEST_CART_CONF"] could be printed out. I also use getenv("TEST_CART_CONF") and phpinfo() function; both of them work well.
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. http://rhn.redhat.com/errata/RHBA-2014-0209.html