2
0
mirror of https://github.com/xcat2/confluent.git synced 2026-08-03 07:57:02 +00:00

Keep the nodediscover CSV import going past a failed assignment

gather propagates the first exception and leaves its siblings running,
so a transport level failure against one node ends the import with a
traceback while the rest of the batch is cancelled at loop shutdown.
The forked children used to contain such a failure to their own node.
assign_macs already reports an error response itself, so this is the
connection dropping rather than the server refusing the assignment.

Collect the exceptions instead, report each one and count it towards
the exit code.  Schedule the assignments as tasks while doing so, since
the plain coroutines are left unawaited if defining a later node raises
before the gather is reached.
This commit is contained in:
Markus Hilger
2026-07-27 06:15:45 +02:00
parent a619b6ed6f
commit f8ea1adec7
+6 -2
View File
@@ -242,8 +242,12 @@ async def import_csv(options, session):
print('Defined ' + res['created'])
else:
print(repr(res))
assignments.append(assign_macs(maclist, nodename, assignlimit))
for rcode in await asyncio.gather(*assignments):
assignments.append(
asyncio.create_task(assign_macs(maclist, nodename, assignlimit)))
for rcode in await asyncio.gather(*assignments, return_exceptions=True):
if isinstance(rcode, BaseException):
sys.stderr.write('Error assigning discovery data: {0}\n'.format(rcode))
rcode = 1
exitcode |= rcode
if exitcode:
sys.exit(exitcode)