Bug 911775 - Scaled wordpress app creation results in PHP started before environment variables for MySQL loaded
Summary: Scaled wordpress app creation results in PHP started before environment varia...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: OKD
Classification: Red Hat
Component: Containers
Version: 2.x
Hardware: Unspecified
OS: Unspecified
low
medium
Target Milestone: ---
: ---
Assignee: Dan McPherson
QA Contact: libra bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-02-15 22:58 UTC by John Poelstra
Modified: 2015-05-14 23:05 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Enhancement
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-05-11 20:09:04 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
scaled wordpress app (78.07 KB, image/png)
2013-02-15 22:58 UTC, John Poelstra
no flags Details
The webpage of https://<Gear_id of Mysql>-<domain_name>.dev.rhcloud.com (135.95 KB, image/png)
2013-03-07 07:12 UTC, Mengjiao Gao
no flags Details
The webpage of https://<Gear_id of PHP>-<domain_name>.dev.rhcloud.com (175.15 KB, image/png)
2013-03-07 07:17 UTC, Mengjiao Gao
no flags Details

Description John Poelstra 2013-02-15 22:58:38 UTC
Created attachment 698012 [details]
scaled wordpress app

Description of problem:

Using the webconsole I created a wordpress app on a medium gear and set scaling to "yes."  the result is the statistics page for HAProxy (see attached).

I realize WordPress is probably not supported as a scaled app, but I think this isn't a great first impression for a customer either :)

Comment 1 Clayton Coleman 2013-02-19 23:10:30 UTC
Did you keep refreshing the page and it never started working?  Because it takes some time for those gears to spin up.

Comment 2 John Poelstra 2013-02-20 00:43:30 UTC
Yes. 

It's an easy reproducer. 

I just created a new one and 13 min later still seeing HA Proxy page.  In the original case it was a day later.

Comment 3 Rob Millner 2013-02-27 01:26:37 UTC
Haproxy should propagate this error up rather than show the status page, but its being caused by a 500 error returned from php.

# curl -vvv 127.0.252.129:8080
* About to connect() to 127.0.252.129 port 8080 (#0)
*   Trying 127.0.252.129... connected
* Connected to 127.0.252.129 (127.0.252.129) port 8080 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.14.0.0 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: 127.0.252.129:8080
> Accept: */*
> 
< HTTP/1.1 500 Internal Server Error
< Date: Wed, 27 Feb 2013 01:25:17 GMT
< Server: Apache/2.2.15 (Red Hat)
< Expires: Wed, 11 Jan 1984 05:00:00 GMT
< Cache-Control: no-cache, must-revalidate, max-age=0
< Pragma: no-cache
< Content-Length: 251
< Connection: close
< Content-Type: text/html; charset=utf-8
< 
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>Database Error</title>

</head>
<body>
	<h1>Error establishing a database connection</h1>
</body>
</html>
* Closing connection #0

Comment 4 Rob Millner 2013-02-27 01:30:42 UTC
Looks like Wordpress mysql initialization never succeeded.

[wpscale-rmillner0030.dev.rhcloud.com ~]\> mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.1.67 Source distribution

Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use wpscale
Database changed
mysql> show tables;
Empty set (0.00 sec)

mysql> Bye

Comment 5 Rob Millner 2013-02-27 01:35:40 UTC
Git clone the app, dummy commit, and push makes the error go away and haproxy starts taking you to the wordpress page.

I suspect there's a sequencing issue or a retry that should wait longer.

Passing back to Clayton to have a look at the wordpress app.

Also, lowering severity since wordpress itself cannot be scalable (needs to share filesystem with its gears and we just don't have that).  We should come up with a way to disable the scaling button for apps that cannot scale.

Comment 6 Clayton Coleman 2013-02-27 01:46:03 UTC
I just updated the QuickStart - if a user checks in their modules most things will function, but not all.

To make a QuickStart disable the selection you just need to add the not_scalable tag.  I think this issue is fixed now though.

Comment 7 Mengjiao Gao 2013-03-04 03:15:35 UTC
Tested this issue on devenv_2888. The wordpress application have no not_scalable tag in website on devenv_2888, and user can still create scalable wordpress. 

I have tried to create a scalable wordpress on devenv_2888. The web page of my app still dispalyed as the statistics page for HAProxy.

So I will assign this bug back to fix it further.

Comment 8 Clayton Coleman 2013-03-06 19:14:20 UTC
Wordpress is scalable - are you saying that the app never comes up when started as scalable?  Can you get logs from php indicating why?

You'll see the stats page for HAProxy until both gears are started, but there is nothing that should prevent that from working once the php gear is started.

Comment 9 Mengjiao Gao 2013-03-07 07:11:04 UTC
Retest this issue on devenv_2905 , with following steps and result:

1.Login the website
2.Create a scalable wordpress and check the development.log from /var/logs/openshift/site
3.Check the webpage of the scalable wordpress.
4.Check the gear status via REST_API
5.SSH into the app, and check the access_log and error_log from 
/var/lib/openshift/513834e5857eb59df1000045/php-5.3/logs
6.Check two webpages: 
  https://<Gear_id of PHP>-<domain_name>.dev.rhcloud.com
  https://<Gear_id of Mysql>-<domain_name>.dev.rhcloud.com

Actual result:
2.development.log as below:
-------------------------------------------------------------------------------
2013-03-07 01:34:09.756 [INFO ] Started POST "/app/console/applications" for 203.114.244.88 at 2013-03-07 01:34:09 -0500 (pid:18021)
2013-03-07 01:34:11.578 [INFO ] Processing by ApplicationsController#create as HTML (pid:18021)
2013-03-07 01:34:11.580 [INFO ] Parameters: {"utf8"=>"✓", "authenticity_token"=>"zqVuJig2G1pNIIcmLNq4RIWXuOIJHEZIPwtx0lRdmzY=", "advanced"=>"true", "application"=>{"application_type"=>"quickstart!12724", "name"=>"scalewordpressdevenv2905", "domain_name"=>"mgao", "initial_git_url"=>"git://github.com/openshift/wordpress-example.git", "gear_profile"=>"small", "cartridges"=>["php-5.3", "mysql-5.1"], "scale"=>"true"}} (pid:18021)
2013-03-07 01:34:11.586 [DEBUG] Session contents: {"ticket"=>"bWdhbw==", "api_ticket"=>"f8ab676f0f34715c925b907c5c1931cc073915df0ebfdcf39ad728bb6d02f2b9", "login"=>"mgao", "streamline_type"=>:full, "terms"=>true, "session_id"=>"c9407daac4b560b690703f5e9d10cf53", "caps"=>[3, 0, [:small], nil, true], "_csrf_token"=>"zqVuJig2G1pNIIcmLNq4RIWXuOIJHEZIPwtx0lRdmzY="} (pid:18021)
2013-03-07 01:34:11.816 [DEBUG] OpenShift API (88.4ms) get https://localhost:443/broker/rest/api.json [ code: 200 ] (pid:18021)
2013-03-07 01:34:12.519 [DEBUG] OpenShift API (677.5ms) get https://localhost:8118/api/v1/quickstarts/12724 [ code: 200 ] (pid:18021)
2013-03-07 01:34:12.825 [DEBUG] OpenShift API (251.2ms) get https://localhost:443/broker/rest/cartridges.json [ code: 200 ] (pid:18021)
2013-03-07 01:34:12.890 [DEBUG] OpenShift API (24.7ms) get https://localhost:443/broker/rest/domains.json [ code: 200 ] (pid:18021)
2013-03-07 01:34:13.745 [DEBUG] OpenShift API (177.0ms) post https://localhost:443/broker/rest/domains.json [ code: 201 ] (pid:18021)
2013-03-07 01:35:45.609 [DEBUG] OpenShift API (92527.9ms) post https://localhost:443/broker/rest/domains/mgao/applications.json [ code: 201 ] (pid:18021)
2013-03-07 01:35:45.617 [INFO ] Redirected to https://ec2-54-234-76-105.compute-1.amazonaws.com/app/console/applications/scalewordpressdevenv2905/get_started?wizard=true (pid:18021)
2013-03-07 01:35:45.618 [DEBUG] Session domain is reset (pid:18021)
2013-03-07 01:35:45.618 [DEBUG] Session capabilities are reset (pid:18021)
2013-03-07 01:35:45.619 [INFO ] Completed 302 Found in 94039ms (pid:18021)
2013-03-07 01:35:45.915 [INFO ] Started GET "/app/console/applications/scalewordpressdevenv2905/get_started?wizard=true" for 203.114.244.88 at 2013-03-07 01:35:45 -0500 (pid:18021)
2013-03-07 01:35:45.944 [INFO ] Processing by ApplicationsController#get_started as HTML (pid:18021)
2013-03-07 01:35:45.946 [INFO ] Parameters: {"wizard"=>"true", "id"=>"scalewordpressdevenv2905"} (pid:18021)
2013-03-07 01:35:45.949 [DEBUG] Session contents: {"ticket"=>"bWdhbw==", "api_ticket"=>"f8ab676f0f34715c925b907c5c1931cc073915df0ebfdcf39ad728bb6d02f2b9", "login"=>"mgao", "streamline_type"=>:full, "terms"=>true, "session_id"=>"c9407daac4b560b690703f5e9d10cf53", "_csrf_token"=>"zqVuJig2G1pNIIcmLNq4RIWXuOIJHEZIPwtx0lRdmzY=", "flash"=>#<ActionDispatch::Flash::FlashHash:0x000000050e5e48 @used=#<Set: {:info_pre}>, @closed=false, @flashes={:info_pre=>["\nMySQL 5.1 database added.  Please make note of these credentials:\n\n       Root User: adminYGhzYSa\n   Root Password: GAQxmP4flrfG\n   Database Name: scalewordpressdevenv2905\n\nConnection URL: mysql://$OPENSHIFT_MYSQL_DB_HOST:$OPENSHIFT_MYSQL_DB_PORT/\nMySQL gear-local connection URL: mysql://$OPENSHIFT_MYSQL_DB_HOST:$OPENSHIFT_MYSQL_DB_PORT/\n\n"]}, @now=nil>} (pid:18021)
2013-03-07 01:35:45.997 [DEBUG] OpenShift API (42.9ms) get https://localhost:443/broker/rest/domains.json [ code: 200 ] (pid:18021)
2013-03-07 01:35:46.258 [DEBUG] OpenShift API (254.4ms) get https://localhost:443/broker/rest/domains/mgao/applications/scalewordpressdevenv2905.json [ code: 200 ] (pid:18021)
2013-03-07 01:35:46.293 [DEBUG] OpenShift API (27.0ms) get https://localhost:443/broker/rest/user/keys.json [ code: 200 ] (pid:18021)
2013-03-07 01:35:46.593 [INFO ] Rendered /opt/rh/ruby193/root/usr/share/gems/gems/openshift-origin-console-1.5.12/app/views/keys/_simple_form.html.haml (35.5ms) (pid:18021)
2013-03-07 01:35:46.598 [INFO ] Rendered /opt/rh/ruby193/root/usr/share/gems/gems/openshift-origin-console-1.5.12/app/views/applications/get_started.html.haml within layouts/console (100.5ms) (pid:18021)
2013-03-07 01:35:46.663 [INFO ] Rendered /opt/rh/ruby193/root/usr/share/gems/gems/openshift-origin-console-1.5.12/app/views/layouts/_head.html.haml (38.2ms) (pid:18021)
2013-03-07 01:35:46.832 [INFO ] Rendered layouts/console/_stylesheets.html.haml (168.0ms) (pid:18021)
2013-03-07 01:35:46.869 [INFO ] Rendered layouts/console/_header.html.haml (33.3ms) (pid:18021)
2013-03-07 01:35:46.892 [INFO ] Rendered layouts/_footer.html.haml (17.7ms) (pid:18021)
2013-03-07 01:35:46.981 [INFO ] Rendered layouts/console/_javascripts.html.haml (87.3ms) (pid:18021)
2013-03-07 01:35:46.983 [INFO ] Completed 200 OK in 1035ms (Views: 689.9ms | OpenShift API: 324.3ms) (pid:18021)
2013-03-07 01:35:47.283 [INFO ] Started GET "/app/assets/modernizr.min.js?body=1" for 203.114.244.88 at 2013-03-07 01:35:47 -0500 (pid:18021)
2013-03-07 01:35:47.610 [INFO ] Started GET "/app/assets/jquery.js?body=1" for 203.114.244.88 at 2013-03-07 01:35:47 -0500 (pid:18021)
-------------------------------------------------------------------------------

3.The webpage of the scalable wordpress shown like: attachment 698012 [details]
4.The rest_api shown the two gears are all started.
[root@dhcp-9-249 wordpressscale]# curl -k -H "Accept: application/xml" --user mgao:redhat https://ec2-54-234-76-105.compute-1.amazonaws.com/broker/rest/domains/mgao/applications/scalewordpressdevenv2905/gear_groups -X GET
<?xml version="1.0" encoding="UTF-8"?>
<response>
  <status>ok</status>
  <type>gear_groups</type>
  <data>
    <gear-group>
      <uuid>513834e5857eb59df1000062</uuid>
      <name>513834e5857eb59df1000062</name>
      <gear-profile>small</gear-profile>
      <gears>
        <gear>
          <id>513834e5857eb59df1000048</id>
          <state>started</state>
        </gear>
      </gears>
      <cartridges>
        <cartridge>
          <connection-url>mysql://$OPENSHIFT_MYSQL_DB_HOST:$OPENSHIFT_MYSQL_DB_PORT/</connection-url>
          <username>adminYGhzYSa</username>
          <password>GAQxmP4flrfG</password>
          <database-name>scalewordpressdevenv2905</database-name>
          <name>mysql-5.1</name>
          <display-name>MySQL Database 5.1</display-name>
          <tags>
            <tag>service</tag>
            <tag>database</tag>
            <tag>embedded</tag>
          </tags>
        </cartridge>
      </cartridges>
      <scales-from nil="true"></scales-from>
      <scales-to nil="true"></scales-to>
      <base-gear-storage>1</base-gear-storage>
      <additional-gear-storage>0</additional-gear-storage>
    </gear-group>
    <gear-group>
      <uuid>513834e5857eb59df1000063</uuid>
      <name>513834e5857eb59df1000063</name>
      <gear-profile>small</gear-profile>
      <gears>
        <gear>
          <id>513834e5857eb59df1000045</id>
          <state>started</state>
        </gear>
      </gears>
      <cartridges>
        <cartridge>
          <name>php-5.3</name>
          <display-name>PHP 5.3</display-name>
          <tags>
            <tag>service</tag>
            <tag>php</tag>
            <tag>web_framework</tag>
          </tags>
        </cartridge>
        <cartridge>
          <name>haproxy-1.4</name>
          <display-name>OpenShift Web Balancer</display-name>
          <tags>
            <tag>web_proxy</tag>
            <tag>scales</tag>
            <tag>embedded</tag>
          </tags>
        </cartridge>
      </cartridges>
      <scales-from>1</scales-from>
      <scales-to>-1</scales-to>
      <base-gear-storage>1</base-gear-storage>
      <additional-gear-storage>0</additional-gear-storage>
    </gear-group>
  </data>
  <messages/>
  <version>1.3</version>
  <supported-api-versions>
    <supported-api-version>1.0</supported-api-version>
    <supported-api-version>1.1</supported-api-version>
    <supported-api-version>1.2</supported-api-version>
    <supported-api-version>1.3</supported-api-version>
  </supported-api-versions>
</response>

5.Access_log shown as below:
----------------------------------------------------------------
- - - [07/Mar/2013:01:59:43 -0500] "GET / HTTP/1.0" 500 251 "-" "-"
- - - [07/Mar/2013:01:59:45 -0500] "GET / HTTP/1.0" 500 251 "-" "-"
- - - [07/Mar/2013:01:59:47 -0500] "GET / HTTP/1.0" 500 251 "-" "-"
- - - [07/Mar/2013:01:59:49 -0500] "GET / HTTP/1.0" 500 251 "-" "-"
- - - [07/Mar/2013:01:59:51 -0500] "GET / HTTP/1.0" 500 251 "-" "-"
- - - [07/Mar/2013:01:59:53 -0500] "GET / HTTP/1.0" 500 251 "-" "-"
- - - [07/Mar/2013:01:59:55 -0500] "GET / HTTP/1.0" 500 251 "-" "-"
- - - [07/Mar/2013:01:59:57 -0500] "GET / HTTP/1.0" 500 251 "-" "-"
- - - [07/Mar/2013:01:59:59 -0500] "GET / HTTP/1.0" 500 251 "-" "-"
- - - [07/Mar/2013:02:00:01 -0500] "GET / HTTP/1.0" 500 251 "-" "-"
- - - [07/Mar/2013:02:00:03 -0500] "GET / HTTP/1.0" 500 251 "-" "-"
- - - [07/Mar/2013:02:00:05 -0500] "GET / HTTP/1.0" 500 251 "-" "-"
- - - [07/Mar/2013:02:00:07 -0500] "GET / HTTP/1.0" 500 251 "-" "-"
-------------------------------------------------------------------
Error_log as below:
-------------------------------------------------------------------
[Thu Mar 07 01:35:15 2013] [notice] SELinux policy enabled; httpd running as context system_u:system_r:openshift_t:s0:c0,c507
[Thu Mar 07 01:35:15 2013] [notice] mod_bw : Memory Allocated 32 bytes (each conf takes 32 bytes)
[Thu Mar 07 01:35:15 2013] [notice] mod_bw : Version 0.8 - Initialized [1 Confs]
[Thu Mar 07 01:35:15 2013] [notice] Digest: generating secret for digest authentication ...
[Thu Mar 07 01:35:15 2013] [notice] Digest: done
[Thu Mar 07 01:35:16 2013] [notice] Apache/2.2.15 (Unix) configured -- resuming normal operations
------------------------------------------------------------------

6.The webpage of https://<Gear_id of Mysql>-<domain_name>.dev.rhcloud.com can be shown correctly as attachment.
But the webpage of   https://<Gear_id of PHP>-<domain_name>.dev.rhcloud.com will pointed to a not-found error page.

Comment 10 Mengjiao Gao 2013-03-07 07:12:47 UTC
Created attachment 706383 [details]
The webpage of https://<Gear_id of Mysql>-<domain_name>.dev.rhcloud.com

Comment 11 Mengjiao Gao 2013-03-07 07:17:56 UTC
Created attachment 706384 [details]
The webpage of https://<Gear_id of PHP>-<domain_name>.dev.rhcloud.com

Comment 12 Clayton Coleman 2013-03-07 18:49:18 UTC
Marking the quickstart not_scalable (so that users won't be able to create it scalable).  There is a known platform issue where components created at the same time are not created in the correct order, so PHP starts before the MySQL environment variables are added.  This means that PHP won't have the necessary environment variables to create the database the first time.

Comment 13 Clayton Coleman 2013-03-07 18:49:32 UTC
Dan and I agreed this is not release blocking.

Comment 14 Dan McPherson 2013-05-07 15:35:25 UTC
Can this be retested?  It should be fixed by the addition of post-configure.

Comment 15 John Poelstra 2013-05-07 15:52:56 UTC
How to retest if scaling for wordpress is disabled in the web console?

Comment 16 Dan McPherson 2013-05-07 16:55:01 UTC
Follow the steps here:

https://github.com/openshift/wordpress-example

except pass -s when you create the app.

Comment 17 Xiaoli Tian 2013-05-08 03:08:24 UTC
Verified it on devenv_3194 with the following commands, scaling wordpress application could be created successfully, wordpress home page could be accessed successfully

# rhc app-create wordpress php-5 mysql-5 --from-code=https://github.com/openshift/wordpress-example -s
Using php-5.3 (PHP 5.3) for 'php-5'
Using mysql-5.1 (MySQL Database 5.1) for 'mysql-5'

Application Options
-------------------
  Namespace:   domx1
  Cartridges:  php-5.3, mysql-5.1
  Source Code: https://github.com/openshift/wordpress-example
  Gear Size:   default
  Scaling:     yes

Creating application 'wordpress' ... done

Waiting for your DNS name to be available ... done

Downloading the application Git repository ...
Initialized empty Git repository in /root/wordpress/.git/
The authenticity of host 'wordpress-domx1.dev.rhcloud.com (10.202.86.47)' can't be established.
RSA key fingerprint is ed:83:fc:fb:d6:60:17:85:3d:f7:7d:59:05:2a:c5:6d.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'wordpress-domx1.dev.rhcloud.com,10.202.86.47' (RSA) to the list of known hosts.

Your application code is now in 'wordpress'

wordpress @ http://wordpress-domx1.dev.rhcloud.com/ (uuid: 5189c0a3143f390a5a000001)
------------------------------------------------------------------------------------


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