debianmaster / microservices-on-openshift

This project demonstrates how we can deploy micro services built in different languages can deployed on openshift
53 stars 152 forks source link

EMAIL API #1

Open prasenforu opened 7 years ago

prasenforu commented 7 years ago

I am trying to complete setup in my lab (cluster environment OSE 3.2).

Everything is working fine apart from email-api. Email api pod also is running.

http://emailsvc-microsrv.cloudapps.teg.com/email -- it is also responding with "Email API 2"

When I use to do testing with following command, its showing error and not able to receive mail in my mail box.

curl -X POST -d '{"to":"xxxxx@gmail.com","msg":"test mail"}' -H "Content-Type: application/json" http://emailsvc-microsrv.cloudapps.teg.com/email

Error coming as follows ..

//

Internal Server Error

Internal Server Error

//

I did rsh inside the pod of email-api and executed same command and output as follows ..

sh-4.2$ curl http://localhost:8080/email Email API 2sh-4.2$ sh-4.2$ sh-4.2$ sh-4.2$ curl -X POST -d '{"to":"prasenforu@gmail.com","msg":"test mail"}' \

-H "Content-Type: application/json" http://localhost:8080/email

Internal Server Error

Internal Server Error

sh-4.2$

Please help me to troubleshoot.

debianmaster commented 7 years ago

Sorry for the delay in response. i believe the process is not working or may be you have not created the schema that is required in mysql. can you check container logs and double check schema

prasenforu commented 7 years ago

Hi Chakradhar,

First of all thanks for replying.

I followed every steps in your git

Can you please little elaborate.

FYI I am using cluster setup OSE 3.3 not standalone.

I tested 3.2 but same problem.

Thanks & regards, Prasenjit

debianmaster commented 7 years ago

Did you create mysql schema in mysql container? create table emails (from_add varchar(40), to_add varchar(40), subject varchar(40), body varchar(200), created_at date);

prasenforu commented 7 years ago

Yes.

Below mysql pod part.


[root@ose-master ~]# oc rsh $(oc get pods | grep mysql | grep Running | awk '{print $1}')

sh-4.2$ mysql -u $MYSQL_USER -p$MYSQL_PASSWORD -h $HOSTNAME $MYSQL_DATABASE Warning: Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.6.34 MySQL Community Server (GPL)

Copyright (c) 2000, 2016, 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> create table emails (from_add varchar(40), to_add varchar(40), subject varchar(40), body varchar(200), created_at date); Query OK, 0 rows affected (0.02 sec)

mysql> exit Bye sh-4.2$ exit exit


EMAIL container log part


[root@ose-master ~]# curl -X POST -d '{"to":"prasenforu@gmail.com","msg":"test mail"}' -H "Content-Type: application/json" http://emailsvc-firsttest.cloudapps.cloud-cafe.in/email

Internal Server Error

Internal Server Error

[root@ose-master ~]#

[root@ose-master ~]# oc logs po/emailsvc-1-yf64w ---> Serving application with gunicorn (sample:api) ... [2017-02-12 01:36:53 +0000] [1] [INFO] Starting gunicorn 19.4.5 [2017-02-12 01:36:53 +0000] [1] [INFO] Listening at: http://0.0.0.0:8080 (1) [2017-02-12 01:36:53 +0000] [1] [INFO] Using worker: sync [2017-02-12 01:36:53 +0000] [27] [INFO] Booting worker with pid: 27 [2017-02-12 01:36:53 +0000] [28] [INFO] Booting worker with pid: 28 [2017-02-12 01:37:30 +0000] [27] [ERROR] Error handling request /email Traceback (most recent call last): File "/opt/app-root/src/.local/lib/python2.7/site-packages/gunicorn/workers/sync.py", line 130, in handle self.handle_request(listener, req, client, addr) File "/opt/app-root/src/.local/lib/python2.7/site-packages/gunicorn/workers/sync.py", line 171, in handle_request respiter = self.wsgi(environ, resp.start_response) File "/opt/app-root/src/.local/lib/python2.7/site-packages/falcon/api.py", line 182, in call responder(req, resp, **params) File "/opt/app-root/src/sample.py", line 38, in on_post server.login(os.getenv('GMAIL_USERNAME', 'node2test@gmail.com'), os.getenv('GMAIL_PASSWORD', 'Refresh@2015')) File "/opt/rh/python27/root/usr/lib64/python2.7/smtplib.py", line 622, in login raise SMTPAuthenticationError(code, resp) SMTPAuthenticationError: (534, '5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbtt\n5.7.14 JQ_f-A4EJBjVjsEc6Y4CeYZY7JVkWYEzXKh5dQZYJucleFWz1QLYBc067NY9S1Q4W6G4\n5.7.14 btFmMWA3K9fo8QnQKrJXZaGX_6xO-rHTV-r_DPfVbgXkuX5b3kymx6qAaVEH78Kxq3dWkn\n5.7.14 sfVD_mrfmejKzSnEmayCYVQZCoIQBRwHeNyFeEDIrGQbxRIsCyZzS6nEAO-HYzJi6ki6Z0\n5.7.14 -3_gQvI5ONPI9ecKuoJy4xLRn-r0k> Please log in via your web browser and\n5.7.14 then try again.\n5.7.14 Learn more at\n5.7.14 https://support.google.com/mail/answer/78754 r21sm12911555pfd.95 - gsmtp') 10.1.1.1 - - [12/Feb/2017:01:37:30 +0000] "POST /email HTTP/1.1" 500 - "-" "-"

[root@ose-master ~]# curl -X POST -d '{"to":"prasenforu@gmail.com","msg":"test mail"}' -H "Content-Type: application/json" http://emailsvc-firsttest.cloudapps.cloud-cafe.in/email

Internal Server Error

Internal Server Error

[root@ose-master ~]# oc logs po/emailsvc-1-yf64w ---> Serving application with gunicorn (sample:api) ... [2017-02-12 01:36:53 +0000] [1] [INFO] Starting gunicorn 19.4.5 [2017-02-12 01:36:53 +0000] [1] [INFO] Listening at: http://0.0.0.0:8080 (1) [2017-02-12 01:36:53 +0000] [1] [INFO] Using worker: sync [2017-02-12 01:36:53 +0000] [27] [INFO] Booting worker with pid: 27 [2017-02-12 01:36:53 +0000] [28] [INFO] Booting worker with pid: 28 [2017-02-12 01:37:30 +0000] [27] [ERROR] Error handling request /email Traceback (most recent call last): File "/opt/app-root/src/.local/lib/python2.7/site-packages/gunicorn/workers/sync.py", line 130, in handle self.handle_request(listener, req, client, addr) File "/opt/app-root/src/.local/lib/python2.7/site-packages/gunicorn/workers/sync.py", line 171, in handle_request respiter = self.wsgi(environ, resp.start_response) File "/opt/app-root/src/.local/lib/python2.7/site-packages/falcon/api.py", line 182, in call responder(req, resp, **params) File "/opt/app-root/src/sample.py", line 38, in on_post server.login(os.getenv('GMAIL_USERNAME', 'node2test@gmail.com'), os.getenv('GMAIL_PASSWORD', 'Refresh@2015')) File "/opt/rh/python27/root/usr/lib64/python2.7/smtplib.py", line 622, in login raise SMTPAuthenticationError(code, resp) SMTPAuthenticationError: (534, '5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbtt\n5.7.14 JQ_f-A4EJBjVjsEc6Y4CeYZY7JVkWYEzXKh5dQZYJucleFWz1QLYBc067NY9S1Q4W6G4\n5.7.14 btFmMWA3K9fo8QnQKrJXZaGX_6xO-rHTV-r_DPfVbgXkuX5b3kymx6qAaVEH78Kxq3dWkn\n5.7.14 sfVD_mrfmejKzSnEmayCYVQZCoIQBRwHeNyFeEDIrGQbxRIsCyZzS6nEAO-HYzJi6ki6Z0\n5.7.14 -3_gQvI5ONPI9ecKuoJy4xLRn-r0k> Please log in via your web browser and\n5.7.14 then try again.\n5.7.14 Learn more at\n5.7.14 https://support.google.com/mail/answer/78754 r21sm12911555pfd.95 - gsmtp') 10.1.1.1 - - [12/Feb/2017:01:37:30 +0000] "POST /email HTTP/1.1" 500 - "-" "-"

[2017-02-12 01:41:28 +0000] [27] [ERROR] Error handling request /email Traceback (most recent call last): File "/opt/app-root/src/.local/lib/python2.7/site-packages/gunicorn/workers/sync.py", line 130, in handle self.handle_request(listener, req, client, addr) File "/opt/app-root/src/.local/lib/python2.7/site-packages/gunicorn/workers/sync.py", line 171, in handle_request respiter = self.wsgi(environ, resp.start_response) File "/opt/app-root/src/.local/lib/python2.7/site-packages/falcon/api.py", line 182, in call responder(req, resp, **params) File "/opt/app-root/src/sample.py", line 38, in on_post server.login(os.getenv('GMAIL_USERNAME', 'node2test@gmail.com'), os.getenv('GMAIL_PASSWORD', 'Refresh@2015')) File "/opt/rh/python27/root/usr/lib64/python2.7/smtplib.py", line 622, in login raise SMTPAuthenticationError(code, resp) SMTPAuthenticationError: (534, '5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbsT\n5.7.14 5x8OUufS5GF0rVkjWcS3CKnR9Znq2jjtl00afouVqGEnDWlgGhBp3m3Q7YBVjsNjun33Ts\n5.7.14 Dghryl-Ulrotedz7HJ0r6hJ9Jg2t_9hv0VY0SE16o9pXUtwHoYG8DnJj1guv7p_a3val5e\n5.7.14 cIVWjpBdmJIaLiMtzgRJJFVweDsk7oG4SlsfcaizdQlWD_9H7w0MGVAcKSgZq7fp7rtPg1\n5.7.14 DyfQKg-zhu2qmZykC4maYrtl1TvT4> Please log in via your web browser and\n5.7.14 then try again.\n5.7.14 Learn more at\n5.7.14 https://support.google.com/mail/answer/78754 n8sm13073682pgc.16 - gsmtp') 10.1.1.1 - - [12/Feb/2017:01:41:28 +0000] "POST /email HTTP/1.1" 500 - "-" "-"

[root@ose-master ~]#

[root@ose-master ~]# curl http://emailsvc-firsttest.cloudapps.cloud-cafe.in/email Email API 2[root@ose-master ~]#


debianmaster commented 7 years ago

You need to provide correct gmail id/password inside your code and also enable email to allow access without captcha, its little bit tricky, please read on google how to enable email access without captcha

error log has all the details.

prasenforu commented 7 years ago

Thanks for update ...

Looks like now I am close to resolution.

But got another error "Gateway Time-out"

[root@ose-master ~]# curl -X POST -d '{"to":"prasenforu@gmail.com","msg":"test mail"}' -H "Content-Type: application/json" http://emailsvc-msdev.cloudapps.cloud-cafe.in/email

504 Gateway Time-out

The server didn't respond in time.

[root@ose-master ~]# oc logs po/emailsvc-2-i14p7 ---> Serving application with gunicorn (sample:api) ... [2017-02-13 00:32:03 +0000] [1] [INFO] Starting gunicorn 19.4.5 [2017-02-13 00:32:03 +0000] [1] [INFO] Listening at: http://0.0.0.0:8080 (1) [2017-02-13 00:32:03 +0000] [1] [INFO] Using worker: sync [2017-02-13 00:32:03 +0000] [27] [INFO] Booting worker with pid: 27 [2017-02-13 00:32:03 +0000] [28] [INFO] Booting worker with pid: 28 10.1.0.1 - - [13/Feb/2017:00:33:05 +0000] "GET /email HTTP/1.1" 200 11 "-" "curl/7.29.0" [2017-02-13 00:33:48 +0000] [1] [CRITICAL] WORKER TIMEOUT (pid:28) [2017-02-13 00:33:49 +0000] [29] [INFO] Booting worker with pid: 29 10.1.0.1 - - [13/Feb/2017:00:34:25 +0000] "GET /email HTTP/1.1" 200 11 "-" "curl/7.29.0" 10.1.0.1 - - [13/Feb/2017:00:34:51 +0000] "GET /email HTTP/1.1" 200 11 "-" "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.81 Safari/537.36" [2017-02-13 00:35:00 +0000] [1] [CRITICAL] WORKER TIMEOUT (pid:27) [2017-02-13 00:35:01 +0000] [30] [INFO] Booting worker with pid: 30 [2017-02-13 00:36:11 +0000] [1] [CRITICAL] WORKER TIMEOUT (pid:29) [2017-02-13 00:36:12 +0000] [31] [INFO] Booting worker with pid: 31 [root@ose-master ~]# [root@ose-master ~]# curl http://emailsvc-msdev.cloudapps.cloud-cafe.in/email Email API 2[root@ose-master ~]# [root@ose-master ~]#

debianmaster commented 7 years ago

sorry for the late response, did you look at logs ? oc logs python-pod