magecloudkit / magecloudkit

MageCloudKit is the High Performance Stack for running Magento on AWS.
Apache License 2.0
4 stars 5 forks source link

503 Service Temporarily Unavailable #47

Open harshjain2 opened 4 years ago

harshjain2 commented 4 years ago

Issue

Getting 503 Service Temporarily Unavailable on deploying the example https://github.com/magecloudkit/magecloudkit/tree/master/examples/magecloudkit-simple-vpc

Intermittently, I have also observed these errors :

Fatal error: Uncaught PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'magento2.m_store_website' doesn't exist in /var/www/html/vendor/magento/zendframework1/library/Zend/Db/Statement/Pdo.php:228 Stack trace: #0 /var/www/html/vendor/magento/zendframework1/library/Zend/Db/Statement/Pdo.php(228): PDOStatement->execute(Array) #1 /var/www/html/vendor/magento/framework/DB/Statement/Pdo/Mysql.php(93): Zend_Db_Statement_Pdo->_execute(Array) #2 /var/www/html/vendor/magento/zendframework1/library/Zend/Db/Statement.php(303): Magento\Framework\DB\Statement\Pdo\Mysql->_execute(Array) #3 /var/www/html/vendor/magento/zendframework1/library/Zend/Db/Adapter/Abstract.php(480): Zend_Db_Statement->execute(Array) #4 /var/www/html/vendor/magento/zendframework1/library/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('SELECT `m_store...', Array) #5 /var/www/html/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php(533): Zend_Db_Adapter_Pdo_Abstract->query('SELECT `m_store...', Array) #6 /var/www/html/ in /var/www/html/vendor/magento/zendframework1/library/Zend/Db/Statement/Pdo.php on line 235
Fatal error: Uncaught PDOException: PDO::__construct(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /var/www/html/vendor/magento/zendframework1/library/Zend/Db/Adapter/Pdo/Abstract.php:128 Stack trace: #0 /var/www/html/vendor/magento/zendframework1/library/Zend/Db/Adapter/Pdo/Abstract.php(128): PDO->__construct('mysql:host=db.a...', 'magento2', 'magento2', Array) #1 /var/www/html/vendor/magento/zendframework1/library/Zend/Db/Adapter/Pdo/Mysql.php(111): Zend_Db_Adapter_Pdo_Abstract->_connect() #2 /var/www/html/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php(398): Zend_Db_Adapter_Pdo_Mysql->_connect() #3 /var/www/html/vendor/magento/zendframework1/library/Zend/Db/Adapter/Abstract.php(460): Magento\Framework\DB\Adapter\Pdo\Mysql->_connect() #4 /var/www/html/vendor/magento/zendframework1/library/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('SELECT `m_store...', Array) #5 /var/www/html/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php(533): Zend_Db_Adapter_Pdo_Abstract in /var/www/html/vendor/magento/zendframework1/library/Zend/Db/Adapter/Pdo/Abstract.php on line 144

Terraform version : Terraform v0.11.8

Let me know if you are aware about this issue. Or point me to right direction, so that I can fix this issue.

robmorgan commented 4 years ago

Hi @harshjain2,

Thanks for reaching out. Unfortunately we no longer actively support or develop MageCloudKit so I am unable to help you with this issue. You can read more about this change in the following blog post. You are welcome to investigate this issue yourself and submit any code changes via a pull request and we'll review your contribution.

I'll leave this issue open as a reminder it still needs to be investigated either by yourself or the community.

Regards,

Rob

harshjain2 commented 4 years ago

@robmorgan I will surely investigate this issue and if I am able to find a solution, I will raise the PR aa well.

Based on your experience, please guide me a bit so that I can start investigating this issue.

robmorgan commented 4 years ago

@harshjain2 sure!

I'll answer inline, based on my experience:

Getting 503 Service Temporarily Unavailable on deploying the example https://github.com/magecloudkit/magecloudkit/tree/master/examples/magecloudkit-simple-vpc

This likely sounds like none of the ECS tasks are successfully running on the ECS cluster. As a result, none have been added into the ALB (Application Load Balancer) target group as 'healthy'. This is likely causing the 503. It probably has been caused by an empty database. I.e. You can fix it by running the Magento installer somehow or importing a Magento 2 database dump into the RDS database.

Fatal error: Uncaught PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'magento2.m_store_website' doesn't exist in /var/www/html/vendor/magento/zendframework1/library/Zend/Db/Statement/Pdo.php:228 Stack trace: #0 /var/www/html/vendor/magento/zendframework1/library/Zend/Db/Statement/Pdo.php(228): PDOStatement->execute(Array) #1 /var/www/html/vendor/magento/framework/DB/Statement/Pdo/Mysql.php(93): Zend_Db_Statement_Pdo->_execute(Array) #2 /var/www/html/vendor/magento/zendframework1/library/Zend/Db/Statement.php(303): Magento\Framework\DB\Statement\Pdo\Mysql->_execute(Array) #3 /var/www/html/vendor/magento/zendframework1/library/Zend/Db/Adapter/Abstract.php(480): Zend_Db_Statement->execute(Array) #4 /var/www/html/vendor/magento/zendframework1/library/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('SELECT m_store...', Array) #5 /var/www/html/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php(533): Zend_Db_Adapter_Pdo_Abstract->query('SELECTm_store...', Array) #6 /var/www/html/ in /var/www/html/vendor/magento/zendframework1/library/Zend/Db/Statement/Pdo.php on line 235

Sounds like an empty database. Same issue as above.

Fatal error: Uncaught PDOException: PDO::construct(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /var/www/html/vendor/magento/zendframework1/library/Zend/Db/Adapter/Pdo/Abstract.php:128 Stack trace: #0 /var/www/html/vendor/magento/zendframework1/library/Zend/Db/Adapter/Pdo/Abstract.php(128): PDO->construct('mysql:host=db.a...', 'magento2', 'magento2', Array) #1 /var/www/html/vendor/magento/zendframework1/library/Zend/Db/Adapter/Pdo/Mysql.php(111): Zend_Db_Adapter_Pdo_Abstract->_connect() #2 /var/www/html/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php(398): Zend_Db_Adapter_Pdo_Mysql->_connect() #3 /var/www/html/vendor/magento/zendframework1/library/Zend/Db/Adapter/Abstract.php(460): Magento\Framework\DB\Adapter\Pdo\Mysql->_connect() #4 /var/www/html/vendor/magento/zendframework1/library/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('SELECT `m_store...', Array) #5 /var/www/html/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php(533): Zend_Db_Adapter_Pdo_Abstract in /var/www/html/vendor/magento/zendframework1/library/Zend/Db/Adapter/Pdo/Abstract.php on line 144

This sounds like PHP is having trouble connecting to the database host. Was the host name modified or entered incorrectly? was it not passed via the ECS task definition correctly? Check the details in the ECS console and see what is in the task definition.

harshjain2 commented 4 years ago

It probably has been caused by an empty database. This is the real issue. I am just curious to know the step during which DB is installed.

harshjain2 commented 4 years ago

@robmorgan I am just wondering how the updates will work in magecloudkit? E.g. I have added a new module which adds a new table. With the current solution, I will create a new Docker file and then upload it to ECR. At which step will I invoke upgrade to reflect those changes in database?