Merge ~smoser/ubuntu/+source/open-iscsi:bug/1785108-bionic-net-interface-handler-runs-always into ubuntu/+source/open-iscsi:ubuntu/bionic-devel

Proposed by Scott Moser
Status: Merged
Merged at revision: fdb1b8c3131415fffc202e1922e723f16f66525e
Proposed branch: ~smoser/ubuntu/+source/open-iscsi:bug/1785108-bionic-net-interface-handler-runs-always
Merge into: ubuntu/+source/open-iscsi:ubuntu/bionic-devel
Diff against target: 273 lines (+99/-19)
7 files modified
debian/changelog (+8/-0)
debian/net-interface-handler (+18/-4)
debian/tests/README-boot-test.md (+10/-5)
debian/tests/patch-image (+44/-5)
debian/tests/test-open-iscsi.py (+15/-1)
debian/tests/tgt-boot-test (+2/-2)
debian/tests/xkvm (+2/-2)
Reviewer Review Type Date Requested Status
git-ubuntu developers Pending
Review via email: mp+352757@code.launchpad.net

Description of the change

see commit message

To post a comment you must log in.
Revision history for this message
Scott Moser (smoser) wrote :

I've just uploaded this to the queue, mostly just pushed a MP for easier review andlinking to the bug.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index 83773dc..b660fef 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,11 @@
6+open-iscsi (2.0.874-5ubuntu2.1) bionic; urgency=medium
7+
8+ * d/tests: pull back cloud image test updates from cosmic.
9+ * d/net-interface-handler: Apply changes only for the iscsi-root
10+ (LP: #1785108)
11+
12+ -- Scott Moser <smoser@ubuntu.com> Wed, 08 Aug 2018 09:09:02 -0400
13+
14 open-iscsi (2.0.874-5ubuntu2) bionic; urgency=medium
15
16 * debian/tests:
17diff --git a/debian/net-interface-handler b/debian/net-interface-handler
18index 7717f61..15d35c6 100755
19--- a/debian/net-interface-handler
20+++ b/debian/net-interface-handler
21@@ -10,12 +10,23 @@
22 # ifupdown appears to have no way to do this without also running
23 # /etc/network/*.d/ scripts.
24
25+assert_interface() {
26+ # udev sets INTERFACE to the name of the currently-processed nic.
27+ [ -n "$INTERFACE" ] && return 0
28+ echo "environment variable INTERFACE not set." 1>&2;
29+ return 1
30+}
31+
32 start() {
33 CR="
34 "
35+ assert_interface || return
36 ifile=/run/initramfs/open-iscsi.interface
37- if [ -f "$ifile" ] && read iface < "$ifile" &&
38- ! grep -qs "^$iface=" /run/network/ifstate; then
39+
40+ [ -f "$ifile" ] && read iface < "$ifile" || return 0
41+ [ "$INTERFACE" = "$iface" ] || return
42+
43+ if ! grep -qs "^$iface=" /run/network/ifstate; then
44 mkdir -p /run/network
45 echo "$iface=$iface" >>/run/network/ifstate
46
47@@ -51,9 +62,12 @@ EOF
48 }
49
50 stop() {
51+ assert_interface || return
52 ifile=/run/initramfs/open-iscsi.interface
53- if [ -f "$ifile" ] && read iface < "$ifile" &&
54- grep -qs "^$iface=" /run/network/ifstate; then
55+ [ -f "$ifile" ] && read iface < "$ifile" || return 0
56+ [ "$INTERFACE" = "$iface" ] || return
57+
58+ if grep -qs "^$iface=" /run/network/ifstate; then
59 grep -v "^$iface=" /run/network/ifstate >/run/network/.ifstate.tmp || true
60 mv /run/network/.ifstate.tmp /run/network/ifstate
61
62diff --git a/debian/tests/README-boot-test.md b/debian/tests/README-boot-test.md
63index 526090c..e45bbf0 100644
64--- a/debian/tests/README-boot-test.md
65+++ b/debian/tests/README-boot-test.md
66@@ -44,7 +44,7 @@ The test case in `debian/tests/test-open-iscsi.py` uses some helper tools.
67 using the updated initramfs we wouldn't really be testing the new
68 open-iscsi.
69
70- It will upgrade any packages inside that are mentioned in
71+ It will upgrade any packages inside that are mentioned in
72 ADT_TEST_TRIGGERS environment. It will also install open-iscsi if
73 it is not in that list.
74
75@@ -53,6 +53,9 @@ The test case in `debian/tests/test-open-iscsi.py` uses some helper tools.
76 repos into the target. This is necessary for the autopackage test
77 environment that adds local package repositories to sources.list.d.
78
79+ It may also make other changes to the image to workaround bugs.
80+ See --help output for list of bugs.
81+
82 * **get-image**: This downloads an image from cloud-images.ubuntu.com. See
83 its Usage for more information. it downloads via stream data and verifies
84 download. One thing to note is that it does not overwrite existing files.
85@@ -82,14 +85,16 @@ Testing manually looks like this:
86 ## Get the image you want. This creates out.d/disk.img and disk.img.dist
87 $ get-image xenial.d xenial
88
89- ## patch the image with an open-iscsi, which creates xenial/kernel
90- ## and xenial/initrd from the kernel and initramfs inside the image.
91+ ## patch the image with an open-iscsi, which creates xenial.d/kernel
92+ ## and xenial.d/initrd from the kernel and initramfs inside the image.
93 $ apt-get download open-iscsi
94 $ deb=$(ls open-iscsi_*.deb | tail -n 1)
95- $ patch-image xenial/disk.img "$deb" --kernel=xenial/kernel --initrd=xenial/initrd
96+ $ sudo ./debian/tests/patch-image \
97+ --kernel=xenial.d/kernel --initrd=xenial.d/initrd
98+ xenial.d/disk.img "$deb"
99
100 ## Boot the system, log in, look around.
101- $ tgt-boot-test -v xenial/disk.img xenial/kernel xenial/initrd
102+ $ tgt-boot-test -v xenial.d/disk.img xenial.d/kernel xenial.d/initrd
103
104
105 ### Features of tgt-boot-test ###
106diff --git a/debian/tests/patch-image b/debian/tests/patch-image
107index caba3da..b9b34e3 100755
108--- a/debian/tests/patch-image
109+++ b/debian/tests/patch-image
110@@ -11,9 +11,18 @@ Usage() {
111 cat <<EOF
112 Usage: ${0##*/} [options] image [packages]
113 Patch image, upgrading [packages].
114- --kernel FILE copy kernel out to FILE
115- --initrd FILE copy initrd out to FILE
116- --no-copy-apt do not copy apt repos in.
117+ --kernel FILE copy kernel out to FILE
118+ --initrd FILE copy initrd out to FILE
119+
120+ --krd-only only copy out kernel/initrd do not change image.
121+ this is incompatible with 'packages'
122+ it is a short-cut to specifying all the '--no-*'
123+ options below.
124+
125+ --no-copy-apt do not copy host's apt repos in.
126+
127+ image modifications:
128+ --no-update-fstab do not modify fstab (LP: #1732028)
129
130 if no packages are provided, and ADT_TEST_TRIGGERS is set
131 in environment, then it will be read for the list of packages.
132@@ -70,6 +79,17 @@ bin_packages_from_source_pkg() {
133 _RET=$(set -f; for i in ${ret}; do echo "$i"; done | sort -u)
134 }
135
136+update_fstab() {
137+ # update_fstab(path) modify the fstab at path
138+ # to remove problematic entries (LP: #1732028)
139+ local fstab="$1"
140+ if [ ! -e "$fstab.patch-image-dist" ]; then
141+ cp "$fstab" "$fstab.patch-image-dist" ||
142+ { error "failed backing up $fstab to $fstab.dist"; return 1; }
143+ fi
144+ sed -i '/^LABEL=UEFI/s/^/#/' "$fstab"
145+}
146+
147 main() {
148 local short_opts="hv"
149 local long_opts="help,no-copy-apt,initrd:,kernel:,verbose"
150@@ -81,13 +101,16 @@ main() {
151 { bad_Usage; return; }
152
153 local cur="" next=""
154- local kernel="" initrd="" copy_apt=true
155+ local kernel="" initrd="" copy_apt=true krd_only=false
156+ local update_fstab=true
157
158 while [ $# -ne 0 ]; do
159 cur="$1"; next="$2";
160 case "$cur" in
161 -h|--help) Usage ; exit 0;;
162+ --krd-only) krd_only=true; shift;;
163 --no-copy-apt) copy_apt=false; shift;;
164+ --no-update-fstab) update_fstab=false; shift;;
165 --kernel) kernel=$next; shift;;
166 --initrd) initrd=$next; shift;;
167 -v|--verbose) VERBOSITY=$((${VERBOSITY}+1));;
168@@ -121,6 +144,17 @@ main() {
169 local packages=( )
170 packages=( "$@" )
171
172+ if $krd_only; then
173+ if [ "${#packages[@]}" != 0 -a "${packages[*]}" != "none" ]; then
174+ error "--krd-only is incompatible with packages."
175+ return 1
176+ fi
177+ debug 1 "--krd-only provided no changes will be done."
178+ copy_apt=false
179+ update_fstab=false
180+ packages=( "none" )
181+ fi
182+
183 if [ "${#packages[@]}" = "1" -a "${packages[0]}" = "none" ]; then
184 packages=( )
185 elif [ "${#packages[@]}" -eq 0 -a -n "${ADT_TEST_TRIGGERS}" ]; then
186@@ -185,8 +219,13 @@ main() {
187 done
188 fi
189
190+ if $update_fstab; then
191+ update_fstab "$target/etc/fstab" ||
192+ { error "failed updating /etc/fstab in target"; return 1; }
193+ fi
194+
195 mount -o bind /sys "$target"/sys || :
196- mount -o bind /proc "$target"/proc || :
197+ mount -o bind /proc "$target"/proc || :
198 mount -o bind /dev "$target"/dev || :
199 mount -o bind /dev/pts "$target"/dev/pts || :
200
201diff --git a/debian/tests/test-open-iscsi.py b/debian/tests/test-open-iscsi.py
202index e7e37a8..27a5e0b 100644
203--- a/debian/tests/test-open-iscsi.py
204+++ b/debian/tests/test-open-iscsi.py
205@@ -75,8 +75,19 @@ bukket:
206 exit
207 fi
208 systemd-resolve --status --no-pager
209+ - &add_and_remove_tuntap |
210+ #!/bin/sh
211+ # LP: #1785108 would break dns when any device was removed.
212+ tapdev="mytap0"
213+ echo ==== Adding $tapdev ====
214+ ip tuntap add mode tap user root $tapdev
215+ udevadm settle
216+ echo ==== Removing $tapdev ====
217+ ip tuntap del mode tap $tapdev
218+ udevadm settle
219
220 runcmd:
221+ - [ sh, -c, *add_and_remove_tuntap ]
222 - [ mkdir, -p, /output ]
223 - [ cp, /etc/resolv.conf, /output]
224 - [ sh, -c, *get_resolved_status, --, /output/systemd-resolve-status.txt]
225@@ -271,7 +282,10 @@ class CloudImageTest(testlib.TestlibCase, PrivateOpenIscsiTest):
226 self.info['initrd']]
227 sys.stderr.write(' '.join(cmd) + "\n")
228
229- subprocess.check_call(cmd)
230+ env = os.environ.copy()
231+ env['BOOT_TIMEOUT'] = env.get('BOOT_TIMEOUT', '60m')
232+ subprocess.check_call(cmd, env=env)
233+
234 files = self.extract_files(output_disk)
235 print("files: %s" % files)
236 resolvconf = files.get('resolv.conf', "NO_RESOLVCONF_FOUND")
237diff --git a/debian/tests/tgt-boot-test b/debian/tests/tgt-boot-test
238index 2f8bff3..6ed7a9b 100755
239--- a/debian/tests/tgt-boot-test
240+++ b/debian/tests/tgt-boot-test
241@@ -514,8 +514,8 @@ main() {
242 local mem="512" start="$SECONDS" ret=""
243 local cmd=""
244 cmd=(
245- timeout --kill-after=1m --signal=TERM ${BOOT_TIMEOUT:-60m}
246- xkvm "${netdev_args[@]}" ${overlay_drive_xkvm} "${pt[@]}" --
247+ ${BOOT_TIMEOUT:+timeout --kill-after=1m --signal=TERM $BOOT_TIMEOUT}
248+ xkvm -v -v "${netdev_args[@]}" ${overlay_drive_xkvm} "${pt[@]}" --
249 -echr 0x5
250 -m $mem ${serial_log:+-serial "file:$serial_log"} -nographic
251 -kernel "${t_kernel}" -initrd "${t_initrd}"
252diff --git a/debian/tests/xkvm b/debian/tests/xkvm
253index 9015140..9513723 100755
254--- a/debian/tests/xkvm
255+++ b/debian/tests/xkvm
256@@ -292,7 +292,7 @@ get_bios_opts() {
257
258 if [ -n "$nvram" ]; then
259 if [ ! -f "$nvram" ]; then
260- cp "$nvram_src" "$nvram" ||
261+ cp "$nvram_src" "$nvram" ||
262 { error "failed copy $nvram_src to $nvram"; return 1; }
263 debug 1 "copied $nvram_src to $nvram"
264 fi
265@@ -664,7 +664,7 @@ main() {
266
267 local bus_devices
268 bus_devices=( -device "$virtio_scsi_bus,id=virtio-scsi-xkvm" )
269- cmd=( "${kvmcmd[@]}" "${archopts[@]}"
270+ cmd=( "${kvmcmd[@]}" "${archopts[@]}"
271 "${bios_opts[@]}"
272 "${bus_devices[@]}"
273 "${netargs[@]}"

Subscribers

People subscribed via source and target branches