-
Notifications
You must be signed in to change notification settings - Fork 34
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
Support Google Cloud SQL #12
Comments
As expected, the errors were as follows: Failed to execute query "SELECT * FROM pg_authid WHERE rolname != 'pg_signal_backend';":
File "/Users/tmurphy/.local/share/virtualenvs/pgbedrock-x_-HagMe/lib/python3.6/site-packages/pgbedrock/common.py", line 56, in run_query
cursor.execute(query)
File "/Users/tmurphy/.local/share/virtualenvs/pgbedrock-x_-HagMe/lib/python3.6/site-packages/psycopg2/extras.py", line 144, in execute
return super(DictCursor, self).execute(query, vars) |
Hey Taylor, Man, not being able to use any SUPERUSER functionality is a huge blow here. pgbedrock relies on being able to become other users in order to grant default privileges, alter object ownership, and modify roles. I'm curious how those things are done in the Cloud SQL world without a superuser. Taking the last piece as an example (modifying roles), how would you currently change a role's ability to login, its connection limit, etc.? It's also possible that I'm misinterpreting that statement in their docs: is there the concept of a superuser at all? What happens if you do
Even if that above fails, can you log in as the Lastly, was there anything after that colon in the first line of the traceback? Or was there more to the traceback? Thanks! |
Thanks @zcmarine for the thoughtful response. Here's what I see as the default for CloudSQL roles:
So there is a superuser, but it's managed by cloudsql. As far as I can tell, I have no ability to login as the superuser. Trying to create a superuser role from the I'm able to create roles with the Using the verbose option on
Even with this not working, I'm planning on using the YAML format to document how the roles in CloudSQL are organized so that we can version control it and make it easier to reason about. The "nice to have" feature for me would be to use the YAML to validate that the permissions line up as expected and just return information about where there is a mismatch. Checking what permissions are granted to users should be able to be done by the |
Hey, sorry for the slow response. Man, that's really interesting. I can see the security benefit in not allowing superusers to exist / connect, though it definitely adds a big (probably insurmountable) wrinkle here. The one thing I do wonder about though is how that With that said, it's possible that the Postgres role can do most of what you want, particularly if you're focused mostly on permission management. Have you tried running pgbedrock with the other submodules off and seeing if it will run? I.e. Manually create a YAML file with the various roles in it and then do
It's possible that the postgres role has enough access to do everything you need there. Unfortunately, you may be forced to generate the permissions deductively, i.e. look at what pgbedrock would have removed and then add that to your YAML spec, which is kind of painstaking. However, if this runs at all and that would meet your needs, it would be a small lift to modify One last line of inquiry: it's possible that pgbedrock generate is failing in part because of the tables that it can access / that exist. This is copied from the Redshift issue (#9) and shows which tables that pgbedrock relies on do not exist:
If anything comes back then that indicates something we'd need to modify in pgbedrock. Additionally, you might run a Hopefully at least something in the above is useful; I'm kind of throwing out a bunch of ideas and hoping we can get something workable from at least one of them. Zach |
@zcmarine Thanks for the response and apologies for taking so long to try this out. Here's what I'm seeing.
It asks for a password and bombs out. According to the docs "This user account is used by automated processes that need to access the data in your instance (for example, backing up your instance or performing an import or export)." Similarly, sudoing returns
So I combined the
$ pgbedrock configure -U postgres -w "MYPASSWORD" -d dw_production --verbose --no-attributes --no-memberships --no-ownerships --privileges spec.yml
DEBUG:privileges.py:analyze_privileges:35 - Starting analyze_privileges() Traceback (most recent call last): Repeating it causes it to KeyError on different table names. Maybe I have something wrong in the spec definition? Playing around with it the only change I could get is still this error
So! Playing around with this as I was writing the comment... I did a global find and replace in the project for When I used a simplified spec.yml (see details) it actually tried to execute a bunch of commands! =>
And on and on. The final error on that being:
spec that spits out revoke statements and the error in execute analytics:
can_login: no
is_superuser: no
tmurphy:
can_login: yes
is_superuser: no
member_of:
- analytics But when my spec looks like this: analytics:
can_login: no
is_superuser: no
privileges:
schemas:
write:
- analytics
tmurphy:
can_login: yes
is_superuser: no
member_of:
- analytics It gives me the KeyError. So it does seem like |
Hey Taylor, Regarding the KeyError you were seeing, that makes sense to me. The short answer is that pgbedrock expects that the owner for each schema will show up somewhere in the spec file, and since you only included a subset of the role definitions that isn't true. The longer explanation is that the Note that this is also the explanation for the KeyError you mention in the end of the above comment: The fact that pg_authid is the only missing table in Google Cloud SQL is encouraging. If you replace pg_authid with pg_roles throughout the codebase I would try running The bigger question if the above works is what we want to do about this in the pgbedrock codebase. We want to continue to manage password configuration, and pg_authid is necessary for that. What would seem reasonable to me is:
So in my mind Step 1 is verifying that you can get
|
We'll be getting some resources allocated to this later this month as getting this working with Cloud SQL is becoming a higher priority. PR's will be made here for sure, but we'll be tracking progress in https://gitlab.com/meltano/meltano/issues/195 on the GitLab side. |
Hey Taylor, That's awesome to hear! If it'd be useful to do a Google Hangout or slack conversation once you I went back through the above set of messages and have taken a shot at consolidating what we know: Notes
Known Open Questions
To Do
I'm going to try working on item 3 from the To Dos in the next couple weeks and will keep you |
Hi, @zcmarine!
Works
Works
Works
Looking into permission of the Postgres user I see that it only has:
We can't, I tried: ERROR: must be superuser to alter superusers
PostgreSQL 9.6.6 on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4, 64-bit
As far as I can tell - no, the image must be pure Postgres with the custom settings from Google SQL. Now I'll be looking into TODOs, trying to poke around and undestand the codebase. |
Hey Alex, thanks for the updates! If we can't find anything better, your idea about looking for a The inability to impersonate other roles is going to add a real wrinkle here since default privileges are based on which user does the grant. I'm assuming that Google Cloud SQL has default privileges since Taylor said that the |
Hey Zack, Yep, let's stick to the As I understood Taylors requirments are:
Since Currently working on PR that would show inital ideas of how the indentification of the Google Cloud SQL would work to get your initial feedback on the approach. |
A similar problem exists for running on AWS RDS. Might be useful (if not too difficult) to generalize the handling for "semi-limited" environments like Google Cloud SQL and AWS RDS? |
Similar to #9 I'd be very interested in using this to manage users on our Cloud SQL instance. Unfortunately, per the docs "any features that require
SUPERUSER
privileges" are not supported.I'm working on testing this using the default postgres user, so I don't know exactly what any errors might be. But, this would still be very useful as a validation check against existing privileges.
Is there a route to rework the tool so that it could a) validate roles against a specified YAML role, b) write out the SQL that would have to be run to make any adjustments and c) all while using a non superuser role?
Basically, I'd see this as part of our test suite that would create an error if something was off, but wouldn't take action on it.
The text was updated successfully, but these errors were encountered: