Bug 680973

Summary: lvm2 pvmove test mode "Command failed with status code 5"
Product: Red Hat Enterprise Linux 5 Reporter: Debbie Johnson <dejohnso>
Component: lvm2Assignee: Milan Broz <mbroz>
Status: CLOSED CURRENTRELEASE QA Contact: Corey Marthaler <cmarthal>
Severity: low Docs Contact:
Priority: low    
Version: 5.6CC: agk, dwysocha, heinzm, jbrassow, mbroz, ndoane, prajnoha, prockai, pvrabec, thornber, zkabelac
Target Milestone: rc   
Target Release: 5.7   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 680976 (view as bug list) Environment:
Last Closed: 2011-03-07 11:55:48 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Bug Depends On:    
Bug Blocks: 680976    

Description Debbie Johnson 2011-02-28 16:52:50 UTC
Description of problem:
When using test mode with the lvm2 command, pvmove (and probably others),
you get an error:

Command failed with status code 5


Version-Release number of selected component (if applicable):
RHEL 5.6



How reproducible:  every time

Example:

root@bbnfs ~]# pvmove -tv /dev/mapper/mpath3p2 /dev/mapper/mpath2p1
Test mode: Metadata will NOT be updated.
Finding volume group "nfsVG"
Test mode: Skipping archiving of volume group.
Creating logical volume pvmove0
Moving 1599 extents of logical volume nfsVG/bbnfs
Found volume group "nfsVG"
Updating volume group metadata
Test mode: Skipping volume group backup.
Found volume group "nfsVG"
Found volume group "nfsVG"
Found volume group "nfsVG"
Test mode: Wiping internal cache
Wiping internal VG cache
Command failed with status code 5. 


Actual results:
Appears the test command failed because of the error

Expected results:
No Command failed message outputed


Additional info:

In looking at the code it appears the problem is at:

        if ((ret != ECMD_PROCESSED) && !error_message_produced()) {
                log_debug(INTERNAL_ERROR "Failed command did not use log_error");
                log_error("Command failed with status code %d.", ret);
        }


We are not testing to see if we are in test mod before printing the message.
This is in lvm2_main() and lvm_shell().  So I believe the if statement should be:

        if ((ret != ECMD_PROCESSED) && !error_message_produced() && !test_mode()) {

to avoid printing the Command failed message.

Comment 1 Alasdair Kergon 2011-02-28 17:07:12 UTC
Rather, it should return success in test mode, not fail.  The error message check is OK there.  I thought pvmove --test used to work once-upon-a-time...

Comment 3 Milan Broz 2011-02-28 20:33:31 UTC
Please always provice exact lvm2 rpm version.

It works for me for release 5.6 - lvm2-2.02.74-5.el5.x86_64

# pvmove -vt /dev/sdc /dev/sdb ; echo $?
  Test mode: Metadata will NOT be updated.
    Finding volume group "vgt"
    Test mode: Skipping archiving of volume group.
    Creating logical volume pvmove0
    Moving 100 extents of logical volume vgt/lv
    Found volume group "vgt"
    activation/volume_list configuration setting not defined, checking only host tags for vgt/lv
    Updating volume group metadata
    Found volume group "vgt"
    Found volume group "vgt"
    Found volume group "vgt"
    Test mode: Skipping volume group backup.
    Test mode: Wiping internal cache
    Wiping internal VG cache
0