Merge ~jocave/plainbox-provider-resource:handle-track-info into plainbox-provider-resource:master

Proposed by Jonathan Cave
Status: Merged
Approved by: Jonathan Cave
Approved revision: 7b4cad3581419fbe1f3d4b63d79f2af3990ac529
Merged at revision: 08b1dcfa07af85cd38f3c946f475f46228feb591
Proposed branch: ~jocave/plainbox-provider-resource:handle-track-info
Merge into: plainbox-provider-resource:master
Diff against target: 29 lines (+10/-2)
1 file modified
bin/snapd_resource (+10/-2)
Reviewer Review Type Date Requested Status
Sylvain Pineau (community) Approve
Review via email: mp+365293@code.launchpad.net

Description of the change

With UC18 images model assertions have started appearing where the gadget and kernel snap fields specify a track that should be used. This breaks templates that were using this field to check details in the gadget snap of the system e.g. the job might try to query the path /snap/pc=18/current/...

Example resource unit produced on a UC18 device, note in this case the addition of the "gadget_track" key:
https://paste.ubuntu.com/p/pgXGCvscZ7/

To post a comment you must log in.
Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/bin/snapd_resource b/bin/snapd_resource
2index c65249c..d88ffa0 100755
3--- a/bin/snapd_resource
4+++ b/bin/snapd_resource
5@@ -74,7 +74,8 @@ class AssertionQuery(SnapdQuery):
6 """ Super naive Assertion parser
7
8 No attempt to handle assertions with a body. Discards signatures based
9- on lack of colon characters.
10+ on lack of colon characters. Update: need to be less naive about
11+ gadget and kernel names on UC18
12 """
13 data = self.get(self.prefix + assertion)
14 count = int(data.headers['X-Ubuntu-Assertions-Count'])
15@@ -82,7 +83,14 @@ class AssertionQuery(SnapdQuery):
16 for line in io.StringIO(data.text):
17 if line.strip() == "":
18 print()
19- if ':' in line:
20+ if line.count(':') == 1:
21+ key, val = [x.strip() for x in line.split(':')]
22+ if key in ('gadget', 'kernel'):
23+ if '=' in val:
24+ snap, track = [x.strip() for x in val.split('=')]
25+ print('{}: {}'.format(key, snap))
26+ print('{}_track: {}'.format(key, track))
27+ continue
28 print(line.strip())
29 return count
30

Subscribers

People subscribed via source and target branches