Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 2029807

Summary: foreman-maintain service fails for external postgres service, when no psql utility installed
Product: Red Hat Satellite Reporter: Gaurav Talreja <gtalreja>
Component: Satellite MaintainAssignee: Amit Upadhye <aupadhye>
Status: CLOSED ERRATA QA Contact: Gaurav Talreja <gtalreja>
Severity: high Docs Contact:
Priority: unspecified    
Version: 6.10.1CC: apatel, aupadhye, ehelms, jbhatia, kgaikwad, lvrtelov, pcreech
Target Milestone: 6.11.0Keywords: Triaged
Target Release: Unused   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: rubygem-foreman_maintain-1.0.10 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-07-05 14:30:51 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Gaurav Talreja 2021-12-07 11:00:36 UTC
Description of problem:
foreman-maintain service fails for external Postgres service when no psql utility is installed with message unable to connect to the remote database.


Version-Release number of selected component (if applicable):
Satellite 6.10.1.1
rubygem-foreman_maintain-0.8.21-1.el7sat.noarch

How reproducible:
Always

Steps to Reproduce:
1. Configure repos for satellite, and install satellite package.
2. Install and configure Postgres on rhel as per documentation[1]
3. Run the installer as mentioned in documention[1] to configure satellite with external DB, which fails with BZ 2029793
4. Check the status of the external PostgreSQL service, which fails with the following message,
# foreman-maintain service status --only postgresql
Running Status Services
================================================================================
Get status of applicable services:

Displaying the following service(s):
postgresql (pulpcore), postgresql (candlepin), postgresql (foreman)
/ displaying postgresql (pulpcore)
postgresql (pulpcore) is remote and is DOWN.
  Unable to connect to the remote database.
  See the log (/var/log/foreman-maintain/foreman-maintain.log) for more details.
/ displaying postgresql (candlepin)
postgresql (candlepin) is remote and is DOWN.
  Unable to connect to the remote database.
  See the log (/var/log/foreman-maintain/foreman-maintain.log) for more details.
/ displaying postgresql (foreman)
postgresql (foreman) is remote and is DOWN.
  Unable to connect to the remote database.
  See the log (/var/log/foreman-maintain/foreman-maintain.log) for more details.
/ All services displayed                                              [FAIL]
Some services are not running (postgresql (pulpcore), postgresql (candlepin), postgresql (foreman))
--------------------------------------------------------------------------------


Actual results:
a message like, "Unable to connect to the remote database, see logs"

Expected results:
Message something like, "The psql command not found. Make sure the system has a psql utility installed."


Additional info:
This BZ[2] has provided a similar fail-safe option for backup/restore when psql is unavailable with methods like "psql_cmd_available?" for Postgres and "mongo_cmd_available?" for Mongo.


[1] https://access.redhat.com/documentation/en-us/red_hat_satellite/6.10/html/installing_satellite_server_from_a_connected_network/performing-additional-configuration#using-external-databases_satellite
[2] https://bugzilla.redhat.com/show_bug.cgi?id=1921295

Comment 1 Amit Upadhye 2021-12-13 11:18:58 UTC
Created redmine issue https://projects.theforeman.org/issues/34136 from this bug

Comment 3 Amit Upadhye 2022-05-11 12:07:42 UTC
The 6.11 should stay in 1.0.x versions and accordingly correct version to pick is 1.0.10 and there are cherry picks of psql dependency in that,

https://github.com/theforeman/foreman-packaging/pull/7887

Comment 4 Gaurav Talreja 2022-05-23 18:12:58 UTC
Verified.

Tested on Satellite 6.11.0 Snap 21.0
Version: rubygem-foreman_maintain-1.0.10-1.el7sat.noarch

Steps:
1. Install satellite/rubygem-foreman_maintain packages

Observation:
psql utility comes with a package "rh-postgresql12-postgresql-syspaths" for el7, which is now added as direct dependency to `rubygem-foreman_maintain` package, which fixes both BZ 2029793 and this BZ. 
For EL8 and onward, it is done similarly by requiring /usr/bin/psql in the spec file of `rubygem-foreman_maintain` package.

```
Installed:
  rubygem-foreman_maintain.noarch 1:1.0.10-1.el7sat

Dependency Installed:
  rh-postgresql12-postgresql.x86_64 0:12.9-1.el7                        rh-postgresql12-postgresql-libs.x86_64 0:12.9-1.el7
  rh-postgresql12-postgresql-syspaths.x86_64 0:12.9-1.el7               rh-postgresql12-runtime.x86_64 0:3.4-1.el7
  ruby.x86_64 0:2.0.0.648-39.el7_9                                      ruby-irb.noarch 0:2.0.0.648-39.el7_9
  ruby-libs.x86_64 0:2.0.0.648-39.el7_9                                 rubygem-bigdecimal.x86_64 0:1.2.0-39.el7_9
  rubygem-clamp.noarch 0:1.1.2-7.el7sat                                 rubygem-highline.noarch 0:2.0.3-2.el7sat
  rubygem-io-console.x86_64 0:0.4.2-39.el7_9                            rubygem-json.x86_64 0:1.7.7-39.el7_9
  rubygem-psych.x86_64 0:2.0.0-39.el7_9                                 rubygem-rdoc.noarch 0:4.0.0-39.el7_9
  rubygems.noarch 0:2.0.14.1-39.el7_9                                   scl-utils.x86_64 0:20130529-19.el7

Complete!
```

Comment 7 errata-xmlrpc 2022-07-05 14:30:51 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Moderate: Satellite 6.11 Release), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2022:5498