-
Notifications
You must be signed in to change notification settings - Fork 169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clarify steps needed for Cloud SQL #1928
Conversation
Notifying subscribers in CODENOTIFY files for diff b807166...6a24673.
|
|
||
- Default db {[Password](https://my.1password.com/vaults/dnrhbauihkhjs5ag6vszsme45a/allitems/svfiw4vcbxhhbobpl442olyebu/)} | ||
``` | ||
gcloud beta sql connect --project sourcegraph-dev sg-cloud-732a936743 --user=sg -d=sg |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't work for me
% gcloud beta sql connect --project sourcegraph-dev sg-cloud-732a936743 --user=sg -d=sg
ERROR: (gcloud.beta.sql.connect) Cloud SQL Proxy could not be found in PATH. See https://cloud.google.com/sql/docs/mysql/sql-proxy#install for information on installing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, I thought it prompted to install the beta utils if you did not have them
You do not currently have this command group installed. Using it
requires the installation of components: [beta]
Your current Cloud SDK version is: 310.0.0
Installing components from version: 310.0.0
┌─────────────────────────────────────────────┐
│ These components will be installed. │
├──────────────────────┬────────────┬─────────┤
│ Name │ Version │ Size │
├──────────────────────┼────────────┼─────────┤
│ gcloud Beta Commands │ 2019.05.17 │ < 1 MiB │
└──────────────────────┴────────────┴─────────┘
For the latest full release notes, please visit:
https://cloud.google.com/sdk/release_notes
Do you want to continue (Y/n)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What makes you think I don't have beta tools installed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like the cloud-sql-proxy is not installed as part of the beta tools. I thought it was.
|
||
You may use these gcloud commands to connect directly to the databases: | ||
|
||
- Default db {[Password](https://my.1password.com/vaults/dnrhbauihkhjs5ag6vszsme45a/allitems/svfiw4vcbxhhbobpl442olyebu/)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how/where is the password provided?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The login should prompt for it
https://console.cloud.google.com/bigquery?sq=527047051561:67f2616f4acb4b7cb3639e4a97e2f4aa | ||
) and their `EXTERNAL_QUERY` syntax. | ||
|
||
There are two ways of connecting: either using the `gcloud beta sql connect` command or running the proxy on a port locally. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a developer, how do I know which way to choose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gcloud is mainly for quick pgsql
commands, the proxy is used when you want to connect an external database viewer or GUI program.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two ways of connecting: either using the `gcloud beta sql connect` command or running the proxy on a port locally. | |
There are two ways of connecting: either using the `gcloud beta sql connect` command which will use the `pgsql` client or running the proxy on a port locally to utilize whatever tools you typically use. | |
``` | ||
_Note:_ You may need to set or unset your PGPASSWORD environment variable to the value of the password of the user you are using to connect (`-U sg`). | ||
|
||
If you are frequently using this to access the database for read-only operations, please let the #dev-ops channel know so we can add a read-only replica. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the very least, it seems like we should create a readonly user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For read-only access, there is also an option of using [BigQuery]( | ||
https://console.cloud.google.com/bigquery?sq=527047051561:67f2616f4acb4b7cb3639e4a97e2f4aa | ||
) and their `EXTERNAL_QUERY` syntax. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think using BigQuery might deserve a section of its own, with the full EXTERNAL_QUERY
here (did not realize that it was just a stand-in for a table), e.g. seeing:
SELECT * FROM EXTERNAL_QUERY("...", "SELECT name::text,created_at::text FROM repo LIMIT 5;");
would be a lot more self-explanatory. Seems a lot less setup than the alternative, so for UI-and-mouse noobs like me I would probably go for this more often than not 😛
Co-authored-by: Robert Lin <robert@bobheadxi.dev>
don't wait on my review, ultimately this documentation should make it clear to a new teammate how to connect to the database. The best review here is to have a new teammate walk through these steps and give you feedback on whether they were successful or not (feel free to merge first) |
|
||
- Default db {[Password](https://start.1password.com/open/i?a=HEDEDSLHPBFGRBTKAKJWE23XX4&v=dnrhbauihkhjs5ag6vszsme45a&i=pjxf64qxwsin4d56xij6vm3gva&h=my.1password.com)} | ||
``` | ||
gcloud beta sql connect --project sourcegraph-dev sg-cloud-732a936743 --user=dev-readonly -d=sg |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to export CLOUDSDK_PYTHON=python2
. I have both 2 and 3 installed, 2 appears first in my path, but it looks like 3 gets chosen anyway:
Python 3 is preferred over Python 2. Note that gcloud requires Python version 2.7.x or 3.5-3.8.
I have 2.7 and 3.9, so without the environment variable I get AttributeError: module 'importlib' has no attribute 'util'
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you find this command useful or do you just use the proxy by itself?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me personally, the command is useful. I don't generally use a GUI or similar tool for PG access.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worked for me, just left a couple of notes/questions
This adds additional clarification for how to access our production databases
Followup to https://sourcegraph.slack.com/archives/D012ZE3Q5J7/p1604332857000100