Bug 690494 - condor_q output depends on order of parameters
Summary: condor_q output depends on order of parameters
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise MRG
Classification: Red Hat
Component: condor
Version: 1.3
Hardware: Unspecified
OS: Linux
low
low
Target Milestone: 2.1
: ---
Assignee: Erik Erlandson
QA Contact: Martin Kudlej
URL:
Whiteboard:
Depends On:
Blocks: 743350
TreeView+ depends on / blocked
 
Reported: 2011-03-24 13:46 UTC by Martin Kudlej
Modified: 2012-01-23 17:26 UTC (History)
3 users (show)

Fixed In Version: condor-7.6.4-0.5
Doc Type: Bug Fix
Doc Text:
The "-long" and "-format" options to the condor_q command were order-dependent due to a parsing error. This update removes the parsing error, and the order of the aforementioned options no longer results in different behavior.
Clone Of:
Environment:
Last Closed: 2012-01-23 17:26:09 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHEA-2012:0045 0 normal SHIPPED_LIVE Red Hat Enterprise MRG Grid 2.1 bug fix and enhancement update 2012-01-23 22:22:58 UTC

Description Martin Kudlej 2011-03-24 13:46:49 UTC
Description of problem:
There is no information about order of condor_q parameters in manual page or help message. But "condor_q -long" output depends on position in parameters array.

$ condor_q
-- Submitter: : <:41399> : 
 ID      OWNER            SUBMITTED     RUN_TIME ST PRI SIZE CMD               
 175.0   condor          3/24 09:41   0+00:00:01 R  0   0.0  .condor_run.1349  

$ /usr/bin/condor_q   -long  -format "%s\n" x -attributes ProcId,ExitCode,ExitBySignal,JobStatus 175

$ /usr/bin/condor_q   -format "%s\n" x -long -attributes ProcId,ExitCode,ExitBySignal,JobStatus 175 
ProcId = 0
ExitBySignal = FALSE
JobStatus = 2

$ /usr/bin/condor_q   -format "%s\n" x -attributes ProcId,ExitCode,ExitBySignal,JobStatus -long 175 
ProcId = 0
ExitBySignal = FALSE
JobStatus = 2

Version-Release number of selected component (if applicable):
condor-7.4.5-0.7.el5 also condor-7.6.0-0.2.el5

How reproducible:
100%

Steps to Reproduce:
1. submit job
2. try commands written above
  
Actual results:
output of condor_q depends on position of -long

Expected results:
output of condor_q will not depend on position of -long

Additional info:

Comment 1 Matthew Farrellee 2011-08-31 13:30:42 UTC
Also,

$ condor_q -attributes ProcId,ExitCode,ExitBySignal,JobStatus -long -format "%s\n" x -long
JobStatus = 5
ProcId = 0
ExitBySignal = false

It looks like -format clears some -long bit.

And indeed it does,

src/condor_q.V6/queue.cpp

      if (match_prefix (arg, "long")) {
         verbose = 1;
         summarize = 0;
      } 

...

      if( match_prefix( arg, "format" ) ) {
            // make sure we have at least two more arguments
         if( argc <= i+2 ) {
            fprintf( stderr, "Error: Argument -format requires "
                   "format and attribute parameters\n" );
            exit( 1 );
         }
         verbose = 0;

Comment 2 Matthew Farrellee 2011-08-31 13:35:21 UTC
It is unclear why the "verbose = 0" is important, especially when an extra -long after the -format can re-enable it.

commit f57379da4ff5e9f2ea3920b6b71271a55ad341dc
Author: gthain <gthain>
Date:   Thu Nov 15 21:06:57 2007 +0000

    Add support for schedd-side projection when xml output is asked for.  This is a bit of a hack, and only for Igor, so I am intentionall not documenting it yet

diff --git a/src/condor_q.V6/queue.C b/src/condor_q.V6/queue.C
index 3becaed..64fef7a 100644
--- a/src/condor_q.V6/queue.C
+++ b/src/condor_q.V6/queue.C
@@ -1122,6 +1122,7 @@ processCommandLineArguments (int argc, char *argv[])
                   "format and attribute parameters\n" );
            exit( 1 );
         }
+        verbose = 0;
         if (customFormat == false) {
            // first time here
            attrs.clearAll();

Comment 3 Matthew Farrellee 2011-08-31 14:06:38 UTC
The code was introduced for the "-xml -format X Attr1 -format Y Attr2" trick, which is now explicitly supported with "-xml -attributes Attr1,Attr2".

The importance of the "verbose = 0" is still a mystery and does not appear to be important in current code.

It should just be removed.

Comment 4 Erik Erlandson 2011-09-23 20:55:28 UTC
upstream:
https://condor-wiki.cs.wisc.edu/index.cgi/tktview?tn=2498

Comment 5 Erik Erlandson 2011-09-23 22:52:23 UTC
Committed to uw/V7_6-branch

Comment 6 Erik Erlandson 2011-09-23 22:55:03 UTC
REPRO/TEST

Submit a more or less arbitrary job so there is something in the queue.

Before fix, order of "-l" and "-format" will alter output:

$ condor_q -attributes ProcId,JobStatus -l -format "%s\n" xxx 1

$ condor_q -attributes ProcId,JobStatus -format "%s\n" xxx  -l 1
JobStatus = 2
ProcId = 0



After fix, order is independent:

$ condor_q -attributes ProcId,JobStatus -l -format "%s\n" xxx 1
JobStatus = 2
ProcId = 0

$ condor_q -attributes ProcId,JobStatus -format "%s\n" xxx  -l 1
JobStatus = 2
ProcId = 0

Comment 7 Erik Erlandson 2011-09-23 22:55:03 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
Cause:
boolean flag was needlessly reset during parsing of "-format" option on condor_q

Consequence:
Order dependency between "-long" and "-format" arguments on command line

Fix:
Removed the offending flag reset

Result:
"-long" and "-format" are no longer order dependent

Comment 9 Martin Kudlej 2011-10-18 12:38:07 UTC
Tested on RHEL5.8/RHEL6.1 x x86_64/i386 with condor-7.6.4-0.8 and it works -> VERIFIED

Comment 10 Douglas Silas 2011-11-17 00:28:17 UTC
    Technical note updated. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    Diffed Contents:
@@ -1,11 +1 @@
-Cause:
+The "-long" and "-format" options to the condor_q command were order-dependent due to a parsing error. This update removes the parsing error, and the order of the aforementioned options no longer results in different behavior.-boolean flag was needlessly reset during parsing of "-format" option on condor_q
-
-Consequence:
-Order dependency between "-long" and "-format" arguments on command line
-
-Fix:
-Removed the offending flag reset
-
-Result:
-"-long" and "-format" are no longer order dependent

Comment 11 errata-xmlrpc 2012-01-23 17:26:09 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHEA-2012-0045.html


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