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
diff --git a/debian/changelog b/debian/changelog
index 83773dc..b660fef 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
1open-iscsi (2.0.874-5ubuntu2.1) bionic; urgency=medium
2
3 * d/tests: pull back cloud image test updates from cosmic.
4 * d/net-interface-handler: Apply changes only for the iscsi-root
5 (LP: #1785108)
6
7 -- Scott Moser <smoser@ubuntu.com> Wed, 08 Aug 2018 09:09:02 -0400
8
1open-iscsi (2.0.874-5ubuntu2) bionic; urgency=medium9open-iscsi (2.0.874-5ubuntu2) bionic; urgency=medium
210
3 * debian/tests:11 * debian/tests:
diff --git a/debian/net-interface-handler b/debian/net-interface-handler
index 7717f61..15d35c6 100755
--- a/debian/net-interface-handler
+++ b/debian/net-interface-handler
@@ -10,12 +10,23 @@
10# ifupdown appears to have no way to do this without also running10# ifupdown appears to have no way to do this without also running
11# /etc/network/*.d/ scripts.11# /etc/network/*.d/ scripts.
1212
13assert_interface() {
14 # udev sets INTERFACE to the name of the currently-processed nic.
15 [ -n "$INTERFACE" ] && return 0
16 echo "environment variable INTERFACE not set." 1>&2;
17 return 1
18}
19
13start() {20start() {
14 CR="21 CR="
15"22"
23 assert_interface || return
16 ifile=/run/initramfs/open-iscsi.interface24 ifile=/run/initramfs/open-iscsi.interface
17 if [ -f "$ifile" ] && read iface < "$ifile" &&25
18 ! grep -qs "^$iface=" /run/network/ifstate; then26 [ -f "$ifile" ] && read iface < "$ifile" || return 0
27 [ "$INTERFACE" = "$iface" ] || return
28
29 if ! grep -qs "^$iface=" /run/network/ifstate; then
19 mkdir -p /run/network30 mkdir -p /run/network
20 echo "$iface=$iface" >>/run/network/ifstate31 echo "$iface=$iface" >>/run/network/ifstate
2132
@@ -51,9 +62,12 @@ EOF
51}62}
5263
53stop() {64stop() {
65 assert_interface || return
54 ifile=/run/initramfs/open-iscsi.interface66 ifile=/run/initramfs/open-iscsi.interface
55 if [ -f "$ifile" ] && read iface < "$ifile" &&67 [ -f "$ifile" ] && read iface < "$ifile" || return 0
56 grep -qs "^$iface=" /run/network/ifstate; then68 [ "$INTERFACE" = "$iface" ] || return
69
70 if grep -qs "^$iface=" /run/network/ifstate; then
57 grep -v "^$iface=" /run/network/ifstate >/run/network/.ifstate.tmp || true71 grep -v "^$iface=" /run/network/ifstate >/run/network/.ifstate.tmp || true
58 mv /run/network/.ifstate.tmp /run/network/ifstate72 mv /run/network/.ifstate.tmp /run/network/ifstate
5973
diff --git a/debian/tests/README-boot-test.md b/debian/tests/README-boot-test.md
index 526090c..e45bbf0 100644
--- a/debian/tests/README-boot-test.md
+++ b/debian/tests/README-boot-test.md
@@ -44,7 +44,7 @@ The test case in `debian/tests/test-open-iscsi.py` uses some helper tools.
44 using the updated initramfs we wouldn't really be testing the new44 using the updated initramfs we wouldn't really be testing the new
45 open-iscsi.45 open-iscsi.
4646
47 It will upgrade any packages inside that are mentioned in 47 It will upgrade any packages inside that are mentioned in
48 ADT_TEST_TRIGGERS environment. It will also install open-iscsi if48 ADT_TEST_TRIGGERS environment. It will also install open-iscsi if
49 it is not in that list.49 it is not in that list.
5050
@@ -53,6 +53,9 @@ The test case in `debian/tests/test-open-iscsi.py` uses some helper tools.
53 repos into the target. This is necessary for the autopackage test53 repos into the target. This is necessary for the autopackage test
54 environment that adds local package repositories to sources.list.d.54 environment that adds local package repositories to sources.list.d.
5555
56 It may also make other changes to the image to workaround bugs.
57 See --help output for list of bugs.
58
56 * **get-image**: This downloads an image from cloud-images.ubuntu.com. See59 * **get-image**: This downloads an image from cloud-images.ubuntu.com. See
57 its Usage for more information. it downloads via stream data and verifies60 its Usage for more information. it downloads via stream data and verifies
58 download. One thing to note is that it does not overwrite existing files.61 download. One thing to note is that it does not overwrite existing files.
@@ -82,14 +85,16 @@ Testing manually looks like this:
82 ## Get the image you want. This creates out.d/disk.img and disk.img.dist85 ## Get the image you want. This creates out.d/disk.img and disk.img.dist
83 $ get-image xenial.d xenial86 $ get-image xenial.d xenial
8487
85 ## patch the image with an open-iscsi, which creates xenial/kernel88 ## patch the image with an open-iscsi, which creates xenial.d/kernel
86 ## and xenial/initrd from the kernel and initramfs inside the image.89 ## and xenial.d/initrd from the kernel and initramfs inside the image.
87 $ apt-get download open-iscsi90 $ apt-get download open-iscsi
88 $ deb=$(ls open-iscsi_*.deb | tail -n 1)91 $ deb=$(ls open-iscsi_*.deb | tail -n 1)
89 $ patch-image xenial/disk.img "$deb" --kernel=xenial/kernel --initrd=xenial/initrd92 $ sudo ./debian/tests/patch-image \
93 --kernel=xenial.d/kernel --initrd=xenial.d/initrd
94 xenial.d/disk.img "$deb"
9095
91 ## Boot the system, log in, look around.96 ## Boot the system, log in, look around.
92 $ tgt-boot-test -v xenial/disk.img xenial/kernel xenial/initrd97 $ tgt-boot-test -v xenial.d/disk.img xenial.d/kernel xenial.d/initrd
9398
9499
95### Features of tgt-boot-test ###100### Features of tgt-boot-test ###
diff --git a/debian/tests/patch-image b/debian/tests/patch-image
index caba3da..b9b34e3 100755
--- a/debian/tests/patch-image
+++ b/debian/tests/patch-image
@@ -11,9 +11,18 @@ Usage() {
11 cat <<EOF11 cat <<EOF
12Usage: ${0##*/} [options] image [packages]12Usage: ${0##*/} [options] image [packages]
13 Patch image, upgrading [packages].13 Patch image, upgrading [packages].
14 --kernel FILE copy kernel out to FILE14 --kernel FILE copy kernel out to FILE
15 --initrd FILE copy initrd out to FILE15 --initrd FILE copy initrd out to FILE
16 --no-copy-apt do not copy apt repos in.16
17 --krd-only only copy out kernel/initrd do not change image.
18 this is incompatible with 'packages'
19 it is a short-cut to specifying all the '--no-*'
20 options below.
21
22 --no-copy-apt do not copy host's apt repos in.
23
24 image modifications:
25 --no-update-fstab do not modify fstab (LP: #1732028)
1726
18 if no packages are provided, and ADT_TEST_TRIGGERS is set27 if no packages are provided, and ADT_TEST_TRIGGERS is set
19 in environment, then it will be read for the list of packages.28 in environment, then it will be read for the list of packages.
@@ -70,6 +79,17 @@ bin_packages_from_source_pkg() {
70 _RET=$(set -f; for i in ${ret}; do echo "$i"; done | sort -u)79 _RET=$(set -f; for i in ${ret}; do echo "$i"; done | sort -u)
71}80}
7281
82update_fstab() {
83 # update_fstab(path) modify the fstab at path
84 # to remove problematic entries (LP: #1732028)
85 local fstab="$1"
86 if [ ! -e "$fstab.patch-image-dist" ]; then
87 cp "$fstab" "$fstab.patch-image-dist" ||
88 { error "failed backing up $fstab to $fstab.dist"; return 1; }
89 fi
90 sed -i '/^LABEL=UEFI/s/^/#/' "$fstab"
91}
92
73main() {93main() {
74 local short_opts="hv"94 local short_opts="hv"
75 local long_opts="help,no-copy-apt,initrd:,kernel:,verbose"95 local long_opts="help,no-copy-apt,initrd:,kernel:,verbose"
@@ -81,13 +101,16 @@ main() {
81 { bad_Usage; return; }101 { bad_Usage; return; }
82102
83 local cur="" next=""103 local cur="" next=""
84 local kernel="" initrd="" copy_apt=true104 local kernel="" initrd="" copy_apt=true krd_only=false
105 local update_fstab=true
85106
86 while [ $# -ne 0 ]; do107 while [ $# -ne 0 ]; do
87 cur="$1"; next="$2";108 cur="$1"; next="$2";
88 case "$cur" in109 case "$cur" in
89 -h|--help) Usage ; exit 0;;110 -h|--help) Usage ; exit 0;;
111 --krd-only) krd_only=true; shift;;
90 --no-copy-apt) copy_apt=false; shift;;112 --no-copy-apt) copy_apt=false; shift;;
113 --no-update-fstab) update_fstab=false; shift;;
91 --kernel) kernel=$next; shift;;114 --kernel) kernel=$next; shift;;
92 --initrd) initrd=$next; shift;;115 --initrd) initrd=$next; shift;;
93 -v|--verbose) VERBOSITY=$((${VERBOSITY}+1));;116 -v|--verbose) VERBOSITY=$((${VERBOSITY}+1));;
@@ -121,6 +144,17 @@ main() {
121 local packages=( )144 local packages=( )
122 packages=( "$@" )145 packages=( "$@" )
123146
147 if $krd_only; then
148 if [ "${#packages[@]}" != 0 -a "${packages[*]}" != "none" ]; then
149 error "--krd-only is incompatible with packages."
150 return 1
151 fi
152 debug 1 "--krd-only provided no changes will be done."
153 copy_apt=false
154 update_fstab=false
155 packages=( "none" )
156 fi
157
124 if [ "${#packages[@]}" = "1" -a "${packages[0]}" = "none" ]; then158 if [ "${#packages[@]}" = "1" -a "${packages[0]}" = "none" ]; then
125 packages=( )159 packages=( )
126 elif [ "${#packages[@]}" -eq 0 -a -n "${ADT_TEST_TRIGGERS}" ]; then160 elif [ "${#packages[@]}" -eq 0 -a -n "${ADT_TEST_TRIGGERS}" ]; then
@@ -185,8 +219,13 @@ main() {
185 done219 done
186 fi220 fi
187221
222 if $update_fstab; then
223 update_fstab "$target/etc/fstab" ||
224 { error "failed updating /etc/fstab in target"; return 1; }
225 fi
226
188 mount -o bind /sys "$target"/sys || :227 mount -o bind /sys "$target"/sys || :
189 mount -o bind /proc "$target"/proc || : 228 mount -o bind /proc "$target"/proc || :
190 mount -o bind /dev "$target"/dev || :229 mount -o bind /dev "$target"/dev || :
191 mount -o bind /dev/pts "$target"/dev/pts || :230 mount -o bind /dev/pts "$target"/dev/pts || :
192231
diff --git a/debian/tests/test-open-iscsi.py b/debian/tests/test-open-iscsi.py
index e7e37a8..27a5e0b 100644
--- a/debian/tests/test-open-iscsi.py
+++ b/debian/tests/test-open-iscsi.py
@@ -75,8 +75,19 @@ bukket:
75 exit75 exit
76 fi76 fi
77 systemd-resolve --status --no-pager77 systemd-resolve --status --no-pager
78 - &add_and_remove_tuntap |
79 #!/bin/sh
80 # LP: #1785108 would break dns when any device was removed.
81 tapdev="mytap0"
82 echo ==== Adding $tapdev ====
83 ip tuntap add mode tap user root $tapdev
84 udevadm settle
85 echo ==== Removing $tapdev ====
86 ip tuntap del mode tap $tapdev
87 udevadm settle
7888
79runcmd:89runcmd:
90 - [ sh, -c, *add_and_remove_tuntap ]
80 - [ mkdir, -p, /output ]91 - [ mkdir, -p, /output ]
81 - [ cp, /etc/resolv.conf, /output]92 - [ cp, /etc/resolv.conf, /output]
82 - [ sh, -c, *get_resolved_status, --, /output/systemd-resolve-status.txt]93 - [ sh, -c, *get_resolved_status, --, /output/systemd-resolve-status.txt]
@@ -271,7 +282,10 @@ class CloudImageTest(testlib.TestlibCase, PrivateOpenIscsiTest):
271 self.info['initrd']]282 self.info['initrd']]
272 sys.stderr.write(' '.join(cmd) + "\n")283 sys.stderr.write(' '.join(cmd) + "\n")
273284
274 subprocess.check_call(cmd)285 env = os.environ.copy()
286 env['BOOT_TIMEOUT'] = env.get('BOOT_TIMEOUT', '60m')
287 subprocess.check_call(cmd, env=env)
288
275 files = self.extract_files(output_disk)289 files = self.extract_files(output_disk)
276 print("files: %s" % files)290 print("files: %s" % files)
277 resolvconf = files.get('resolv.conf', "NO_RESOLVCONF_FOUND")291 resolvconf = files.get('resolv.conf', "NO_RESOLVCONF_FOUND")
diff --git a/debian/tests/tgt-boot-test b/debian/tests/tgt-boot-test
index 2f8bff3..6ed7a9b 100755
--- a/debian/tests/tgt-boot-test
+++ b/debian/tests/tgt-boot-test
@@ -514,8 +514,8 @@ main() {
514 local mem="512" start="$SECONDS" ret=""514 local mem="512" start="$SECONDS" ret=""
515 local cmd=""515 local cmd=""
516 cmd=(516 cmd=(
517 timeout --kill-after=1m --signal=TERM ${BOOT_TIMEOUT:-60m}517 ${BOOT_TIMEOUT:+timeout --kill-after=1m --signal=TERM $BOOT_TIMEOUT}
518 xkvm "${netdev_args[@]}" ${overlay_drive_xkvm} "${pt[@]}" --518 xkvm -v -v "${netdev_args[@]}" ${overlay_drive_xkvm} "${pt[@]}" --
519 -echr 0x5519 -echr 0x5
520 -m $mem ${serial_log:+-serial "file:$serial_log"} -nographic520 -m $mem ${serial_log:+-serial "file:$serial_log"} -nographic
521 -kernel "${t_kernel}" -initrd "${t_initrd}"521 -kernel "${t_kernel}" -initrd "${t_initrd}"
diff --git a/debian/tests/xkvm b/debian/tests/xkvm
index 9015140..9513723 100755
--- a/debian/tests/xkvm
+++ b/debian/tests/xkvm
@@ -292,7 +292,7 @@ get_bios_opts() {
292292
293 if [ -n "$nvram" ]; then293 if [ -n "$nvram" ]; then
294 if [ ! -f "$nvram" ]; then294 if [ ! -f "$nvram" ]; then
295 cp "$nvram_src" "$nvram" || 295 cp "$nvram_src" "$nvram" ||
296 { error "failed copy $nvram_src to $nvram"; return 1; }296 { error "failed copy $nvram_src to $nvram"; return 1; }
297 debug 1 "copied $nvram_src to $nvram"297 debug 1 "copied $nvram_src to $nvram"
298 fi298 fi
@@ -664,7 +664,7 @@ main() {
664664
665 local bus_devices665 local bus_devices
666 bus_devices=( -device "$virtio_scsi_bus,id=virtio-scsi-xkvm" )666 bus_devices=( -device "$virtio_scsi_bus,id=virtio-scsi-xkvm" )
667 cmd=( "${kvmcmd[@]}" "${archopts[@]}" 667 cmd=( "${kvmcmd[@]}" "${archopts[@]}"
668 "${bios_opts[@]}"668 "${bios_opts[@]}"
669 "${bus_devices[@]}"669 "${bus_devices[@]}"
670 "${netargs[@]}"670 "${netargs[@]}"

Subscribers

People subscribed via source and target branches