Merge lp:~smoser/maas-images/lp1626810 into lp:maas-images

Proposed by Scott Moser
Status: Merged
Merged at revision: 331
Proposed branch: lp:~smoser/maas-images/lp1626810
Merge into: lp:maas-images
Diff against target: 129 lines (+40/-8)
5 files modified
bin/maas-cloudimg2ephemeral (+2/-0)
meph2/commands/build_image.py (+1/-1)
meph2/commands/cloudimg_sync.py (+1/-1)
meph2/commands/meph2_util.py (+1/-1)
meph2/stream.py (+35/-5)
To merge this branch: bzr merge lp:~smoser/maas-images/lp1626810
Reviewer Review Type Date Requested Status
Blake Rouse (community) Approve
Review via email: mp+306633@code.launchpad.net

Commit message

Do not build products for architectures not listed in config.

This change does 2 things:
 a.) enables 'powerpc' to actually build
 b.) makes meph2-build and cloud-image sync not build products for architectures not listed in the config.

The path for 'b' is to write empty products data and to LOG.warn and
write to stderr a message saying how to support.

Also there is a drive by fix here to make 'insert --no-sign' work respect
the --no-sign argument.

To post a comment you must log in.
Revision history for this message
Andres Rodriguez (andreserl) wrote :

While the change looks good there's one thing:

We shouldn't be providing MAAS images for an architecture we don't even support.

Revision history for this message
Andres Rodriguez (andreserl) wrote :

forgot the approve.

lp:~smoser/maas-images/lp1626810 updated
331. By Scott Moser

find supported arch list from the config file.

Revision history for this message
Scott Moser (smoser) wrote :

Note... this will create an empty products tree.
I'm not entirely certain that all other tools will handle that
empty products tree. Other tools may need to be updated to address this.

Example:

$ ./bin/meph2-build powerpc yakkety 20101001 /tmp/foo.img out.d
arch 'powerpc' is not supported for release 'yakkety'.
Release has architectures: {'ppc64el', 'arm64', 's390x', 'i386', 'amd64', 'armhf'}.
To support, add kernel info to config.

$ for f in $(find out.d -type f); do echo == $f ==; cat $f; done
== out.d/streams/v1/com.ubuntu.maas:daily:v2:download.json ==
{
 "content_id": "com.ubuntu.maas:daily:v2:download",
 "datatype": "image-downloads",
 "format": "products:1.0",
 "products": {},
 "updated": "Fri, 23 Sep 2016 16:14:25 +0000"
}
== out.d/streams/v1/index.json ==
{
 "format": "index:1.0",
 "index": {
  "com.ubuntu.maas:daily:v2:download": {
   "datatype": "image-downloads",
   "format": "products:1.0",
   "path": "streams/v1/com.ubuntu.maas:daily:v2:download.json",
   "products": [],
   "updated": "Fri, 23 Sep 2016 16:14:25 +0000"
  }
 },
 "updated": "Fri, 23 Sep 2016 16:14:25 +0000"
}

Revision history for this message
Blake Rouse (blake-rouse) :
lp:~smoser/maas-images/lp1626810 updated
332. By Scott Moser

drive by fix, in 'insert' respect --no-sign.

Revision history for this message
Scott Moser (smoser) wrote :

This is actually the right result... the user asked us to build all relevant products, and we built none. How better to indicate that than to build an empty list that can be parsed?

Revision history for this message
Scott Moser (smoser) wrote :

I've verified at least that 'insert' into an empty dir is fine. i'm guessing it will be fine on other data too:

$ rm -Rf out.d; ./bin/meph2-build powerpc yakkety 20101001 /tmp/foo.img out.d
arch 'powerpc' is not supported for release 'yakkety'.
Release has architectures: {'amd64', 's390x', 'ppc64el', 'armhf', 'arm64', 'i386'}.
To support, add kernel info to config.

$ rm -Rf joined.d; ./bin/meph2-util insert --no-sign out.d/streams/v1/index.json joined.d

Revision history for this message
Robert C Jennings (rcj) wrote :

smoser, this looks like a fine solution. +1

lp:~smoser/maas-images/lp1626810 updated
333. By Scott Moser

fix the case statement. qemu_arch here is now 'ppc'.

334. By Scott Moser

mark fixes 1626810

Revision history for this message
Blake Rouse (blake-rouse) wrote :

Sounds good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/maas-cloudimg2ephemeral'
2--- bin/maas-cloudimg2ephemeral 2016-09-22 16:38:08 +0000
3+++ bin/maas-cloudimg2ephemeral 2016-09-23 16:33:33 +0000
4@@ -492,12 +492,14 @@
5 arm64) qemu_arch="aarch64";;
6 arm*) qemu_arch="arm";;
7 ppc64el) qemu_arch="ppc64le";;
8+ powerpc) qemu_arch="ppc";;
9 *) qemu_arch="$debian_arch";;
10 esac
11
12 local cross=true
13 case "$host_arch:$qemu_arch" in
14 $host_arch:$host_arch) cross=false;;
15+ ppc64:ppc) cross=false;;
16 i?86:i386) cross=false;;
17 x86_64:i386) cross=false;;
18 aarm64:arm64) cross=false;;
19
20=== modified file 'meph2/commands/build_image.py'
21--- meph2/commands/build_image.py 2016-09-14 06:58:09 +0000
22+++ meph2/commands/build_image.py 2016-09-23 16:33:33 +0000
23@@ -24,7 +24,7 @@
24 sutil.products_set(prod_tree, items[i],
25 (prodname, version_name, i))
26
27- sutil.products_prune(prod_tree)
28+ sutil.products_prune(prod_tree, preserve_empty_products=True)
29 sutil.products_condense(prod_tree, sticky=['di_version', 'kpackage'])
30
31 tsnow = sutil.timestamp()
32
33=== modified file 'meph2/commands/cloudimg_sync.py'
34--- meph2/commands/cloudimg_sync.py 2016-09-14 06:58:09 +0000
35+++ meph2/commands/cloudimg_sync.py 2016-09-23 16:33:33 +0000
36@@ -150,7 +150,7 @@
37
38 def insert_products(self, path, target, content):
39 tree = copy.deepcopy(self.content_t)
40- sutil.products_prune(tree)
41+ sutil.products_prune(tree, preserve_empty_products=True)
42 # stop these items from copying up when we call condense
43 sutil.products_condense(tree,
44 sticky=['di_version', 'kpackage'])
45
46=== modified file 'meph2/commands/meph2_util.py'
47--- meph2/commands/meph2_util.py 2016-08-23 06:08:11 +0000
48+++ meph2/commands/meph2_util.py 2016-09-23 16:33:33 +0000
49@@ -461,7 +461,7 @@
50 tmirror = InsertBareMirrorWriter(config=mirror_config, objectstore=tstore)
51 tmirror.sync(smirror, src_path)
52
53- gen_index_and_sign(args.target)
54+ gen_index_and_sign(args.target, sign=not args.no_sign)
55 return 0
56
57
58
59=== modified file 'meph2/stream.py'
60--- meph2/stream.py 2016-09-22 16:51:28 +0000
61+++ meph2/stream.py 2016-09-23 16:33:33 +0000
62@@ -6,6 +6,7 @@
63 import copy
64 import os
65 import subprocess
66+import sys
67 import yaml
68
69 from simplestreams.log import LOG
70@@ -32,6 +33,27 @@
71 'root-tar', 'squashfs-image']
72
73
74+def read_kdata(info, ret=list):
75+ # read a kernel data list and return it as a list or a dict.
76+
77+ # copy it for our modification.
78+ info = list(info)
79+
80+ # 7th field is optional in kernel lines in config data
81+ # so fill it with empty dictionary if not present.
82+ if len(info) == 6:
83+ info.append({})
84+
85+ names = ("krel", "arch", "subarch", "flavor", "kpkg",
86+ "subarches", "kdata")
87+ if ret == list:
88+ return info
89+ elif ret == dict:
90+ return dict(zip(names, info))
91+ else:
92+ raise ValueError("Unexpected input '%s'" % ret)
93+
94+
95 def create_version(arch, release, version_name, img_url, out_d,
96 include_di=True, cfgdata=None, common_tags=None,
97 verbosity=0, img_format=None):
98@@ -75,6 +97,17 @@
99 release)
100 rdata = r
101
102+ arches = set([read_kdata(i, dict)['arch'] for i in rdata['kernels']])
103+ if arch not in arches:
104+ msg = (
105+ "arch '%(arch)s' is not supported for release '%(release)s'.\n"
106+ "Release has architectures: %(arches)s.\n"
107+ "To support, add kernel info to config." %
108+ {'arch': arch, 'release': release, 'arches': arches})
109+ LOG.warn(msg)
110+ sys.stderr.write(msg + "\n")
111+ return {}
112+
113 version = rdata['version']
114 if isinstance(version, float):
115 raise ValueError("release '%s' in config had version as a float (%s) "
116@@ -142,11 +175,8 @@
117 kdata_defaults = {'suffix': "", 'di-format': "default", 'dtb': ""}
118
119 for info in rdata['kernels']:
120- # 7th field is optional in kernel lines in config data
121- # so fill it with empty dictionary if not present.
122- if len(info) == 6:
123- info.append({})
124- (krel, karch, psubarch, flavor, kpkg, subarches, kdata) = info
125+ (krel, karch, psubarch, flavor, kpkg, subarches, kdata) = (
126+ read_kdata(info))
127
128 if karch != arch:
129 continue

Subscribers

People subscribed via source and target branches