Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1343757

Summary: engine-psql.sh does not log commands when -c option is used
Product: Red Hat Enterprise Virtualization Manager Reporter: Allie DeVolder <adevolder>
Component: redhat-support-plugin-rhevAssignee: Spenser Shumaker <sshumake>
Status: CLOSED CURRENTRELEASE QA Contact: Pavel Stehlik <pstehlik>
Severity: low Docs Contact:
Priority: unspecified    
Version: 3.6.3CC: awels, dornelas, gklein, lsurette, mkalinin, mperina, oourfali, pstehlik, rbalakri, rmcswain, srevivo, ykaul
Target Milestone: ovirt-4.0.0-rc   
Target Release: 4.0.0   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1344468 1344586 (view as bug list) Environment:
Last Closed: 2016-09-06 06:55:14 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Infra RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1344586    

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