Bug 964333 - rhn-satellite-activate --disconnect fails because driver_postgresql.py sets host=None instead of host=localhost
rhn-satellite-activate --disconnect fails because driver_postgresql.py sets h...
Status: CLOSED NOTABUG
Product: Spacewalk
Classification: Community
Component: Installation (Show other bugs)
1.10
All Linux
low Severity low
: ---
: ---
Assigned To: Jan Pazdziora
Red Hat Satellite QA List
:
Depends On:
Blocks: space27
  Show dependency treegraph
 
Reported: 2013-05-17 17:44 EDT by Michele Baldessari
Modified: 2017-09-28 14:08 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2013-05-18 09:14:38 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Michele Baldessari 2013-05-17 17:44:33 EDT
Description of problem:
In my postgresq DB I have "ident" as auth method when using Unix sockets and "md5" for anything else. In this scenario, rhn-satellite-activate will fail because /usr/lib/python2.7/site-packages/spacewalk/server/rhnSQL/driver_postgresql.py has the following code:

class Database(sql_base.Database):
    """ Class for PostgreSQL database operations. """

    def __init__(self, host=None, port=None, username=None,
                 password=None, database=None):

        if host is None or host == '' or host == 'localhost':
            self.host = None
            self.port = None
        else:
            self.host = host
            self.port = port


I have host = localhost in /etc/rhn/rhn.conf and the above will try to connect without having set 'host' to anything and the connect will fail due to wrong auth:
init.py:179:connect:SQLConnectError: (None, None, 'spacewalk', 'Attempting Re-Connect to the database failed')

Traceback (most recent call last):
  File "/usr/bin/rhn-satellite-activate", line 42, in <module>
    sys.exit(abs(mod.main() or 0))
  File "/usr/lib/python2.7/site-packages/spacewalk/satellite_tools/rhn_satellite_activate.py", line 580, in main
    rhnSQL.initDB()
  File "/usr/lib/python2.7/site-packages/spacewalk/server/rhnSQL/init.py", line 102, in initDB
    initDB(backend, host, port, username, password, database)
  File "/usr/lib/python2.7/site-packages/spacewalk/server/rhnSQL/init.py", line 55, in initDB
    __DB.connect()
  File "/usr/lib/python2.7/site-packages/spacewalk/server/rhnSQL/driver_postgresql.py", line 174, in connect
    return self.connect(reconnect=0)
  File "/usr/lib/python2.7/site-packages/spacewalk/server/rhnSQL/driver_postgresql.py", line 163, in connect
    password=self.password)
  File "/usr/lib64/python2.7/site-packages/psycopg2/init.py", line 179, in connect
    connection_factory=connection_factory, async=async)
SQLConnectError: (None, None, 'spacewalk', 'Attempting Re-Connect to the database failed')

If I change the line "if host is None or host == '' or host == 'localhost':"
to " if host is None or host == ''": things are fine.

Version-Release number of selected component (if applicable):
# rpm -qf /usr/lib/python2.7/site-packages/spacewalk/server/rhnSQL/driver_postgresql.py
spacewalk-backend-sql-postgresql-1.10.32-1.fc18.noarch
Comment 1 Jan Pazdziora 2013-05-18 09:14:38 EDT
(In reply to comment #0)
> Description of problem:
> In my postgresq DB I have "ident" as auth method when using Unix sockets and

You PostgreSQL setup is incorrect then -- please consult

   https://fedorahosted.org/spacewalk/wiki/PostgreSQLServerSetup

for the settings that work with Spacewalk.
Comment 2 Eric Herget 2017-09-28 14:08:00 EDT
This BZ closed some time during 2.5, 2.6 or 2.7.  Adding to 2.7 tracking bug.

Note You need to log in before you can comment on or make changes to this bug.