Bug 1036524 - Fail to connect MongoDB via db driver for zend carts (zend-5.6 and zend-6.1)
Summary: Fail to connect MongoDB via db driver for zend carts (zend-5.6 and zend-6.1)
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: OpenShift Online
Classification: Red Hat
Component: Image
Version: 2.x
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ---
: ---
Assignee: Vojtech Vitek
QA Contact: libra bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-12-02 09:06 UTC by Zhe Wang
Modified: 2015-05-15 00:35 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-01-30 00:51:28 UTC
Target Upstream Version:


Attachments (Terms of Use)

Description Zhe Wang 2013-12-02 09:06:27 UTC
Description of problem:
Given a zend-5.6 or 6.1 app with MongoDB-2.2 added, it fails to connect to the db via mongodb driver  from its website, even though mongo.so is installed under /usr/local/zend/lib/php_extensions/

Version-Release number of selected component (if applicable):
devenv_4084

How reproducible:
always

Steps to Reproduce:
1. create a zend app (5.6 or 6.1) with MongoDB added.

2. remove the app's hot_deploy marker to make sure the app is restarted properly (minimize the numbers of variables).

3. SSH into the app and check /usr/local/zend/lib/php_extensions/ to see if mongo.so is at presence.

4. create a php page to connect to mongodb with the following code. (You could verify the code with a php app)

<----mongo.php--->

<?php
header('Content-Type: text/plain');
$m = new Mongo($_ENV['OPENSHIFT_MONGODB_DB_URL']);
$db = $m->$_ENV['OPENSHIFT_APP_NAME'];

$coll = $db->factory;
$count = $coll->find()->count();

if($count == 0) {
  $insert = array("version" => "1");
  $coll->insert($insert);
}

# Accessing the page without arguments
if(empty($_GET["version"])) {
    $obj = $coll->findOne();
    $m->close();
    echo "version ".$obj["version"];
}
else {
    $coll->remove();
    $insert = array("version" => $_GET["version"]);
    $coll->insert($insert);
    $m->close();
    echo "The mongodb factory is modified\n";
}
?>

<---------------->

5. push the change

6. visit $APP_DNS/mongo.php

7. try to reinstall mongo module of the latest version
echo "channel://pecl.php.net/mongo-1.4.5" > $APP_REPO/deplist.txt
OR
ssh into the app and run "pecl install mongo"

Actual results:
In step 3, we can see that mongo.so is at presence:

-rwxr-xr-x.  1 root root  214872 Oct  2  2012 mongo.so

but it returns error 500 when visiting the mongo.php page of the zend app.

Moreover, reinstalling the mongo module fails with the error below:
remote: ERROR: failed to write /usr/local/zend/lib/php_extensions/mongo.so (copy(/usr/local/zend/lib/php_extensions/mongo.so): failed to open stream: Permission denied)

Expected results:
Zend apps (5.6 or 6.1) should support MongoDB without errors in OpenShift. 

Additional info:

Comment 1 Vojtech Vitek 2013-12-04 18:32:15 UTC
https://github.com/openshift/li/pull/2209

Comment 2 Vojtech Vitek 2013-12-06 03:30:11 UTC
PR fixes the problem with PEAR/PECL paths.

Notes:
Mongo extension is disabled by default in Zend Server. Users can enable it in the Zend Server Console (GUI) as follows:
1. Go to $APP_URL/ZendServer/Extensions/phpExtensions
2. Check 'mongo' and click Enable button
3. Click 'Restart' button in the right upper corner to restart PHP processes

If we want to have some of the extensions enabled by default, we should Feature Request it.

Right code to test against:
<?php
header('Content-Type: text/plain');
$m = new Mongo(getenv('OPENSHIFT_MONGODB_DB_URL'));
$db = $m->selectDB(getenv('OPENSHIFT_APP_NAME'));

$coll = $db->factory;
$count = $coll->find()->count();

if($count == 0) {
  $insert = array("version" => "1");
  $coll->insert($insert);
}

# Accessing the page without arguments
if(empty($_GET["version"])) {
    $obj = $coll->findOne();
    $m->close();
    echo "version ".$obj["version"];
}
else {
    $coll->remove();
    $insert = array("version" => $_GET["version"]);
    $coll->insert($insert);
    $m->close();
    echo "The mongodb factory is modified\n";
}

Comment 3 Zhe Wang 2013-12-06 07:51:12 UTC
Hi, Vojtech,

Thanks for your notes, following which this bug is verified in devenv_4102. Would you please move the bug to ON_QA, then I will change it to VERIFIED?

Moreover, I am able to enable mongo extension by adding a pre_build hook in automation scripts to modify the php.ini, so that if won't block auto testing if mongo extension is not enabled in zend apps by default. I will report a feature request if still necessary. But modifying the php.ini leads nother problem that is irrelevant to this bug: after I enable mongo extension by echoing "extension=mongo.so" to $OPENSHIFT_HOMEDIR/configuration/etc/php.ini, the page of $APP_URL/ZendServer/Extensions/phpExtensions still shows that mongo is off. Do you think it is a bug of Zend studio itself or an openshift one?

Thanks,
Zhe Wang

Comment 4 Zhe Wang 2013-12-06 07:52:56 UTC
Sorry, it should be $OPENSHIFT_HOMEDIR/zend/configuration/etc/php.ini in Comment#3.

Comment 5 Vojtech Vitek 2013-12-06 13:18:06 UTC
@Zhe Wang, I think you're just hitting Zend Server cache. Try restarting the whole cartridge.

Imho, the preferred way is to set the extensions via Zend Server Console GUI.

Comment 6 openshift-github-bot 2013-12-06 13:39:48 UTC
Commit pushed to master at https://github.com/openshift/li

https://github.com/openshift/li/commit/057d1b0ef9a7688065d95a6f9c70d6e48da70021
fix zend PEAR and PECL extensions

Configure all the PEAR/PECL paths properly, add PEAR/PECL scripts for Zend Server Console.

Bug 1036524 - Fail to connect MongoDB via db driver for zend carts (zend-5.6 and zend-6.1)
https://bugzilla.redhat.com/show_bug.cgi?id=1036524

Bug 1036526 - Zend-6.1 app does not load installed dependencies from $OPENSHIFT_DEPENDENCIES_DIR by default
https://bugzilla.redhat.com/show_bug.cgi?id=1036526

Comment 7 Zhe Wang 2013-12-09 02:25:25 UTC
Move this bug to VERIFIED according to Comment#3.


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