Skip to content

Commit 14644fb

Browse files
committed
[pcp_metrics] Skip malformed annotation lines
So now we're skipping lines that doesn't match the expected format of: TIMESTAMP | Details So any log line like: " - PLAY [Manage and Provide ironic baremetal nodes] stdout: "[WARNING]: Found variable using reserved name: namespace\n\n" should not be parsed and then not making a runtime Error. Signed-off-by: Enrique Vallespi Gil <evallesp@redhat.com>
1 parent b9f05e2 commit 14644fb

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

roles/pcp_metrics/files/plot.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,11 @@ def annotate(axs: Iterable[plt.Axes]) -> None:
410410
data = file.read().strip().split("\n")
411411

412412
for annotation in data:
413-
time, details = annotation.split(" | ", maxsplit=1)
413+
try:
414+
time, details = annotation.split(" | ", maxsplit=1)
415+
except ValueError:
416+
print("WARNING Skipping malformed annotation line:", annotation.strip())
417+
continue
414418
time = datetime.strptime(time, "%Y-%m-%d %H:%M:%S,%f")
415419

416420
if details.startswith("PLAY"):

0 commit comments

Comments
 (0)