Unable to connect to postgres database on oVirt engine

I am unable to connect to postgres database running on oVirt engine and while troubleshooting found below possible issue. semanage fcontext -a -t postgresql_exec_t /opt/rh/rh-postgresql10/root/usr/bin/psql ValueError: File spec /opt/rh/rh-postgresql10/root/usr/bin/psql conflicts with equivalency rule '/opt/rh/rh-postgresql10/root /'; Try adding '//usr/bin/psql' instead Can someone help to resolve this issue.

Hi, Which version of the engine are you using? On Tue, Oct 20, 2020 at 4:59 PM <kushagra2agarwal@gmail.com> wrote:
I am unable to connect to postgres database running on oVirt engine and while troubleshooting found below possible issue.
How do you try to connect?
semanage fcontext -a -t postgresql_exec_t /opt/rh/rh-postgresql10/root/usr/bin/psql ValueError: File spec /opt/rh/rh-postgresql10/root/usr/bin/psql conflicts with equivalency rule '/opt/rh/rh-postgresql10/root /'; Try adding '//usr/bin/psql' instead
Why do you think psql needs postgresql_exec_t type? On my test engine, I have: $ ls -lZ /opt/rh/rh-postgresql10/root/usr/bin/psql -rwxr-xr-x. root root system_u:object_r:bin_t:s0 /opt/rh/rh-postgresql10/root/usr/bin/psql and everything works well. psql is not the PG server/daemon - it's just a user utility, it does not need access to PG data or anything like that. BTW, there is a utility script for running psql against the engine DB, working in every version (since it was introduced) - e.g.: /usr/share/ovirt-engine/dbscripts/engine-psql.sh -c 'select * from vms' Generally speaking, you should not need to modify the DB. Best regards, -- Didi

@Didi thanks for your response, we are trying to pull postgres db metrics using collectd agent but while trying to get metrics we are getting below error. We are pulling creds from file '/etc/ovirt-engine/engine.conf.d/10-setup-database.conf' oVirt engine version 4.3.10 Any thoughts on what else can be the issue than. Failed to connect to database engine (engine): could not connect to server: Permission denied

On Tue, Oct 20, 2020 at 5:25 PM <kushagra2agarwal@gmail.com> wrote:
@Didi thanks for your response, we are trying to pull postgres db metrics using collectd agent but while trying to get metrics we are getting below error. We are pulling creds from file '/etc/ovirt-engine/engine.conf.d/10-setup-database.conf'
oVirt engine version 4.3.10
Any thoughts on what else can be the issue than.
Failed to connect to database engine (engine): could not connect to server: Permission denied
Did you try engine-psql.sh as I suggested? Best regards, -- Didi

I usually run the following (HostedEngine): [root@engine ~]# su - postgres -bash-4.2$ source /opt/rh/rh-postgresql10/enable -bash-4.2$ psql engine How did you try to access the Engine's DB ? Best Regards, Strahil Nikolov В вторник, 20 октомври 2020 г., 17:00:37 Гринуич+3, kushagra2agarwal@gmail.com <kushagra2agarwal@gmail.com> написа: I am unable to connect to postgres database running on oVirt engine and while troubleshooting found below possible issue. semanage fcontext -a -t postgresql_exec_t /opt/rh/rh-postgresql10/root/usr/bin/psql ValueError: File spec /opt/rh/rh-postgresql10/root/usr/bin/psql conflicts with equivalency rule '/opt/rh/rh-postgresql10/root /'; Try adding '//usr/bin/psql' instead Can someone help to resolve this issue. _______________________________________________ Users mailing list -- users@ovirt.org To unsubscribe send an email to users-leave@ovirt.org Privacy Statement: https://www.ovirt.org/privacy-policy.html oVirt Code of Conduct: https://www.ovirt.org/community/about/community-guidelines/ List Archives: https://lists.ovirt.org/archives/list/users@ovirt.org/message/JPWYVOHDVRLNIS...

On Wed, Oct 21, 2020 at 9:16 PM Strahil Nikolov via Users <users@ovirt.org> wrote:
I usually run the following (HostedEngine):
[root@engine ~]# su - postgres
-bash-4.2$ source /opt/rh/rh-postgresql10/enable
This is applicable to 4.3, on el7. For 4.4 this isn't needed. Also, IIRC this isn't the official method to activate an SCL component, but: $ scl enable rh-postgresql10 bash Which is a significant difference - it runs a process ('bash', in this case, but you can run psql directly) "inside" the environment. A somewhat more official (although IIRC still not the recommended) way is: . scl_source enable rh-postgresql10 (Or 'source' instead of '.', although '.' is the POSIX standard).
-bash-4.2$ psql engine
This works if the engine db is automatically provisioned by engine-setup (which is the default). engine-psql.sh works regardless of version, remote or not, etc. It's a pretty simple script - you can easily read it to see what it does. Best regards,
How did you try to access the Engine's DB ?
Best Regards, Strahil Nikolov
В вторник, 20 октомври 2020 г., 17:00:37 Гринуич+3, kushagra2agarwal@gmail.com <kushagra2agarwal@gmail.com> написа:
I am unable to connect to postgres database running on oVirt engine and while troubleshooting found below possible issue.
semanage fcontext -a -t postgresql_exec_t /opt/rh/rh-postgresql10/root/usr/bin/psql ValueError: File spec /opt/rh/rh-postgresql10/root/usr/bin/psql conflicts with equivalency rule '/opt/rh/rh-postgresql10/root /'; Try adding '//usr/bin/psql' instead
Can someone help to resolve this issue. _______________________________________________ Users mailing list -- users@ovirt.org To unsubscribe send an email to users-leave@ovirt.org Privacy Statement: https://www.ovirt.org/privacy-policy.html oVirt Code of Conduct: https://www.ovirt.org/community/about/community-guidelines/ List Archives: https://lists.ovirt.org/archives/list/users@ovirt.org/message/JPWYVOHDVRLNIS... _______________________________________________ Users mailing list -- users@ovirt.org To unsubscribe send an email to users-leave@ovirt.org Privacy Statement: https://www.ovirt.org/privacy-policy.html oVirt Code of Conduct: https://www.ovirt.org/community/about/community-guidelines/ List Archives: https://lists.ovirt.org/archives/list/users@ovirt.org/message/LKCIV56ELQRI4H...
-- Didi

Hi Didi, thanks for the info - I learned it the hard way (trial & error) and so far it was working. Do we have an entry about that topic in the documentation ? Best Regards, Strahil Nikolov В четвъртък, 22 октомври 2020 г., 08:27:08 Гринуич+3, Yedidyah Bar David <didi@redhat.com> написа: On Wed, Oct 21, 2020 at 9:16 PM Strahil Nikolov via Users <users@ovirt.org> wrote:
I usually run the following (HostedEngine):
[root@engine ~]# su - postgres -bash-4.2$ source /opt/rh/rh-postgresql10/enable
This is applicable to 4.3, on el7. For 4.4 this isn't needed. Also, IIRC this isn't the official method to activate an SCL component, but: $ scl enable rh-postgresql10 bash Which is a significant difference - it runs a process ('bash', in this case, but you can run psql directly) "inside" the environment. A somewhat more official (although IIRC still not the recommended) way is: . scl_source enable rh-postgresql10 (Or 'source' instead of '.', although '.' is the POSIX standard).
-bash-4.2$ psql engine
This works if the engine db is automatically provisioned by engine-setup (which is the default). engine-psql.sh works regardless of version, remote or not, etc. It's a pretty simple script - you can easily read it to see what it does. Best regards,
How did you try to access the Engine's DB ?
Best Regards, Strahil Nikolov
В вторник, 20 октомври 2020 г., 17:00:37 Гринуич+3, kushagra2agarwal@gmail.com <kushagra2agarwal@gmail.com> написа:
I am unable to connect to postgres database running on oVirt engine and while troubleshooting found below possible issue.
semanage fcontext -a -t postgresql_exec_t /opt/rh/rh-postgresql10/root/usr/bin/psql ValueError: File spec /opt/rh/rh-postgresql10/root/usr/bin/psql conflicts with equivalency rule '/opt/rh/rh-postgresql10/root /'; Try adding '//usr/bin/psql' instead
Can someone help to resolve this issue. _______________________________________________ Users mailing list -- users@ovirt.org To unsubscribe send an email to users-leave@ovirt.org Privacy Statement: https://www.ovirt.org/privacy-policy.html oVirt Code of Conduct: https://www.ovirt.org/community/about/community-guidelines/ List Archives: https://lists.ovirt.org/archives/list/users@ovirt.org/message/JPWYVOHDVRLNIS... _______________________________________________ Users mailing list -- users@ovirt.org To unsubscribe send an email to users-leave@ovirt.org Privacy Statement: https://www.ovirt.org/privacy-policy.html oVirt Code of Conduct: https://www.ovirt.org/community/about/community-guidelines/ List Archives: https://lists.ovirt.org/archives/list/users@ovirt.org/message/LKCIV56ELQRI4H...
-- Didi

On Thu, Oct 22, 2020 at 9:05 PM Strahil Nikolov <hunter86_bg@yahoo.com> wrote:
Hi Didi,
thanks for the info - I learned it the hard way (trial & error) and so far it was working.
Do we have an entry about that topic in the documentation ?
I do not think we have very much about the engine DB or how to access it at all, in the official documentation, because it's usually considered a bug if users have to manually fiddle with that. And if you write your own script to connect to the engine db and do stuff there, and it's broken in some next upgrade, that's considered to be your own problem. We do have lots of official documentation about the DWH database, because accessing it directly (read-only!) is an official API (including compatibility views per version, etc.). Best regards, -- Didi
participants (3)
-
kushagra2agarwal@gmail.com
-
Strahil Nikolov
-
Yedidyah Bar David