Bug 1373900 - "db-control start" returns 0 and does not complain when it fails
Summary: "db-control start" returns 0 and does not complain when it fails
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Satellite 5
Classification: Red Hat
Component: Server
Version: unspecified
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Eric Herget
QA Contact: Lukáš Hellebrandt
URL:
Whiteboard:
Depends On:
Blocks: sat580-low
TreeView+ depends on / blocked
 
Reported: 2016-09-07 11:52 UTC by Lukáš Hellebrandt
Modified: 2017-06-21 12:09 UTC (History)
5 users (show)

Fixed In Version: spacewalk-web-2.7.1-1 or spacewalk-web-2.5.2-8-sat
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-06-21 12:09:24 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Lukáš Hellebrandt 2016-09-07 11:52:52 UTC
Description of problem:
When db-control start fails to start the Embedded or Managed DB, it returns 0 and masks error messages

How reproducible:
Deterministic

Steps to Reproduce:
1.
# db-control stop

2.
# sed s/${rhnSchemaName}/${rhnSchemaName}x/ /var/lib/pgsql/data/pg_hba.conf

3.
# db-control start
Starting postgresql service:                               [  OK  ]
# echo $?
0
# db-control status
The database is offline.


Actual results:
The database does not run but $? is 0 and no errors were shown (they are in /var/lib/pgsql/data/pg_log/postgresql-$DAY.log)

Expected results:
When something fails, db-control tool should let the user know

Comment 1 Eric Herget 2016-09-26 21:07:13 UTC
spacewalk.github:
d341f2d112e6195bc33e206820a1de9f5b07111e

Comment 3 Lukáš Hellebrandt 2016-11-04 10:11:25 UTC
When the start fails, the result looks like the following:

--
Starting rh-postgresql95-postgresql service:               [  OK  ]
Database failed to start.  The database is offline.
--

1) I think "OK" highlighted in green is not a very intuitive way to show something failed

2) Worse, when starting the database as part of "rhn-satellite start", only the first line is shown and no problem is indicated whatsoever.

Comment 4 Tomas Lestach 2016-11-07 08:40:43 UTC
LukasH, what is the motive for moving the BZ into MODIFIED state?

I think the 'green OK' is coming form the postgresql service itself. In case you think it should behave in a different way, please, open a BZ against postgresql in RHSCL.

Comment 5 Lukáš Hellebrandt 2016-11-07 11:11:43 UTC
The motive is described in comment 3.

You are right, green OK comes from the service itself. Then also the output of "db-control start" is understandable, though not very intuitive; it merely says the service was started successfully and then the database is offline regardless.

Still, "rhn-satellite restart" does not warn when DB start fails. That is not, however, issue in db-control.

If you are sure this is the behavior you want, put the bug back to ON_QA and I can verify it:

Comment 6 Eric Herget 2016-11-09 20:35:04 UTC
How about I change the message from

"Database failed to start. The database is offline."

to

"Unable to connect to the database.  It may be offline."

Of course this would still be under the output from the service which contains the green "OK".

I'd like to change the message as part of the work for this bz.  I would open a separate bz to investigate and change the output of "rhn-satellite restart" command.

I'll give a day or two for comments on the above proposal.  If no objections or better suggestions, I'll do as described.

Comment 8 Eric Herget 2016-11-23 14:12:09 UTC
Updated output when db-control start fails to connect to database.

Comment 9 Eric Herget 2016-11-23 14:13:04 UTC
additional spacewalk.github:
907349668bdee70dc396a50aece632b45ff71e54

Comment 11 Lukáš Hellebrandt 2016-12-07 11:10:34 UTC
Verified on Sat5.8 from 2016-11-06.

Used a reproducer from OP, the pg_hba.conf file's path has changed to /var/opt/rh/rh-postgresql95/lib/pgsql/data/pg_hba.conf .

When the config is incorrect, the output now looks like this:
***
Starting rh-postgresql95-postgresql service:               [  OK  ]
Unable to connect to database to determine status.  If database service
started successfully, check configuration in rhn.conf.
***

This seems understandable enough.

Note that when restarting the database using "rhn-satellite restart", only the first row is shown and thus no problem is indicated.


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