Description of problem: Description of problem: Given a Perl-5.10 embeded with mongodb-2.2 and 10gen-mms-agent-0.1, it fails to load "OPENSHIFT_10GENMMSAGENT_IDENT" and "OPENSHIFT_10GENMMSAGENT_DIR" env vars from its web page. Version-Release number of selected component (if applicable): int How reproducible: always Steps to Reproduce: 1. create a Perl-5.10 application as app1 2. add mongodb-2.2 to the app 3. cd into the app'repo/.openshift and mkdir mms 4. cd into mms and create a settings.py 5. in the app'repo/perl, create a new page named universal.pl with the following code: <--------------> #!/usr/bin/env perl use URI::Escape; print "Content-type: text/plain\r\n\r\n"; # Get parameters in query string my $param = {}; if(length($ENV{'QUERY_STRING'}) > 0) { $buffer = $ENV{'QUERY_STRING'}; @pairs = split(/&/, $buffer); foreach $pair (@pairs){ ($name, $value) = split(/=/, $pair); $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $param{$name} = uri_unescape($value); } } if(not exists($param{'group'})) { print "Usage: $ENV{'OPENSHIFT_APP_DNS'}/universal.pl?group=<group>\nValid groups are 'shell', 'env'\n"; exit 255 } # Try to load OPENSHIFT env vars with shell commands passed in HTTP request if($param{'group'} eq "shell") { if(not exists($param{'cmd'})) { print "Usage: $ENV{'OPENSHIFT_APP_DNS'}/universal.pl?group=shell&cmd=<shell command>\n"; exit 1 } my $cmd = $param{'cmd'}; print "Command: $cmd\n"; my $output = `$cmd`; print "Exit value: $?\n"; print "===================================Output=====================================\n"; print $output; print "==============================================================================\n"; } # Load all server side env vars elsif($param{'group'} eq "env") { print "The env vars of $ENV{'OPENSHIFT_APP_NAME'}\n"; foreach $key(keys %ENV){ print "$key=$ENV{$key}\n"; } } <--------------> 6.git push all the changes 7.add cartridge 10gen-mms-agent-0.1 to the app 8. Try to load all env vars of this app via visiting <app_url>/universal.pl?group=env 9. Try to load env vars of 10gen-mms-agent-0.1 via visiting <app_url>/universal.pl?group=shell&cmd=env | grep OPENSHIFT_10GENMMSAGENT_IDENT <app_url>/universal.pl?group=shell&cmd=env | grep OPENSHIFT_10GENMMSAGENT_DIR Actual results: Command: env | grep OPENSHIFT_10GENMMSAGENT_DIR Exit value: 256 Command: env | grep OPENSHIFT_10GENMMSAGENT_IDENT Exit value: 256 Expected results: OPENSHIFT_10GENMMSAGENT_DIR OPENSHIFT_10GENMMSAGENT_IDENT Additional info:
*** Bug 965680 has been marked as a duplicate of this bug. ***
Fixed in https://github.com/openshift/origin-server/pull/2580
Commit pushed to master at https://github.com/openshift/li https://github.com/openshift/li/commit/6c24aa44bdc77efc93fe5b1f34eca583a285c05d Bug 965537 - Dynamically build PassEnv httpd configuration * Update httpd configuration on each start and restart
Commit pushed to master at https://github.com/openshift/origin-server https://github.com/openshift/origin-server/commit/373f718c3be39748b4136fb0cfcaba21c18127de Bug 965537 - Dynamically build PassEnv httpd configuration * Update httpd configuration on each start and restart
the bug failed on devenv_3258 again the result is Command: env | grep OPENSHIFT_10GENMMSAGENT_IDENT Exit value: 256 Command: env | grep OPENSHIFT_10GENMMSAGENT_DIR Exit value: 256
Checked on devenv_3258, After a restart of the app, the new added env_vars still cannot be found by the code. Assign the bug back.
The PR https://github.com/openshift/origin-server/pull/2580 seems did not fix the issue. For all the apache based app, it cannot read the db cartridge env_vars after added it, unless do a git push or a manually stop/start. As it mentioned in Card: https://trello.com/card/pick-up-env-vars-for-apache-restart/50fc6bb487602f214b003f71/126 The env_vars should be reloaded after add/remove the cartridge or restart the app.
Updated card to be clearer on actual results. The httpd-based cartridges cannot update when another cartridge is added or removed without restarted the httpd-based cartridge. The new feature allows the httpd configuration to pick up any available cartridge environment variables when httpd is restarted, the environment variables are no longer hard coded in httpd.conf.
Checked on devenv_3262 again, The httpd_nolog.conf will be updated after each restart, and OPENSHIFT env_vars will be written to the file. But it still cannot be loaded by the code. eg. PHP # cat php/test.php <?php foreach ($_ENV as $key=>$val ) { echo $key."\n"; } ?> After restart the web cartridge, the test.php page dose not update accordingly. 1. Create php app 2. Add above code to check the env 3. Add mysql to the app 4. Restart the php cartridge 5. Login to the app to check the httpd_nolog.conf file The new mysql env_vars are imported to the file. 6. Refresh the page It still cannot get the new envs. And if stop the app and start it again, the new env_vars will be shown on the web page.
It seems restart app will not cause the parent httpd pid change, for eg: Before restart app, the parent httpd pid is 11592: [phpapp-domx1.dev.rhcloud.com 866111267982399670059008]\> ps -ef|grep http 516 11592 1 0 04:34 ? 00:00:00 /usr/sbin/httpd -C Include /var/lib/openshift/866111267982399670059008/php//configuration/etc/conf.d/*.conf -f /var/lib/openshift/866111267982399670059008/php//configuration/etc/conf/httpd_nolog.conf -k start 516 27918 11592 0 04:45 ? 00:00:00 /usr/sbin/httpd -C Include /var/lib/openshift/866111267982399670059008/php//configuration/etc/conf.d/*.conf -f /var/lib/openshift/866111267982399670059008/php//configuration/etc/conf/httpd_nolog.conf -k start [root@ip-10-196-90-40 ~]# rhc app restart phpapp RESULT: phpapp restarted After restart the app, the parent httpd pid is still 11592 [phpapp-domx1.dev.rhcloud.com 866111267982399670059008]\> ps -ef|grep httpd 516 11592 1 0 04:34 ? 00:00:00 /usr/sbin/httpd -C Include /var/lib/openshift/866111267982399670059008/php//configuration/etc/conf.d/*.conf -f /var/lib/openshift/866111267982399670059008/php//configuration/etc/conf/httpd_nolog.conf -k start 516 14471 11592 0 04:53 ? 00:00:00 /usr/sbin/httpd -C Include /var/lib/openshift/866111267982399670059008/php//configuration/etc/conf.d/*.conf -f /var/lib/openshift/866111267982399670059008/php//configuration/etc/conf/httpd_nolog.conf -k start
httpd restart signals httpd to read it's configuration. Having the same pid is as designed.
The PHP framework does not support reading new variables on 'httpd restart', nor do any other frameworks with the exception of the Perl framework. The Perl framework does support reading new variables on 'httpd restart'.
Tested against perl cartridge with script in the Comment#0 Still cannot get the new env_vars via rhc app restart and rhc cartridge restart. Not sure if it is caused by Bug 968340 I can get the env updated after a ctl_all restart from the gear shell, but seems the ctl_all restart perform a stop and start actually.
Closing as upstream and will be handled with: https://trello.com/c/2A5mmrCG