Merge lp:~racb/maas/multi-soc-ephemerals into lp:maas/trunk
| Status: | Merged |
|---|---|
| Approved by: | Robie Basak on 2012-12-04 |
| Approved revision: | 1358 |
| Merged at revision: | 1394 |
| Proposed branch: | lp:~racb/maas/multi-soc-ephemerals |
| Merge into: | lp:maas/trunk |
| Diff against target: |
98 lines (+47/-13) 1 file modified
scripts/maas-import-ephemerals (+47/-13) |
| To merge this branch: | bzr merge lp:~racb/maas/multi-soc-ephemerals |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Gavin Panella (community) | 2012-11-16 | Approve on 2012-11-19 | |
| Scott Moser | 2012-11-16 | Pending | |
|
Review via email:
|
|||
Commit Message
Add multi-SoC support to ephemeral image import
If ephemeral image tarballs contain a subarch/ directory, then import the
linux and initrd.gz files for each subarch as TFTP commissioning images into
MAAS.
If subarch/ does not exist, behave exactly the same as before.
This allows armhf SoCs that require different kernels to all be supported
by a single armhf ephemeral image with multiple kernels installed within it.
Description of the Change
I'd like this to end up in a Precise SRU, so that we can enable other ARM server systems based on non-highbank SoCs as they become available.
There are no flag days. We can generate ephemeral images with subarch/ directories whenever we need. When a MAAS installation uses the updated import script and the ephemeral image has a subarch/ directory, it'll all just start working.
| Robie Basak (racb) wrote : | # |
| Gavin Panella (allenap) wrote : | # |
Thanks for doing this Robie. However, it's untested, and shell script. I'm very reluctant to +1 any more shell script into production parts of MAAS, tested or not, but without tests it's got no hope. Can you move this logic into Python - or just about anything other than shell script - such that it can also be tested without having to drive pencils into our temples?
| Scott Moser (smoser) wrote : | # |
some things:
* use more quotes. example 'cp $src/subarch/
* generally i think that $(subcmd) is used here rather than `subcmd`. just try to keep consistent.
* uniq_major_arches uses global 'arch' destroying its contents. needs to declare 'local' for arch.
* subarches needs 'local' on variables.
* 'mv' on line 40 can be made (i think) to avoid the race condition of "check then move".
see '--target-
generally looks reasonable and most of hte above are nitpick. and i'm not opposed to writing these things in python.
| Gavin Panella (allenap) wrote : | # |
Despite the dread I feel, I'll +1 this because we don't have the means
right now to refactor with confidence, nor do we have the time to go
through indeterminable QA iterations after a rewrite (it might be fine
on the first go, but we can't have much confidence in that).
I assume this will be well exercised before it gets SRU'd?
[1]
+ for arch in "$@"; do echo $arch; done|cut -f1 -d/|uniq
You could save a process here:
for arch in "$@"; do echo "${arch%%/*}"; done | uniq
[2]
+ $major_arch/*) echo "$candidate"|cut -f2 -d/ ;;
Similar thing to [1] here:
$major_arch/*) echo "${candidate#*/}" ;;
[3]
+ for arch in `uniq_major_arches $ARCHES`; do
...
+ for subarch in `subarches $arch $ARCHES`; do
Beware that errors from these new functions won't do anything; command
substitution hides errors. I think they're simple enough that won't
fail, but it's worth knowing for the future.
[4]
+ for arch in "$@"; do echo $arch; done|cut -f1 -d/|uniq
Fwiw, if $arch is -e, -E or -n, echo will absorb it as flag. Afaik
there's no way to avoid this, other than to use printf:
for arch in "$@"; do printf "%s\n" $arch; done|cut -f1 -d/|uniq
Which gives me an idea of how to make this simpler:
printf "%s\n" "$@" | uniq
- 1355. By Robie Basak on 2012-11-23
-
Quote all shell variables
This excludes ARCHES, as it is whitespace-
separated. As a result, any
arch with a space in the name is broken anyway. - 1356. By Robie Basak on 2012-11-23
-
Use $() instead of ``
- 1357. By Robie Basak on 2012-11-23
-
Declare local variables to avoid clobbering globals
- 1358. By Robie Basak on 2012-11-23
-
Use parameter expansions instead of cut
| Robie Basak (racb) wrote : | # |
Thanks for the reviews!
I've made all requested changes except:
Gavin> printf; as discussed, we couldn't find this use documented anywhere so I have left the echo instead.
Scott> "check then move" race; this race exists for all the other checks and moves in the script already, and I didn't want to break the existing pattern as I felt that would make the code less readable for no real gain. Multiple concurrent calls to maas-import-
| Julian Edwards (julian-edwards) wrote : | # |
JFLI!


Example of subarch ephemeral image entries:
quantal- ephemeral- maas-armhf- initrd ephemeral- maas-armhf- vmlinuz ephemeral- maas-armhf. img armadaxp/ initrd. gz armadaxp/ linux highbank/ initrd. gz highbank/ linux
quantal-
quantal-
subarch/
subarch/armadaxp/
subarch/
subarch/
subarch/highbank/
subarch/
subarch/
I went with initrd.gz as this is what seems to be used internally within maas-import- ephemerals. However, note that the expectation of a file ending in ".gz" is that gunzip will work on it, but in the case of armadaxp, there is an extra "uInitrd" wrapper (created by u-boot's mkimage) that breaks this expectation. Using "initrd" instead of "initrd.gz" universally would be better, but it is possibly not practical to make this change everywhere now.
The alternative would be to ship it as uInitrd and uImage inside subarch/armadaxp and have maas-import- ephemerals rename it as needed.