Merge ~paelzer/ubuntu-helpers:fix-unparsable-jobs into ~ubuntu-server/+git/ubuntu-helpers:main

Proposed by Christian Ehrhardt 
Status: Merged
Merged at revision: b4f7d4297b57b5c6f491fbbd1758710f226e3408
Proposed branch: ~paelzer/ubuntu-helpers:fix-unparsable-jobs
Merge into: ~ubuntu-server/+git/ubuntu-helpers:main
Diff against target: 27 lines (+11/-5)
1 file modified
cpaelzer/lp-test-isrunning (+11/-5)
Reviewer Review Type Date Requested Status
Bryce Harrington Approve
Canonical Server Reporter Pending
Review via email: mp+426877@code.launchpad.net

This proposal supersedes a proposal from 2022-07-14.

To post a comment you must log in.
Revision history for this message
Bryce Harrington (bryce) wrote :

Is the broken json something that occurs often? I think catching that is fine in this case but if it happens a lot might be something worth investigating at some point.

The private jobs I've run into too, and the handling looks good.

review: Approve
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

I've seen it somewhere in the <0.5% range. Maybe even way less and it was a one off thing on the backend.

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Merged

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/cpaelzer/lp-test-isrunning b/cpaelzer/lp-test-isrunning
2index abc260b..4b43221 100755
3--- a/cpaelzer/lp-test-isrunning
4+++ b/cpaelzer/lp-test-isrunning
5@@ -60,11 +60,17 @@ with urllib.request.urlopen(request) as response:
6 for arch in queues[origin][series]:
7 n = 0
8 for key in queues[origin][series][arch]:
9- (pkg, json_data) = key.split(maxsplit=1)
10- jobinfo = json.loads(json_data)
11-
12- triggers = ','.join(jobinfo.get('triggers', '-'))
13- ppas = ','.join(jobinfo.get('ppas', '-'))
14+ if key == "private job":
15+ pkg = triggers = ppas = "private job"
16+ else:
17+ (pkg, json_data) = key.split(maxsplit=1)
18+ try:
19+ jobinfo = json.loads(json_data)
20+ triggers = ','.join(jobinfo.get('triggers', '-'))
21+ ppas = ','.join(jobinfo.get('ppas', '-'))
22+ except json.decoder.JSONDecodeError:
23+ pkg = triggers = ppas = "failed to parse"
24+ continue
25
26 n = n + 1
27 try:

Subscribers

People subscribed via source and target branches