Skip to content

Commit 9fb1e34

Browse files
authored
Add maxrc option to clush.conf (#451)
Externalize the -S option as "maxrc" in the configuration file to avoid passing it on the command line on every invocation. Also add --maxrc as long option for -S. Finally, clush -O/--option can also be used to enforce the value for maxrc (yes/no) on the command line.
1 parent 55fead4 commit 9fb1e34

File tree

12 files changed

+44
-8
lines changed

12 files changed

+44
-8
lines changed

conf/clush.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ command_timeout: 0
1010
color: auto
1111
fd_max: 8192
1212
history_size: 100
13+
maxrc: no
1314
node_count: yes
1415
verbosity: 1
1516

doc/extras/vim/syntax/clushconf.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ syn match clushComment "#.*$"
1616
syn match clushComment ";.*$"
1717
syn match clushHeader "\[\w\+\]"
1818

19-
syn keyword clushKeys fanout command_timeout connect_timeout color fd_max history_size node_count verbosity
19+
syn keyword clushKeys fanout command_timeout connect_timeout color fd_max history_size node_count maxrc verbosity
2020
syn keyword clushKeys ssh_user ssh_path ssh_options
2121
syn keyword clushKeys rsh_path rcp_path rcp_options
2222

doc/man/man1/clush.1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.\" Man page generated from reStructuredText.
22
.
3-
.TH CLUSH 1 "2019-12-01" "1.8.3" "ClusterShell User Manual"
3+
.TH CLUSH 1 "2021-10-27" "1.8.3" "ClusterShell User Manual"
44
.SH NAME
55
clush \- execute shell commands on a cluster
66
.
@@ -234,7 +234,7 @@ like \-b but including standard error
234234
.B \-r\fP,\fB \-\-regroup
235235
fold nodeset using node groups
236236
.TP
237-
.B \-S
237+
.B \-S\fP,\fB \-\-maxrc
238238
return the largest of command return codes
239239
.TP
240240
.BI \-\-color\fB= WHENCOLOR

doc/man/man5/clush.conf.5

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ list. Negative values imply unlimited history file size.
103103
Should \fBclush\fP display additional (node count) information in buffer
104104
header? (\fIyes\fP/\fIno\fP)
105105
.TP
106+
.B maxrc
107+
Should \fBclush\fP return the largest of command return codes? (\fIyes\fP/\fIno\fP)
108+
.TP
106109
.B verbosity
107110
Set the verbosity level: \fI0\fP (quiet), \fI1\fP (default), \fI2\fP (verbose) or more
108111
(debug).
@@ -146,6 +149,7 @@ history_size: 100
146149
color: auto
147150
fd_max: 10240
148151
node_count: yes
152+
maxrc: no
149153

150154
.fi
151155
.sp

doc/sphinx/config.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,13 @@ The following table describes available *clush* config file settings.
6464
| node_count | Should *clush* display additional (node count) |
6565
| | information in buffer header? (yes/no) |
6666
+-----------------+----------------------------------------------------+
67+
| maxrc | Should *clush* return the largest of command |
68+
| | return codes? (yes/no) |
69+
| | If set to no (the default), *clush* exit status |
70+
| | gives no information about command return codes, |
71+
| | but rather reports on *clush* execution itself |
72+
| | (zero indicating a successful run). |
73+
+-----------------+----------------------------------------------------+
6774
| verbosity | Set the verbosity level: 0 (quiet), 1 (default), |
6875
| | 2 (verbose) or more (debug). |
6976
+-----------------+----------------------------------------------------+

doc/txt/clush.conf.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ history_size
7171
node_count
7272
Should ``clush`` display additional (node count) information in buffer
7373
header? (`yes`/`no`)
74+
maxrc
75+
Should ``clush`` return the largest of command return codes? (yes/no)
7476
verbosity
7577
Set the verbosity level: `0` (quiet), `1` (default), `2` (verbose) or more
7678
(debug).
@@ -108,6 +110,7 @@ Simple configuration file.
108110
| history_size: 100
109111
| color: auto
110112
| fd_max: 10240
113+
| maxrc: no
111114
| node_count: yes
112115
|
113116

doc/txt/clush.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ execute shell commands on a cluster
77
-----------------------------------
88

99
:Author: Stephane Thiell <[email protected]>
10-
:Date: 2019-12-01
10+
:Date: 2021-10-27
1111
:Copyright: GNU Lesser General Public License version 2.1 or later (LGPLv2.1+)
1212
:Version: 1.8.3
1313
:Manual section: 1
@@ -159,7 +159,7 @@ Output behaviour:
159159
-b, --dshbak display gathered results in a dshbak-like way (note: it will only try to aggregate the output of commands with same return codes)
160160
-B like -b but including standard error
161161
-r, --regroup fold nodeset using node groups
162-
-S return the largest of command return codes
162+
-S, --maxrc return the largest of command return codes
163163
--color=WHENCOLOR whether to use ANSI colors to surround node or nodeset prefix/header with escape sequences to display them in color on the terminal. *WHENCOLOR* is ``never``, ``always`` or ``auto`` (which use color if standard output/error refer to a terminal). Colors are set to [34m (blue foreground text) for stdout and [31m (red foreground text) for stderr, and cannot be modified.
164164
--diff show diff between common outputs (find the best reference output by focusing on largest nodeset and also smaller command return code)
165165

@@ -183,7 +183,7 @@ Connection options:
183183
-u COMMAND_TIMEOUT, --command_timeout=COMMAND_TIMEOUT
184184
limit time for command to run on the node
185185
-R WORKER, --worker=WORKER
186-
worker name to use for connection (``exec``, ``ssh``, ``rsh``, ``pdsh``), default is ``ssh``
186+
worker name to use for connection (``exec``, ``ssh``, ``rsh``, ``pdsh``, or the name of a Python worker module), default is ``ssh``
187187
--remote=REMOTE whether to enable remote execution: in tree mode, 'yes' forces connections to the leaf nodes for execution, 'no' establishes connections up to the leaf parent nodes for execution (default is 'yes')
188188

189189
For a short explanation of these options, see ``-h, --help``.

lib/ClusterShell/CLI/Clush.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1096,7 +1096,7 @@ def main():
10961096
clush_exit(1, task)
10971097

10981098
rc = 0
1099-
if options.maxrc:
1099+
if config.maxrc:
11001100
# Instead of clush return code, return commands retcode
11011101
rc = task.max_retcode()
11021102
if task.num_timeout() > 0:

lib/ClusterShell/CLI/Config.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class ClushConfig(configparser.ConfigParser, object):
5656
"color": THREE_CHOICES[-1], # auto
5757
"verbosity": "%d" % VERB_STD,
5858
"node_count": "yes",
59+
"maxrc": "no",
5960
"fd_max": "8192"}
6061

6162
def __init__(self, options, filename=None):
@@ -94,6 +95,8 @@ def __init__(self, options, filename=None):
9495
self._set_main("command_timeout", options.command_timeout)
9596
if options.whencolor:
9697
self._set_main("color", options.whencolor)
98+
if options.maxrc:
99+
self._set_main("maxrc", options.maxrc)
97100

98101
try:
99102
# -O/--option KEY=VALUE
@@ -212,6 +215,11 @@ def node_count(self):
212215
"""node_count value as a boolean"""
213216
return self.getboolean("Main", "node_count")
214217

218+
@property
219+
def maxrc(self):
220+
"""maxrc value as a boolean"""
221+
return self.getboolean("Main", "maxrc")
222+
215223
@property
216224
def fd_max(self):
217225
"""max number of open files (soft rlimit)"""

lib/ClusterShell/CLI/OptionParser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def install_display_options(self,
172172
help="node / line content separator string "
173173
"(default: ':')")
174174
else:
175-
optgrp.add_option("-S", action="store_true", dest="maxrc",
175+
optgrp.add_option("-S", "--maxrc", action="store_true", dest="maxrc",
176176
help="return the largest of command return codes")
177177

178178
if msgtree_mode:

0 commit comments

Comments
 (0)