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

Test the import drain loops for an error before a percentage

Both loops that read the importer's output test for a percentage first,
so an ERROR: line whose text carries a % takes the percentage branch and
float() raises instead of the error being reported.  The import target
name can carry one too, and that one is user supplied.  importmedia runs
as a bare task, so the exception is swallowed and the client polls a
phase that never advances.

Test for ERROR: first and treat an unparsable percentage as no
percentage.  Set percent on the error path of the second loop as well,
as the first already does.
This commit is contained in:
Markus Hilger
2026-07-27 17:02:17 +02:00
parent b081c17b55
commit 3e7da14a9a
+15 -10
View File
@@ -1275,32 +1275,37 @@ class MediaImporter(object):
nb = await wkr.stdout.read(128)
currline += nb
if b'\r' in currline:
if b'%' in currline:
val = currline.split(b'%')[0].strip()
if val:
self.percent = float(val)
elif b'ERROR:' in currline:
if b'ERROR:' in currline:
self.error = currline.replace(b'ERROR:', b'')
if not isinstance(self.error, str):
self.error = self.error.decode('utf8')
self.phase = 'error'
self.percent = 100.0
return
elif b'%' in currline:
val = currline.split(b'%')[0].strip()
try:
self.percent = float(val)
except ValueError:
pass
currline = b''
a = await wkr.stdout.read(1)
while a:
currline += a
if b'\r' in currline:
if b'%' in currline:
val = currline.split(b'%')[0].strip()
if val:
self.percent = float(val)
elif b'ERROR:' in currline:
if b'ERROR:' in currline:
self.error = currline.replace(b'ERROR:', b'')
if not isinstance(self.error, str):
self.error = self.error.decode('utf8')
self.phase = 'error'
self.percent = 100.0
return
elif b'%' in currline:
val = currline.split(b'%')[0].strip()
try:
self.percent = float(val)
except ValueError:
pass
currline = b''
a = await wkr.stdout.read(1)
if self.oscategory: