Add test for availability of sudo in quicksetup#2333
Conversation
Quicksetup needs to access the Postgres database, but does not know anything about the system setup. It initially tries to see if it is the postgres superuser, but if it is not, it tries to become the postgres superuser via sudo. This is the backstop position and relies on the user having a modern Linux-like system. If, however, the sudo command is not available to this user at all (for example, perhaps on an HPC cluser), an error will be raised and quicksetup will fail ungracefully. This commits add a test to see if sudo can be found before attempting to use it. If it is not, no attempt is made, and the final manual setup message is printed. - Add simple check of the availability of the sudo command to the user. - Add warning message if sudo cannot be found. - Update click.echo calls to the AiiDA echo function. - Update selected messages to 'warning' type messages.
09e56dd to
7549fd5
Compare
|
@yakutovicha will this solve the original issue you had? If I understand correctly it was trying to use |
|
Hi @sphuber , this is an interesting part of the issue. I spent some time looking at how we can connect to the database, but the long and short of it is that without being the postgres user, or another user with superuser permissions for postgres, one needs sudo to create a new database. In normal setup, the user must have created the database already, but in quicksetup it is done automatically. However, in both situations the same constraints are there. |
|
Actually I've found one can start a new instance of Postgres in their user space and connect with their user as a superuser, provided that it's configured to use a port that isn't in use by the system postgres. Should we support this as an option after failing to find sudo? |
|
After discussion with @ltalirz we are going to merge this PR in, but we are keeping issue #1382 open. It looks like there is a bug in the postgres control module that was not properly detecting when a user has postgres rights and so was always defaulting to trying |
Partially addresses #1382
Quicksetup needs to access the Postgres database, but does not know anything about the system setup. It initially tries to see if it is the postgres superuser, but if it is not, it tries to become the Postgres superuser via sudo. This is the "backstop" position and relies on the user having a modern Linux-like system.
If, however, the sudo command is not available to this user at all (for example, perhaps the user is on an HPC cluser with command hidden), a system error will be raised and quicksetup will fail ungracefully.
This commit adds a test to see if sudo can be found before attempting to use it, prints a warning, and then falls back to the 'Postgres not detected' behaviour.