Skip to content

Commit 2589522

Browse files
committed
hack/log-explainer: Don't crash if run on truncated logs
Avoid crashing on undefined 'sync' if someone pushes in logs from a pod that has been running for so long that we no longer have the lines that start the opening sync. Instead, just throw that partially-logged sync out.
1 parent 0fa9b04 commit 2589522

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

hack/log-explainer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ def parse_lines(lines):
9292
sync['lines'] = []
9393
sync['manifests'] = {}
9494
metadata['syncs'].append(sync)
95-
if sync:
96-
sync['lines'].append(line)
97-
else:
95+
if not sync:
9896
logging.warning('sync worker line outside of sync: {}'.format(line))
97+
continue
98+
sync['lines'].append(line)
9999
if line['message'].startswith(end_of_sync_cycle_prefix):
100100
sync['results'] = {
101101
'result': line['message'][len(end_of_sync_cycle_prefix):],

0 commit comments

Comments
 (0)