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
=== modified file 'bin/maas-cloudimg2ephemeral'
--- bin/maas-cloudimg2ephemeral 2016-09-22 16:38:08 +0000
+++ bin/maas-cloudimg2ephemeral 2016-09-23 16:33:33 +0000
@@ -492,12 +492,14 @@
492 arm64) qemu_arch="aarch64";;492 arm64) qemu_arch="aarch64";;
493 arm*) qemu_arch="arm";;493 arm*) qemu_arch="arm";;
494 ppc64el) qemu_arch="ppc64le";;494 ppc64el) qemu_arch="ppc64le";;
495 powerpc) qemu_arch="ppc";;
495 *) qemu_arch="$debian_arch";;496 *) qemu_arch="$debian_arch";;
496 esac497 esac
497498
498 local cross=true499 local cross=true
499 case "$host_arch:$qemu_arch" in500 case "$host_arch:$qemu_arch" in
500 $host_arch:$host_arch) cross=false;;501 $host_arch:$host_arch) cross=false;;
502 ppc64:ppc) cross=false;;
501 i?86:i386) cross=false;;503 i?86:i386) cross=false;;
502 x86_64:i386) cross=false;;504 x86_64:i386) cross=false;;
503 aarm64:arm64) cross=false;;505 aarm64:arm64) cross=false;;
504506
=== modified file 'meph2/commands/build_image.py'
--- meph2/commands/build_image.py 2016-09-14 06:58:09 +0000
+++ meph2/commands/build_image.py 2016-09-23 16:33:33 +0000
@@ -24,7 +24,7 @@
24 sutil.products_set(prod_tree, items[i],24 sutil.products_set(prod_tree, items[i],
25 (prodname, version_name, i))25 (prodname, version_name, i))
2626
27 sutil.products_prune(prod_tree)27 sutil.products_prune(prod_tree, preserve_empty_products=True)
28 sutil.products_condense(prod_tree, sticky=['di_version', 'kpackage'])28 sutil.products_condense(prod_tree, sticky=['di_version', 'kpackage'])
2929
30 tsnow = sutil.timestamp()30 tsnow = sutil.timestamp()
3131
=== modified file 'meph2/commands/cloudimg_sync.py'
--- meph2/commands/cloudimg_sync.py 2016-09-14 06:58:09 +0000
+++ meph2/commands/cloudimg_sync.py 2016-09-23 16:33:33 +0000
@@ -150,7 +150,7 @@
150150
151 def insert_products(self, path, target, content):151 def insert_products(self, path, target, content):
152 tree = copy.deepcopy(self.content_t)152 tree = copy.deepcopy(self.content_t)
153 sutil.products_prune(tree)153 sutil.products_prune(tree, preserve_empty_products=True)
154 # stop these items from copying up when we call condense154 # stop these items from copying up when we call condense
155 sutil.products_condense(tree,155 sutil.products_condense(tree,
156 sticky=['di_version', 'kpackage'])156 sticky=['di_version', 'kpackage'])
157157
=== modified file 'meph2/commands/meph2_util.py'
--- meph2/commands/meph2_util.py 2016-08-23 06:08:11 +0000
+++ meph2/commands/meph2_util.py 2016-09-23 16:33:33 +0000
@@ -461,7 +461,7 @@
461 tmirror = InsertBareMirrorWriter(config=mirror_config, objectstore=tstore)461 tmirror = InsertBareMirrorWriter(config=mirror_config, objectstore=tstore)
462 tmirror.sync(smirror, src_path)462 tmirror.sync(smirror, src_path)
463463
464 gen_index_and_sign(args.target)464 gen_index_and_sign(args.target, sign=not args.no_sign)
465 return 0465 return 0
466466
467467
468468
=== modified file 'meph2/stream.py'
--- meph2/stream.py 2016-09-22 16:51:28 +0000
+++ meph2/stream.py 2016-09-23 16:33:33 +0000
@@ -6,6 +6,7 @@
6import copy6import copy
7import os7import os
8import subprocess8import subprocess
9import sys
9import yaml10import yaml
1011
11from simplestreams.log import LOG12from simplestreams.log import LOG
@@ -32,6 +33,27 @@
32 'root-tar', 'squashfs-image']33 'root-tar', 'squashfs-image']
3334
3435
36def read_kdata(info, ret=list):
37 # read a kernel data list and return it as a list or a dict.
38
39 # copy it for our modification.
40 info = list(info)
41
42 # 7th field is optional in kernel lines in config data
43 # so fill it with empty dictionary if not present.
44 if len(info) == 6:
45 info.append({})
46
47 names = ("krel", "arch", "subarch", "flavor", "kpkg",
48 "subarches", "kdata")
49 if ret == list:
50 return info
51 elif ret == dict:
52 return dict(zip(names, info))
53 else:
54 raise ValueError("Unexpected input '%s'" % ret)
55
56
35def create_version(arch, release, version_name, img_url, out_d,57def create_version(arch, release, version_name, img_url, out_d,
36 include_di=True, cfgdata=None, common_tags=None,58 include_di=True, cfgdata=None, common_tags=None,
37 verbosity=0, img_format=None):59 verbosity=0, img_format=None):
@@ -75,6 +97,17 @@
75 release)97 release)
76 rdata = r98 rdata = r
7799
100 arches = set([read_kdata(i, dict)['arch'] for i in rdata['kernels']])
101 if arch not in arches:
102 msg = (
103 "arch '%(arch)s' is not supported for release '%(release)s'.\n"
104 "Release has architectures: %(arches)s.\n"
105 "To support, add kernel info to config." %
106 {'arch': arch, 'release': release, 'arches': arches})
107 LOG.warn(msg)
108 sys.stderr.write(msg + "\n")
109 return {}
110
78 version = rdata['version']111 version = rdata['version']
79 if isinstance(version, float):112 if isinstance(version, float):
80 raise ValueError("release '%s' in config had version as a float (%s) "113 raise ValueError("release '%s' in config had version as a float (%s) "
@@ -142,11 +175,8 @@
142 kdata_defaults = {'suffix': "", 'di-format': "default", 'dtb': ""}175 kdata_defaults = {'suffix': "", 'di-format': "default", 'dtb': ""}
143176
144 for info in rdata['kernels']:177 for info in rdata['kernels']:
145 # 7th field is optional in kernel lines in config data178 (krel, karch, psubarch, flavor, kpkg, subarches, kdata) = (
146 # so fill it with empty dictionary if not present.179 read_kdata(info))
147 if len(info) == 6:
148 info.append({})
149 (krel, karch, psubarch, flavor, kpkg, subarches, kdata) = info
150180
151 if karch != arch:181 if karch != arch:
152 continue182 continue

Subscribers

People subscribed via source and target branches