Bug 1414855 - taskotop cannot handle db connection problems
Summary: taskotop cannot handle db connection problems
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Satellite 5
Classification: Red Hat
Component: Other
Version: 580
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Gennadii Altukhov
QA Contact: Lukáš Hellebrandt
URL:
Whiteboard:
Depends On:
Blocks: 1340444
TreeView+ depends on / blocked
 
Reported: 2017-01-19 15:27 UTC by Ales Dujicek
Modified: 2017-06-21 12:19 UTC (History)
4 users (show)

Fixed In Version: spacewalk-utils-2.5.1-14-sat
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-06-21 12:19:11 UTC
Target Upstream Version:


Attachments (Terms of Use)

Description Ales Dujicek 2017-01-19 15:27:06 UTC
Description of problem:

taskotop cannot run when database is not running

# db-control stop
# taskotop 
Traceback (most recent call last):
  File "/usr/bin/taskotop", line 172, in <module>
    curses.wrapper(main)
  File "/usr/lib64/python2.6/curses/wrapper.py", line 43, in wrapper
    return func(stdscr, *args, **kwds)
  File "/usr/bin/taskotop", line 150, in main
    rhnSQL.initDB()
  File "/usr/lib/python2.6/site-packages/spacewalk/server/rhnSQL/__init__.py", line 158, in initDB
    raise_with_tb(e, sys.exc_info()[2])
  File "/usr/lib/python2.6/site-packages/spacewalk/server/rhnSQL/__init__.py", line 145, in initDB
    __init__DB(backend, host, port, username, password, database, sslmode, sslrootcert)
  File "/usr/lib/python2.6/site-packages/spacewalk/server/rhnSQL/__init__.py", line 57, in __init__DB
    __DB.connect()
  File "/usr/lib/python2.6/site-packages/spacewalk/server/rhnSQL/driver_postgresql.py", line 195, in connect
    return self.connect(reconnect=reconnect - 1)
  File "/usr/lib/python2.6/site-packages/spacewalk/server/rhnSQL/driver_postgresql.py", line 200, in connect
    "All attempts to connect to the database failed"), sys.exc_info()[2])
  File "/usr/lib/python2.6/site-packages/spacewalk/server/rhnSQL/driver_postgresql.py", line 185, in connect
    self.dbh = psycopg2.connect(" ".join("%s=%s" % (k, re.escape(str(v))) for k, v in dsndata.items()))
spacewalk.server.rhnSQL.sql_base.SQLConnectError: (None, None, 'rhnschema', 'All attempts to connect to the database failed')


and fails if you stop database when it runs

# taskotop 
Traceback (most recent call last):
  File "/usr/bin/taskotop", line 172, in <module>
    curses.wrapper(main)
  File "/usr/lib64/python2.6/curses/wrapper.py", line 43, in wrapper
    return func(stdscr, *args, **kwds)
  File "/usr/bin/taskotop", line 162, in main
    [format_run(run) for run in get_tasko_runs(60)]
  File "/usr/bin/taskotop", line 47, in get_tasko_runs
    task_query.execute(timelimit = datetime.datetime.now() - datetime.timedelta(seconds=maximum_age))
  File "/usr/lib/python2.6/site-packages/spacewalk/server/rhnSQL/sql_base.py", line 151, in execute
    return self._execute_wrapper(self._execute, *p, **kw)
  File "/usr/lib/python2.6/site-packages/spacewalk/server/rhnSQL/driver_postgresql.py", line 296, in _execute_wrapper
    retval = function(*p, **kw)
  File "/usr/lib/python2.6/site-packages/spacewalk/server/rhnSQL/sql_base.py", line 205, in _execute
    return self._execute_(args, kwargs)
  File "/usr/lib/python2.6/site-packages/spacewalk/server/rhnSQL/driver_postgresql.py", line 318, in _execute_
    self._real_cursor.execute(self.sql, params)
psycopg2.OperationalError: server closed the connection unexpectedly
	This probably means the server terminated abnormally
	before or while processing the request.

I would expect some user friendly error messages instead of tracebacks



Version-Release number of selected component (if applicable):
spacewalk-utils-2.5.1-10.el6sat.noarch

How reproducible:
always

Steps to Reproduce:
1. taskotop
2. db-control stop / rhn-satellite-restart

Actual results:
tracebacks

Expected results:
error messages

Comment 1 Gennadii Altukhov 2017-02-15 17:41:11 UTC
fixed in upstream, spacewalk.git:
b2af1e83668c57ded3dc55b76bc0371aa49c2f4c

Comment 4 Lukáš Hellebrandt 2017-05-24 11:46:48 UTC
Verified with spacewalk-utils-2.5.1-23

Taskotop now returns these sensible error messages:

* When database is stopped while taskotop is running:

ERROR: Some problems occurred during getting information about tasks: Cannot execute SQL statement: server closed the connection unexpectedly
        This probably means the server terminated abnormally
        before or while processing the request.

* When database is stopped before taskotop is started:
ERROR: Can't connect to the database: (None, None, 'rhnschema', 'All attempts to connect to the database failed')
Check if your database is running.


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