mirror of
https://github.com/xcat2/confluent.git
synced 2026-09-04 20:17:58 +00:00
Set the exit code when a read fails
nodesensors and nodeconfig printed an error and exited 0, so `nodesensors n1 && next-step` ran next-step after the read it guarded had already failed. nodesensors had three of these: the per-node branch never set the exit code, the top-level branch beside it read `exitcode |= exitcode`, and a normal return from main() fell off the end of the file. nodeconfig accumulates with |= all through its read path except the last line, which assigned, so a failed bmc configuration read was discarded by the system read after it. The fixed branches now match how nodehealth and client.py spell the same thing.
This commit is contained in:
@@ -327,7 +327,7 @@ async def main():
|
||||
else:
|
||||
path = '/noderange/{0}/configuration/system/advanced'.format(
|
||||
noderange)
|
||||
rcode = await client.print_attrib_path(path, session, printsys,
|
||||
rcode |= await client.print_attrib_path(path, session, printsys,
|
||||
options)
|
||||
sys.exit(rcode)
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ def sensorpass(showout=True, appendtime=False):
|
||||
if 'error' in reading:
|
||||
sys.stderr.write('Error: {0}\n'.format(reading['error']))
|
||||
if 'errorcode' in reading:
|
||||
exitcode |= exitcode
|
||||
exitcode |= reading['errorcode']
|
||||
else:
|
||||
exitcode |= 1
|
||||
if 'databynode' not in reading:
|
||||
@@ -120,6 +120,10 @@ def sensorpass(showout=True, appendtime=False):
|
||||
sys.stderr.write(
|
||||
'{0}: Error: {1}\n'.format(node,
|
||||
reading[node]['error']))
|
||||
if 'errorcode' in reading[node]:
|
||||
exitcode |= reading[node]['errorcode']
|
||||
else:
|
||||
exitcode |= 1
|
||||
if 'sensors' not in reading[node]:
|
||||
continue
|
||||
for sensedata in reading[node]['sensors']:
|
||||
@@ -261,3 +265,6 @@ try:
|
||||
except KeyboardInterrupt:
|
||||
print('')
|
||||
sys.exit(0)
|
||||
# Falling off the end exited 0 whatever sensorpass recorded, so only the
|
||||
# --interval path ever reported a failed read.
|
||||
sys.exit(exitcode)
|
||||
|
||||
Reference in New Issue
Block a user