cloudfoundry / php-buildpack

A Cloud Foundry Buildpack for PHP.
Apache License 2.0
142 stars 346 forks source link

IBM Cloud php app not able to connect to DB2 after cflinuxfs3 upgrade #319

Closed mike-pala closed 5 years ago

mike-pala commented 5 years ago

my php app has worked just fine with my DB2 instance for over 2 years.

I was not able to upgrade to cflinuxfs3 because https://github.com/ibmdb/php-buildpack built pack does not work with cflinuxfs3. So I was told to uninstall it:

cf push appname -s cflinuxfs3 -b php_buildpack

and use the php_buildpack community buildpack already installed in Cloud Foundry....

...now my app is upgraded to cflinuxfs3 ... it is up and running BUT unfortunatelly this buildpack does not seem to have DB2 drivers and my app is not able to connect to DB2...

My log says "Call to undefined function db2_connect()" ... so it seems that NOW my app does not recognize DB2 functions

...please let me restate this again.... my app and DB2 were working just fine for 2 years ... unitl the mandatory cflinuxfs3 upgrade.

cf-gitbot commented 5 years ago

We have created an issue in Pivotal Tracker to manage this:

https://www.pivotaltracker.com/story/show/168339817

The labels on this github issue will be updated when the story is started.

dmikusa commented 5 years ago

OK, so you were using a custom buildpack and switched to the standard buildpack and your app stopped working. It's because your custom buildpack had functionality that is not in the standard buildpack. Specifically the DB2 drivers.

We cannot ship proprietary code/drivers with the standard buildpack. It's for legal reasons.

In the short term, you can probably work around this by copying this folder out of the old buildpack and putting it directly into your application. Under the root of your application, create a folder called .extensions. Then puth the ibmdb folder under that, giving you .extensions/ibmdb. The standard PHP buildpack will load extensions from this directory as well, so it should load your IBMDB stuff and 🤞 hopefully work.

That said, you may need to update the IBM DB2 drivers so they are compatible with cflinuxfs3 as well. IDK about that though.

Aside from that, you should probably ask the author of that buildpack or IBM to contribute a buildpack that supports multi-buildpack. They could use this to supply their drivers, but not have to fork and reimplement the entire PHP buildpack.

https://docs.cloudfoundry.org/buildpacks/custom.html#contract

Hope that helps!

mike-pala commented 5 years ago

OK, so you were using a custom buildpack and switched to the standard buildpack and your app stopped working. It's because your custom buildpack had functionality that is not in the standard buildpack. Specifically the DB2 drivers.

We cannot ship proprietary code/drivers with the standard buildpack. It's for legal reasons.

In the short term, you can probably work around this by copying this folder out of the old buildpack and putting it directly into your application. Under the root of your application, create a folder called .extensions. Then puth the ibmdb folder under that, giving you .extensions/ibmdb. The standard PHP buildpack will load extensions from this directory as well, so it should load your IBMDB stuff and 🤞 hopefully work.

That said, you may need to update the IBM DB2 drivers so they are compatible with cflinuxfs3 as well. IDK about that though.

Aside from that, you should probably ask the author of that buildpack or IBM to contribute a buildpack that supports multi-buildpack. They could use this to supply their drivers, but not have to fork and reimplement the entire PHP buildpack.

https://docs.cloudfoundry.org/buildpacks/custom.html#contract

Hope that helps!

Thanks a million Daniel! I will absolutelly try it

mike-pala commented 5 years ago

@dmikusa-pivotal Daniel I did as you suggested but I got a whole bunch of errors during the push

Mate, you seem to know what you're talking about.... could you please take a look and let me know if you have any ideas...?

image

dmikusa commented 5 years ago

Well, the good news is that the extension is running. It looks like it's mostly working too. It's failing cause it's trying to copy a file and the path is wrong. It's hard to tell from the output if the file should be there and it's not, or if the path is just wrong.

Try running cf set-env <app> BP_DEBUG True. Then try restaging your app and capturing all the output (there will be a lot). Attach that here.

mike-pala commented 5 years ago

@dmikusa-pivotal You are just so cool for getting back to me on this. Thank you so much!!!!

I've done as you instructed and am attaching the output below... but also.. in the previous screenshot I noticed that there it's looking for a file in a folder called "20170718" .. while the files in the folder you pointed me to originally contains only (compressed) subfolders going up to "20160303".. not sure if that matters...

cf error.txt

dmikusa commented 5 years ago

OK. Little bit of a guess here, but I think the version of PHP you are using might be too new. The zip it's downloading has this in it.

./._ibm_db2-v1.9.9
ibm_db2-v1.9.9/
ibm_db2-v1.9.9/._20131226
ibm_db2-v1.9.9/20131226/
ibm_db2-v1.9.9/._20151012
ibm_db2-v1.9.9/20151012/
ibm_db2-v1.9.9/._20160303
ibm_db2-v1.9.9/20160303/
ibm_db2-v1.9.9/20160303/._ibm_db2.so
ibm_db2-v1.9.9/20160303/ibm_db2.so
ibm_db2-v1.9.9/20151012/._ibm_db2.so
ibm_db2-v1.9.9/20151012/ibm_db2.so
ibm_db2-v1.9.9/20131226/._ibm_db2.so
ibm_db2-v1.9.9/20131226/ibm_db2.so

but the error is trying to find 20170718/ibm_db2.so. The date there, I think, is the PHP API version. The most recent one looks like 20160303, which is PHP 7.1. You could try setting that version in options.json and see if it helps. Otherwise, you need to get a more recent version of the db2 driver that has extensions for PHP 7.2 and 7.3. You will need to do that eventually though. PHP 7.1 is one life support at this point.

https://www.php.net/supported-versions.php

mike-pala commented 5 years ago

@dmikusa-pivotal Hi Daniel, I tired a a few things on my own ...and failed so far. BUT again, thank you so much for your advice. Might be a stupid questionbut where do I find the options.json you mentioned ???

mike-pala commented 5 years ago

@dmikusa-pivotal Hi Daniel, I know you're answering my questions ONLY because you're just awesome and have no obligation to. That's why I appreciate it even more. Could you please take a quick look at this... please ;) what I did was I found that lates extentions here:

https://pecl.php.net/package/pdo_ibm & https://pecl.php.net/package/ibm_db2

and I've put them in the .extentions\ibmdb\Binaries replacing the original ones ....

and I am getting this:

cf error 2019 09 09.txt

cf-gitbot commented 5 years ago

We have created an issue in Pivotal Tracker to manage this:

https://www.pivotaltracker.com/story/show/168372149

The labels on this github issue will be updated when the story is started.

dmikusa commented 5 years ago

I don't actually see an error in the latest log file. It appears to complete staging & start your app.

At the same time, I'm not sure how that would be. You need to include binary builds of the extensions, but the downloads from PECL are just source code. You would need to take those, build the extension (which requires IBM DB2 dev libraries & headers and that is why we can't include this in the buildpack) then zip up the compiled .so files and put them into your app folder (keeping the same zip archive format).

An easy way to build is with Docker. If you run docker run -w /binary-builder -vpwd:/binary-builder -it cloudfoundry/cflinuxfs3 bash. You'll get a bash shell in a container that matches exactly the running environment for your app. Into that, you'd need to install the DB2 stuff, install PHP 7.2, and then build the IBM DB2 extensions against PHP 7.2 and your DB2 libraries. With binaries, you can package up the extensions .so files into a tgz and include that in your app.

It's kind of a pain. If you're in a time crunch, I would suggest downgrading to PHP 7.1 for now. That looks like it'll work with the previous binaries. Then you can work on compiling against 7.2 or maybe reach out to the previous author about updating their binaries.

mike-pala commented 5 years ago

@dmikusa-pivotal Daniel, thank you so much for your help. Really! I appreciate it. Honestlly most of what you wrote just went over my head as it's beyond my skillset... BUT... I belive it will help me to escalte this issue and get some experts to work on this.

Thank you!

dwillist commented 5 years ago

@mike-pala unfortunately I do not believe we are able to support the DB2 drivers. Please reopen this issue if you have any additional questions/information.