Ticket 312 - sacct usage
Summary: sacct usage
Status: RESOLVED FIXED
Alias: None
Product: Slurm
Classification: Unclassified
Component: Other (show other tickets)
Version: 2.6.x
Hardware: Linux Linux
: 4 - Minor Issue
Assignee: Moe Jette
QA Contact:
URL:
Depends on:
Blocks:
 
Reported: 2013-05-31 01:58 MDT by Rod Schultz
Modified: 2013-05-31 05:08 MDT (History)
1 user (show)

See Also:
Site: Atos/Eviden Sites
Slinky Site: ---
Alineos Sites: ---
Atos/Eviden Sites: ---
Confidential Site: ---
Coreweave sites: ---
Cray Sites: ---
DS9 clusters: ---
Google sites: ---
HPCnow Sites: ---
HPE Sites: ---
IBM Sites: ---
NOAA SIte: ---
NoveTech Sites: ---
Nvidia HWinf-CS Sites: ---
OCF Sites: ---
Recursion Pharma Sites: ---
SFW Sites: ---
SNIC sites: ---
Tzag Elita Sites: ---
Linux Distro: ---
Machine Name:
CLE Version:
Version Fixed:
Target Release: ---
DevPrio: ---
Emory-Cloud Sites: ---


Attachments
new usage patch (1.22 KB, application/octet-stream)
2013-05-31 01:58 MDT, Rod Schultz
Details
More fixes to sacct options (2.60 KB, application/octet-stream)
2013-05-31 03:25 MDT, Rod Schultz
Details

Note You need to log in before you can comment on or make changes to this ticket.
Description Rod Schultz 2013-05-31 01:58:04 MDT
Created attachment 265 [details]
new usage patch

sacct --usage displays nothing

This is a regression. I reported and supplied a patch for this problem last January.

The problem is in the options definition for usage. Here is the declaration for usage in git-master

 {"usage",          no_argument,       &params.opt_help,       OPT_LONG_USAGE},

The comments to _getopt_internal in getopt.c declare that when the flag field for a long-named option (3rd field) is nonzero, it returns 0. In which case, the option is not found in the switch statement.

The attached patch fixes the problem.

Since the usage routine simply prints 

Usage: sacct [options]
        Use --help for help

I actually think the following declaration would be better.

 {"usage",          no_argument,       0,       'h'},

This directly invokes help saving the user from doing sacct --help.

In this case the usage routine should probably be removed, as well as usage cases in switch statements.
Comment 1 Rod Schultz 2013-05-31 03:21:03 MDT
There are some other issues with parsing options for sacct.

I will be sending another patch, so don't apply this one as the new one will also include the usage patch.
Comment 2 Rod Schultz 2013-05-31 03:25:50 MDT
Created attachment 266 [details]
More fixes to sacct options
Comment 3 Rod Schultz 2013-05-31 03:34:44 MDT
The additional bug reported to us was that -d (dump) still worked.

Actually, it didn't dump, it turned into --allusers.

I also found --duplicates had the same problem as --usage as it is a long option and git_master had nonzero in the flags field.

So I tried to make the argument to getopt_long consistent using these rules;

1) If there was a letter in getopt_long arg that did not have a case clause in the following switch statement, I removed it. 
2) If there was a clause in the switch statement that wasn't in the help message, or the long_options declaration, I removed the case and the letter in the list ('t').

I have to admit I'm not completely comfortable with everything I've done, so please review carefully.
Comment 4 Rod Schultz 2013-05-31 03:37:59 MDT
I still think --usage should directly to help.
Comment 5 Danny Auble 2013-05-31 05:08:36 MDT
(In reply to comment #3)
> The additional bug reported to us was that -d (dump) still worked.
> 
> Actually, it didn't dump, it turned into --allusers.

That is interesting, my guess is since getopt_long was still accepting it funky things were happening.  Strange none the less.

> 
> I also found --duplicates had the same problem as --usage as it is a long
> option and git_master had nonzero in the flags field.
> 
> So I tried to make the argument to getopt_long consistent using these rules;
> 
> 1) If there was a letter in getopt_long arg that did not have a case clause
> in the following switch statement, I removed it. 

Yeah, it looks like the 'd' and 'O' was dump and formatted-dump.  Good catch.  'U' wasn't handled either.

> 2) If there was a clause in the switch statement that wasn't in the help
> message, or the long_options declaration, I removed the case and the letter
> in the list ('t').

This was a deprecated option, while it probably isn't used by anyone I left it and documented what happened.

> 
> I have to admit I'm not completely comfortable with everything I've done, so
> please review carefully.

I modified the patch slightly (6974ac0b0a44520046ba52b7dbfd05b03d221380).  I think everything works now.  Let me know if it doesn't.  This code was done a long time ago from HP, I am surprised no one has ever complained.  I guess people don't use the long options :).