-
Notifications
You must be signed in to change notification settings - Fork 189
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
fix: grant role before creating database #5828
Conversation
In some postgresql installations, the following fails: template1=> create user test; CREATE ROLE template1=> create database test owner test; ERROR: must be member of role "test" This is fixed by template1=> grant test to azureuser; GRANT ROLE template1=> create database test owner test; CREATE DATABASE Furthermore, granting privileges to the owner is superfluous according to the postgresql docs, so we drop it. The investigation of this issue also surfaces a bug in the error message for "manual database creation", and that the `--su-db-name` was not passed on from the commandline.
3773a1d
to
d6f68ad
Compare
The error is
I.e. somehow |
When using peer authentication, the `dsn['user']` in PGSU is `None`.
I see - inside the container, going via the default We can use the |
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.
Thanks @ltalirz some minor comments
@@ -177,8 +178,8 @@ def quicksetup( | |||
'Oops! quicksetup was unable to create the AiiDA database for you.', | |||
'See `verdi quicksetup -h` for how to specify non-standard parameters for the postgresql connection.\n' | |||
'Alternatively, create the AiiDA database yourself: ', | |||
manual_setup_instructions(dbuser=su_db_username, | |||
dbname=su_db_name), '', 'and then use `verdi setup` instead', '' | |||
manual_setup_instructions(db_username=db_username, |
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.
Not concerning this line, but line 184: should we just reraise the exception? Isn't it better to simply use echo.echo_critical
? Usually showing a scary traceback by default to a user from a CLI command is not a good idea.
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.
Also just noted that the instructions above (to use verdi quicksetup -h
for help) were wrong for a long time and only (coincidentally) got fixed just two weeks ago in 6469e23 😄
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.
Sometimes the traceback can also help to see where the problem is... let me know if you want me to change it
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 is a reusable option that we have --traceback
that will optionally show the traceback which I think can be useful. But we can leave it for now, it is not critical
aiida/manage/external/postgres.py
Outdated
@@ -108,6 +108,8 @@ def create_dbuser(self, dbuser, dbpass, privileges=''): | |||
self.connection_mode == PostgresConnectionMode.PSYCOPG | |||
""" | |||
self.execute(_CREATE_USER_COMMAND.format(dbuser, dbpass, privileges)) | |||
# this is needed on some postgresql installations |
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.
Could you please add more info on what this is doing? It seems quite weird to GRANT
a user to current_user
. What does that mean? Grant all rights that dbuser
has also to current_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.
I've updated the comment. Let me know whether it is understandable now
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.
Cheers.
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.
Thanks @ltalirz
Yes, that is fixed now (meaning you can now use AiiDA with the hosted Azure Database for Postgresql out of the box). |
In some postgresql installations, the following fails:
This is fixed by
Furthermore, granting privileges to the owner is superfluous according to the postgresql docs, so we drop it.
The investigation of this issue also surfaces a bug in the error message for "manual database creation", and that the
--su-db-name
was not passed on from the commandline. This is fixed in passing.