Bug 866413

Summary: Get error when visit the wordpress app url.
Product: OKD Reporter: Mengjiao Gao <mgao>
Component: TemplatesAssignee: Abhishek Gupta <abhgupta>
Status: CLOSED CURRENTRELEASE QA Contact: libra bugs <libra-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 2.xCC: abhgupta, pruan, rpenta, szhou, wsun, yujzhang
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-04-20 03:34:03 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
The wordpress page before jenkins build.
none
The wordpress page after jenkins build and domain name change. none

Description Mengjiao Gao 2012-10-15 10:11:57 UTC
Created attachment 627283 [details]
The wordpress page before jenkins build.

Description of problem:
When I tested on devenv_2327, I firstly created a wordpress application. Since it takes a long time to deploy(as the bug 863930 say), I restart it used CLI, then I tried to visit the app url, and got error page shown: "Error establishing a database connection" as attachment #1 [details] shown.
Then I tried to build Jenkins with the wordpress app. After successful built the wordpress app, the app url can be visit , and the page shown normally without error .
Then I tried to changed domain name. Then I found the app page shown not correctly as attachment #2 [details] shown.

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

How reproducible:
always

Steps to Reproduce:
1.Go to the website, and create a wordpress application.
2.Restart the app used CLI 
($ rhc app restart -a wordpress -l mgao+dev491 -p redhat)
3.Visit the app url.
4.Enable Jenkins to the app, and then build it with jenkins.
5.Visit the app url again.
6.Change the domain name.
7.Visit the app url again.
  
Actual results:
After step 3, I got an error page with messages:"Error establishing a database connection".
After step 5, I got the right wordpress page.
After step 6, the page cannot be shown correctly as attachment #2 [details] shown.

Expected results:
When I visit the app url, it should be always right displayed.

Additional info:
I saw these word in the console output when building wordpress, so it likely used the dev/typeless branch.
--------------------------------------------------------------------------
.......
Fetching upstream changes from ssh://a9bddf8efc40480498fc8f3b6cdbc041.rhcloud.com/~/git/wordpress22.git/
Seen branch in repository origin/HEAD
Seen branch in repository origin/dev/typeless
Seen branch in repository origin/master
Commencing build of Revision fb422720ff3aa87daff4cef5a44b1e99f4b66bad (origin/dev/typeless)
Checking out Revision fb422720ff3aa87daff4cef5a44b1e99f4b66bad (origin/dev/typeless)
No change to record in branch origin/dev/typeless
.......
----------------------------------------------------------------------

Comment 1 Mengjiao Gao 2012-10-15 10:12:52 UTC
Created attachment 627284 [details]
The wordpress page after jenkins build and domain name change.

Comment 2 Dan McPherson 2012-10-16 13:18:08 UTC
Are you running step 2 before step 1 is finished?

Comment 3 Mengjiao Gao 2012-10-17 03:53:08 UTC
Tested this issue on devenv_2340 without step 2. And the same issue exists on devenv_2340.
The steps as below:
1.Go to the website, and create a wordpress application.
2.Wait for a while until the app's status to be "STARTED", then Visit the app url.
3.Enable Jenkins to the app, and then build it with jenkins.
4.Visit the app url again.
5.Change the domain name.
6.Visit the app url again.

and result as below:
After step 2, The wordpress app status is "STARTED" ,But the app url redirected an error page with messages:"Error establishing a database connection".
After step 4, I got the right wordpress page.
After step 6, the page cannot be shown correctly as attachment #2 [details] shown.

(In reply to comment #2)
> Are you running step 2 before step 1 is finished?

Comment 4 Yujie Zhang 2012-12-10 09:09:49 UTC
Tested on INT(devenv_2572), this issue still exists, the reproduce steps as below:
1.Go to openshift website and login
2.Create a wordpress application
3.Change the domain name
After step3, the page of wordpress is not correct as above screenshot.

Comment 5 Abhishek Gupta 2013-01-31 03:01:03 UTC
This happens because we have absolute URLs for links hardcoded in the mysql database. We populate the database during the deploy action hook.

Created a pull request on the wordpress-example repository. Also, another much older pull request that avoids populating the database would probably resolve this issue as well.

Comment 6 Dan McPherson 2013-02-22 23:31:51 UTC
*** Bug 914845 has been marked as a duplicate of this bug. ***

Comment 7 Abhishek Gupta 2013-03-06 01:34:10 UTC
*** Bug 892119 has been marked as a duplicate of this bug. ***

Comment 8 Abhishek Gupta 2013-03-06 02:05:07 UTC
Wordpress stores absolute URLs for all links in its database. When we change the domain name, those links need to be updated. Probably a update_namespace user hook where the database dump is taken as a sql file, and all references to the application dns changed and then the database imported again. This, however, is too disruptive and we need to look for better alternatives.

Comment 10 Abhishek Gupta 2013-04-15 18:43:51 UTC
This is no longer an issue since we do not allow namespace updates on doamins with applications.

Comment 11 Wei Sun 2013-04-16 03:04:31 UTC
Verified in devenv_3101

Step:
1.Log in website
2.Create a wordpress application
3.Access the url
4.Jenkins build the app


Result:
3.Can access the url successfully.
4.Jenkins build successfully,and the app's url can be accessed.