Bug 1343757 - engine-psql.sh does not log commands when -c option is used
Summary: engine-psql.sh does not log commands when -c option is used
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Enterprise Virtualization Manager
Classification: Red Hat
Component: redhat-support-plugin-rhev
Version: 3.6.3
Hardware: All
OS: Linux
unspecified
low
Target Milestone: ovirt-4.0.0-rc
: 4.0.0
Assignee: Spenser Shumaker
QA Contact: Pavel Stehlik
URL:
Whiteboard:
Depends On:
Blocks: 1344586
TreeView+ depends on / blocked
 
Reported: 2016-06-07 20:22 UTC by Allie DeVolder
Modified: 2016-09-06 06:55 UTC (History)
12 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1344468 1344586 (view as bug list)
Environment:
Last Closed: 2016-09-06 06:55:14 UTC
oVirt Team: Infra
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Allie DeVolder 2016-06-07 20:22:21 UTC
When using the /usr/share/ovirt-engine/dbscripts/engine-psql.sh script with the -c option, the results of the command are logged in the log file, but the command used is not log.

Version-Release number of selected component (if applicable):
redhat-support-plugin-rhev-3.6.*

How reproducible:
100%

Steps to Reproduce:
1. # /usr/share/ovirt-engine/dbscripts/engine-psql.sh -c "select * from storage_pool;" 
2. View resulting log file in /var/log/ovirt-engine/db-manual

Actual results:
Result of query logged but not command run

Expected results:
Command that was run as well as results

Additional info:
This is particularly important with update and delete queries because without logging the command, the only clue we have of what the customer may have done is useless logs such as "DELETE 1" that contain no context.

Comment 2 Derrick Ornelas 2016-06-07 21:15:41 UTC
Without '-a' tee will overwrite the specified file.  Everything was logged correctly to LOGFILE up until this point, but then tee is overwriting LOGFILE with the output of psql command.

Comment 3 Derrick Ornelas 2016-06-07 21:22:50 UTC
# /usr/share/ovirt-engine/dbscripts/engine-psql.sh -c "select 1"
 ?column? 
----------
        1
(1 row)


# zcat /var/log/ovirt-engine/db-manual/20160607171954-engine-psql.log.gz 
Tue Jun  7 17:19:54 EDT 2016: executing command : /usr/share/ovirt-engine/dbscripts/engine-psql.sh -c select 1
output:
 ?column? 
----------
        1
(1 row)

result: 0



# /usr/share/ovirt-engine/dbscripts/engine-psql.sh -f /root/test.sql 
 ?column? 
----------
        1
(1 row)


# zcat /var/log/ovirt-engine/db-manual/20160607172005-engine-psql.log.gz 
Tue Jun  7 17:20:05 EDT 2016: executing command : /usr/share/ovirt-engine/dbscripts/engine-psql.sh -f /root/test.sql
file content is:
select 1
output:
 ?column? 
----------
        1
(1 row)

result: 0

Comment 4 Martin Perina 2016-06-08 10:40:48 UTC
Alex, could you please take a look?

Comment 5 Alexander Wels 2016-06-08 12:39:18 UTC
My sh skills are non-existent, but I can certainly apply the patch that adds -a to line 85 command as provided by Derrick Ornelas. Looks like a fairly trivial change to me.

I didn't write the script it was dropped in my lap with a note saying its yours now.

@Derrick is that what you want me to do? Can you verify that it solves your problem?

Comment 6 Martin Perina 2016-06-08 13:28:52 UTC
Ahh, sorry Alex, now I remember that GSS wanted this script to be included in support-plugin. To me this change make sense, but I think GSS should approve the change (as they have requested this script to be included). Marina?

Comment 7 Marina Kalinin 2016-06-08 14:55:45 UTC
Yes, this is very needed by GSS.
And this is actually a regression, since it used to work:
https://bugzilla.redhat.com/show_bug.cgi?id=1071458

Please please please fix it!

Comment 8 Robert McSwain 2016-06-08 15:01:18 UTC
+1 for this, thanks! :)

Comment 17 Pavel Stehlik 2016-08-16 18:34:57 UTC
redhat-support-plugin-rhev-4.0.0-7.el7ev.noarch


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