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

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

Commit message

Backport maas-import-pxe-files changes froom trunk: survive image download failures.

Description of the change

This is similar to https://code.launchpad.net/~jtv/maas/1.3-maas-import-pxe-files-changes/+merge/188307 — but backporting to the 1.2 branch instead of the 1.3 branch.

It's not a clean merge, hence this merge proposal. But the changes were much the same as for 1.3.

Jeroen

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

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:41:26 +0000
3+++ scripts/maas-import-pxe-files 2013-10-01 03:54:22 +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,10 +21,13 @@
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.
22+# Download locations for Ubuntu releases. When the cluster controller runs
23+# the import scripts, it provides settings from the server side.
24 MAIN_ARCHIVE=${MAIN_ARCHIVE:-http://archive.ubuntu.com/ubuntu/}
25 PORTS_ARCHIVE=${PORTS_ARCHIVE:-http://ports.ubuntu.com/ubuntu-ports/}
26
27@@ -129,23 +132,32 @@
28 echo "$base_url/$postfix"
29 }
30
31+# Fetch MD5SUMS file. This returns false (i.e. nonzero) in the case of
32+# survivable failure, so that the caller can skip this image and move on.
33 fetch_server_md5sums() {
34 local base_url=$1
35- local ignore
36-
37- # Make $IGNORE_GPG non-empty for test programs, as they can't possibly
38- # GPG sign with the right key.
39- if [ "x$IGNORE_GPG" == "x" ]; then
40- $DOWNLOAD "$base_url/MD5SUMS" &&
41- $DOWNLOAD "$base_url/MD5SUMS.gpg" ||
42- fail "unable to download $base_url/MD5SUMS[.gpg]"
43-
44- ignore=$(gpg --keyring=$GPG_KEYRING --verify MD5SUMS.gpg MD5SUMS 2>&1) ||
45- fail "failed to verify MD5SUMS via $GPG_KEYRING ($base_url/MD5SUMS)"
46- else
47- $DOWNLOAD "$base_url/MD5SUMS" ||
48- fail "unable to download $base_url/MD5SUMS"
49- fi
50+
51+ if ! $DOWNLOAD "$base_url/MD5SUMS"
52+ then
53+ echo "Unable to download $base_url/MD5SUMS" >&2
54+ return 1
55+ fi
56+
57+ if [ "x$IGNORE_GPG" == "x" ]
58+ then
59+ if ! $DOWNLOAD "$base_url/MD5SUMS.gpg"
60+ then
61+ echo "Unable to download $base_url/MD5SUMS.gpg" >&2
62+ return 1
63+ fi
64+
65+ if ! gpg --keyring=$GPG_KEYRING --verify MD5SUMS.gpg MD5SUMS >/dev/null 2>/dev/null
66+ then
67+ echo "Failed to verify MD5SUMS via $GPG_KEYRING ($base_url/MD5SUMS)" >&2
68+ return 1
69+ fi
70+ fi
71+ return 0
72 }
73
74 get_md5sum_for_file() {
75@@ -223,7 +235,7 @@
76
77
78 # Download kernel/initrd for installing Ubuntu release $2 for
79-# architecture $1 and install it into the TFTP directory hierarchy.
80+# architecture $1, and install them into the TFTP directory hierarchy.
81 update_install_files() {
82 local arch=$1 release=$2
83 local files file url file_prefix filename_in_md5sums_file md5sum
84@@ -233,11 +245,24 @@
85
86 mkdir "install"
87 pushd "install" >/dev/null
88- fetch_server_md5sums $(compose_installer_base_url $arch $release)
89+ if ! fetch_server_md5sums $(compose_installer_base_url $arch $release)
90+ then
91+ echo "Failed to download MD5 sums for $arch $release." >&2
92+ popd >/dev/null
93+ rm -rf "install"
94+ return
95+ fi
96 echo "MD5SUMS GPG signature OK for $arch $release"
97 for file in $files
98 do
99- $DOWNLOAD $url/$file
100+ if ! $DOWNLOAD $url/$file
101+ then
102+ # Download failed. Log error, and skip this image.
103+ echo "Failed to download $url/$file" >&2
104+ popd >/dev/null
105+ rm -rf "install"
106+ return
107+ fi
108 file_prefix=$(compose_installer_download_url_postfix $arch)
109 filename_in_md5sums_file=$file_prefix$file
110 md5sum=$(get_md5sum_for_file $filename_in_md5sums_file)

Subscribers

People subscribed via source and target branches

to status/vote changes: