Bug 672597 - fence_scsi: properly log errors for all commands
Summary: fence_scsi: properly log errors for all commands
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: fence-agents
Version: 6.1
Hardware: All
OS: Linux
low
low
Target Milestone: rc
: 6.1
Assignee: Ryan O'Hara
QA Contact: Cluster QE
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-01-25 17:14 UTC by Ryan O'Hara
Modified: 2011-05-19 14:21 UTC (History)
3 users (show)

Fixed In Version: fence-agents-3.0.12-13.el6
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-05-19 14:21:55 UTC
Target Upstream Version:


Attachments (Terms of Use)
Log errors with log_error and redirect stderr to /dev/null. (5.56 KB, patch)
2011-01-25 17:25 UTC, Ryan O'Hara
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2011:0745 0 normal SHIPPED_LIVE fence-agents bug fix and enhancement update 2011-05-19 09:37:09 UTC

Description Ryan O'Hara 2011-01-25 17:14:33 UTC
There are a number of places in fence_scsi where the script executes a command via Perl's qx function. Most of these are for executing sg_persist commands. Currently the script does nothing more than:

    $out = qx { $cmd };

    die "[error]: $self\n" if ($?>>8);

If an error occurs executing the command, the script simply dies and reports the name of the subroutine. This can be improved in two ways:

1. Redirect stderr to /dev/null.
2. Log any errors with log_error.

Redirecting stderr to /dev/null keeps some garbage from the sg_persist commands from making its way into the logs. This is a very minor change.

Using log_error instead of simply calling die is preferable since it will write a properly formatted to the logfile.

The improved code would do replace the qx and die calls with:

    $out = qx { $cmd 2> /dev/null };
    $err = ($?>>8);

    if ($err != 0) {
        log_error ("$self (err=$err)");
    }

This code  will correctly write the error to the logfile and include the error code, which might be useful for debugging purposes.

Comment 1 Ryan O'Hara 2011-01-25 17:25:14 UTC
Created attachment 475217 [details]
Log errors with log_error and redirect stderr to /dev/null.

Comment 2 Ryan O'Hara 2011-02-03 02:44:53 UTC
Pushed to RHEL6 branch.

commit b3e375c0554149173390b542de1ef3674da3d128

Comment 5 errata-xmlrpc 2011-05-19 14:21:55 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2011-0745.html


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