Merge lp:~jtv/maas/1.3-maas-import-pxe-files-changes into lp:maas/1.3

Proposed by Jeroen T. Vermeulen
Status: Merged
Approved by: Jeroen T. Vermeulen
Approved revision: no longer in the source branch.
Merged at revision: 1473
Proposed branch: lp:~jtv/maas/1.3-maas-import-pxe-files-changes
Merge into: lp:maas/1.3
Diff against target: 105 lines (+44/-20)
1 file modified
scripts/maas-import-pxe-files (+44/-20)
To merge this branch: bzr merge lp:~jtv/maas/1.3-maas-import-pxe-files-changes
Reviewer Review Type Date Requested Status
Raphaël Badin (community) Approve
Review via email: mp+188307@code.launchpad.net

Commit message

Backport fixes for bug 1212434 and 1233069 from trunk.

Description of the change

This backports these changes, bundled into one:

    https://code.launchpad.net/~jtv/maas/bug-1212434/+merge/187985
    https://code.launchpad.net/~jtv/maas/bug-1233069/+merge/188301

Together, these make maas-import-pxe-files plod on if some images fail to download. It's not a clean merge, hence this merge proposal.

Jeroen

To post a comment you must log in.
Revision history for this message
Raphaël Badin (rvb) wrote :

Looks good. Probably worth backporting to 1.2 as well as this fixes two critical bugs.

review: Approve
Revision history for this message
Raphaël Badin (rvb) wrote :

Well, one 'critical' bug and one 'high' bug but still :)

Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'scripts/maas-import-pxe-files'
2--- scripts/maas-import-pxe-files 2013-09-11 03:37:42 +0000
3+++ scripts/maas-import-pxe-files 2013-09-30 11:41:10 +0000
4@@ -1,5 +1,5 @@
5 #!/usr/bin/env bash
6-# Copyright 2012 Canonical Ltd. This software is licensed under the
7+# Copyright 2012, 2013 Canonical Ltd. This software is licensed under the
8 # GNU Affero General Public License version 3 (see the file LICENSE).
9 #
10 # Download static files needed for net-booting nodes through TFTP:
11@@ -21,7 +21,9 @@
12 # Location of the GPG keyring for the Ubuntu archive.
13 GPG_KEYRING="${GPG_KEYRING:-/usr/share/keyrings/ubuntu-archive-keyring.gpg}"
14
15-# Whether to check GPG keys (necessary for testing of this script).
16+# Whether to skip checking GPG keys (necessary for testing of this script).
17+# Set this to a nonempty string to skip checking. This is needed for test
18+# programs, because they can't possibly sign with the right key.
19 IGNORE_GPG="${IGNORE_GPG:-}"
20
21 # Download locations for Ubuntu releases. When the cluster controller runs
22@@ -130,23 +132,32 @@
23 echo "$base_url/$postfix"
24 }
25
26+# Fetch MD5SUMS file. This returns false (i.e. nonzero) in the case of
27+# survivable failure, so that the caller can skip this image and move on.
28 fetch_server_md5sums() {
29 local base_url=$1
30- local ignore
31-
32- # Make $IGNORE_GPG non-empty for test programs, as they can't possibly
33- # GPG sign with the right key.
34- if [ "x$IGNORE_GPG" == "x" ]; then
35- $DOWNLOAD "$base_url/MD5SUMS" &&
36- $DOWNLOAD "$base_url/MD5SUMS.gpg" ||
37- fail "unable to download $base_url/MD5SUMS[.gpg]"
38-
39- ignore=$(gpg --keyring=$GPG_KEYRING --verify MD5SUMS.gpg MD5SUMS 2>&1) ||
40- fail "failed to verify MD5SUMS via $GPG_KEYRING ($base_url/MD5SUMS)"
41- else
42- $DOWNLOAD "$base_url/MD5SUMS" ||
43- fail "unable to download $base_url/MD5SUMS"
44- fi
45+
46+ if ! $DOWNLOAD "$base_url/MD5SUMS"
47+ then
48+ echo "Unable to download $base_url/MD5SUMS" >&2
49+ return 1
50+ fi
51+
52+ if [ "x$IGNORE_GPG" == "x" ]
53+ then
54+ if ! $DOWNLOAD "$base_url/MD5SUMS.gpg"
55+ then
56+ echo "Unable to download $base_url/MD5SUMS.gpg" >&2
57+ return 1
58+ fi
59+
60+ if ! gpg --keyring=$GPG_KEYRING --verify MD5SUMS.gpg MD5SUMS >/dev/null 2>/dev/null
61+ then
62+ echo "Failed to verify MD5SUMS via $GPG_KEYRING ($base_url/MD5SUMS)" >&2
63+ return 1
64+ fi
65+ fi
66+ return 0
67 }
68
69 get_md5sum_for_file() {
70@@ -224,7 +235,7 @@
71
72
73 # Download kernel/initrd for installing Ubuntu release $2 for
74-# architecture $1 and install it into the TFTP directory hierarchy.
75+# architecture $1, and install them into the TFTP directory hierarchy.
76 update_install_files() {
77 local arch=$1 release=$2
78 local files file url file_prefix filename_in_md5sums_file md5sum
79@@ -234,11 +245,24 @@
80
81 mkdir "install"
82 pushd "install" >/dev/null
83- fetch_server_md5sums $(compose_installer_base_url $arch $release)
84+ if ! fetch_server_md5sums $(compose_installer_base_url $arch $release)
85+ then
86+ echo "Failed to download MD5 sums for $arch $release." >&2
87+ popd >/dev/null
88+ rm -rf "install"
89+ return
90+ fi
91 echo "MD5SUMS GPG signature OK for $arch $release"
92 for file in $files
93 do
94- $DOWNLOAD $url/$file
95+ if ! $DOWNLOAD $url/$file
96+ then
97+ # Download failed. Log error, and skip this image.
98+ echo "Failed to download $url/$file" >&2
99+ popd >/dev/null
100+ rm -rf "install"
101+ return
102+ fi
103 file_prefix=$(compose_installer_download_url_postfix $arch)
104 filename_in_md5sums_file=$file_prefix$file
105 md5sum=$(get_md5sum_for_file $filename_in_md5sums_file)

Subscribers

People subscribed via source and target branches