balderdashy / sails

Realtime MVC Framework for Node.js
https://sailsjs.com
MIT License
22.81k stars 1.95k forks source link

App Engine Deployment with Cloud SQL #7004

Open rajanbharti opened 4 years ago

rajanbharti commented 4 years ago

Node version: 12.16.0 Sails version (sails): 1.2.4 ORM hook version (sails-hook-orm): 2.1.1 Sockets hook version (sails-hook-sockets): 2.0.0 Grunt hook version (sails-hook-grunt): 4.0.0 DB adapter & version (e.g. sails-mysql@5.55.5): sails-postgresql@1.0.2


I was able to deploy with GCP app engine in flex environment. But I am anot able to access my cloudsql postgres resource. As app engine supports different notation [/cloudsql/INSTANCE_CONNECTION_NAME] to represent resources in app engine. https://cloud.google.com/sql/docs/mysql/connect-app-engine-flexible. If I am using that notation, in application logs. it defaults to localhost for db

sailsbot commented 4 years ago

@rajanbharti Thanks for posting! We'll take a look as soon as possible.

In the mean time, there are a few ways you can help speed things along:

Please remember: never post in a public forum if you believe you've found a genuine security vulnerability. Instead, disclose it responsibly.

For help with questions about Sails, click here.

rajanbharti commented 4 years ago

I think it is same as this issue

https://github.com/balderdashy/sails/issues/6888

johnabrams7 commented 4 years ago

@rajanbharti Thanks for letting us know, what does your production datastore config currently look like?

rajanbharti commented 4 years ago
 adapter: 'sails-postgresql',
 url:postgresql://<username>:<password>@/testdb?unix_socket=/cloudsql/gothic-sequence-245119:northamerica-northeast1:testdb,
 charset: 'utf8mb4',
 timezone: 'utc',
 pool: true,
 connectionLimit: 10,
mikermcneil commented 4 years ago

@rajanbharti Haven't used PostgreSQL as my database on Google Cloud Platform before, but one thing jumping out in the code above is the unescaped "/" characters in the query string. Have you tried doing:

`?unix_socket=${encodeURIComponent('/cloudsql/gothic-sequence-245119:northamerica-northeast1:testdb')}`
justinforlenza commented 3 years ago

I tried the solution brought up by @mikermcneil, Doesn't seem to be working.

At least what I can decode from the error logs seems like it is still attempting to connect via localhost instead of the socket.

Seems like still waiting on a fix for #6888 and #6880 ....

Screenshot 2021-05-16 132023

eashaw commented 3 years ago

Hi @justinforlenza, have you tried using the workaround posted in #6888?