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

Proposed by Scott Moser
Status: Merged
Merged at revision: d668e0c6b50ace3fdfaac06b5cd525814f24dd8f
Proposed branch: ~smoser/ubuntu/+source/open-iscsi:bug/1785108-net-interface-handler-runs-always
Merge into: ubuntu/+source/open-iscsi:ubuntu/devel
Diff against target: 168 lines (+53/-13)
6 files modified
debian/changelog (+10/-0)
debian/net-interface-handler (+18/-4)
debian/tests/README-boot-test.md (+7/-5)
debian/tests/test-open-iscsi.py (+15/-1)
debian/tests/tgt-boot-test (+1/-1)
debian/tests/xkvm (+2/-2)
Reviewer Review Type Date Requested Status
Christian Ehrhardt  (community) Approve
Review via email: mp+352215@code.launchpad.net

Commit message

net-interface-handler: Apply changes only for the iscsi-root interface.

net-interface-handler was effectively bringing "up" the iscsi-root
interface for all network device adds and it "down" for all the removes.
The quotes are used above because the design point of the script is to
basically fake ifupdown into believing the event already occurred.

The change here is to only operate when the INTERFACE provided by
udev is the iscsi root device.

LP: #1785108

Description of the change

see commit message

To post a comment you must log in.
f5d9539... by Scott Moser

debian/tests/test-open-iscsi.py: attempt to trigger 1785108

Without the fix applied, this would cause test failure.

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

I know these env vars are defined by the caller, but shouldn't we do a minimal bit of
[ -n $INTERFACE ] || return
before using it?

After wondering about this I found that it is done at least for some variables like DOMAINSEARCH below. I know that those are optional and INTERFACE should be mandatory, but I'd feel better if it was checked before being used.

Other than that the change LGTM - up to you if you'd want to add a check for some extra safety +1

I have not had a setup to test this on iscsi-root, but I assume you did so already on oracles cloud right?

review: Approve
8b3d475... by Scott Moser

only run 'timeout' from test harness making interactive more useful.

The test harness needs/wants the timeout set, but when running
interactively you do not get console output and cannot interact
with qemu. So have the harness set BOOT_TIMEOUT and only use
timeout if it is set.

5bf4f57... by Scott Moser

update doc debian/tests/README-boot-test.md

d3fa82a... by Scott Moser

update changelog for BOOT_TIMEOUT

d0d00c2... by Scott Moser

update changelog: README-boot-test.md and whitespace

406ab8f... by Scott Moser

update changelog fix 1785108

3554b6c... by Scott Moser

releasing package open-iscsi version 2.0.874-5ubuntu7

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 ebdada2..41024ba 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,13 @@
6+open-iscsi (2.0.874-5ubuntu7) UNRELEASED; urgency=medium
7+
8+ * d/tests: make interactive use of tgt-boot-test more usable by
9+ only using 'timeout' from the test harness.
10+ * debian/tests/README-boot-test.md: minor doc fixes and whitespace.
11+ * d/net-interface-handler: Apply changes only for the iscsi-root interface.
12+ (LP: #1785108)
13+
14+ -- Scott Moser <smoser@ubuntu.com> Tue, 07 Aug 2018 15:46:41 -0400
15+
16 open-iscsi (2.0.874-5ubuntu6) cosmic; urgency=medium
17
18 * Ship finalrd logout hook.
19diff --git a/debian/net-interface-handler b/debian/net-interface-handler
20index 7717f61..15d35c6 100755
21--- a/debian/net-interface-handler
22+++ b/debian/net-interface-handler
23@@ -10,12 +10,23 @@
24 # ifupdown appears to have no way to do this without also running
25 # /etc/network/*.d/ scripts.
26
27+assert_interface() {
28+ # udev sets INTERFACE to the name of the currently-processed nic.
29+ [ -n "$INTERFACE" ] && return 0
30+ echo "environment variable INTERFACE not set." 1>&2;
31+ return 1
32+}
33+
34 start() {
35 CR="
36 "
37+ assert_interface || return
38 ifile=/run/initramfs/open-iscsi.interface
39- if [ -f "$ifile" ] && read iface < "$ifile" &&
40- ! grep -qs "^$iface=" /run/network/ifstate; then
41+
42+ [ -f "$ifile" ] && read iface < "$ifile" || return 0
43+ [ "$INTERFACE" = "$iface" ] || return
44+
45+ if ! grep -qs "^$iface=" /run/network/ifstate; then
46 mkdir -p /run/network
47 echo "$iface=$iface" >>/run/network/ifstate
48
49@@ -51,9 +62,12 @@ EOF
50 }
51
52 stop() {
53+ assert_interface || return
54 ifile=/run/initramfs/open-iscsi.interface
55- if [ -f "$ifile" ] && read iface < "$ifile" &&
56- grep -qs "^$iface=" /run/network/ifstate; then
57+ [ -f "$ifile" ] && read iface < "$ifile" || return 0
58+ [ "$INTERFACE" = "$iface" ] || return
59+
60+ if grep -qs "^$iface=" /run/network/ifstate; then
61 grep -v "^$iface=" /run/network/ifstate >/run/network/.ifstate.tmp || true
62 mv /run/network/.ifstate.tmp /run/network/ifstate
63
64diff --git a/debian/tests/README-boot-test.md b/debian/tests/README-boot-test.md
65index 4d6033f..e45bbf0 100644
66--- a/debian/tests/README-boot-test.md
67+++ b/debian/tests/README-boot-test.md
68@@ -44,7 +44,7 @@ The test case in `debian/tests/test-open-iscsi.py` uses some helper tools.
69 using the updated initramfs we wouldn't really be testing the new
70 open-iscsi.
71
72- It will upgrade any packages inside that are mentioned in
73+ It will upgrade any packages inside that are mentioned in
74 ADT_TEST_TRIGGERS environment. It will also install open-iscsi if
75 it is not in that list.
76
77@@ -85,14 +85,16 @@ Testing manually looks like this:
78 ## Get the image you want. This creates out.d/disk.img and disk.img.dist
79 $ get-image xenial.d xenial
80
81- ## patch the image with an open-iscsi, which creates xenial/kernel
82- ## and xenial/initrd from the kernel and initramfs inside the image.
83+ ## patch the image with an open-iscsi, which creates xenial.d/kernel
84+ ## and xenial.d/initrd from the kernel and initramfs inside the image.
85 $ apt-get download open-iscsi
86 $ deb=$(ls open-iscsi_*.deb | tail -n 1)
87- $ patch-image xenial/disk.img "$deb" --kernel=xenial/kernel --initrd=xenial/initrd
88+ $ sudo ./debian/tests/patch-image \
89+ --kernel=xenial.d/kernel --initrd=xenial.d/initrd
90+ xenial.d/disk.img "$deb"
91
92 ## Boot the system, log in, look around.
93- $ tgt-boot-test -v xenial/disk.img xenial/kernel xenial/initrd
94+ $ tgt-boot-test -v xenial.d/disk.img xenial.d/kernel xenial.d/initrd
95
96
97 ### Features of tgt-boot-test ###
98diff --git a/debian/tests/test-open-iscsi.py b/debian/tests/test-open-iscsi.py
99index e7e37a8..27a5e0b 100644
100--- a/debian/tests/test-open-iscsi.py
101+++ b/debian/tests/test-open-iscsi.py
102@@ -75,8 +75,19 @@ bukket:
103 exit
104 fi
105 systemd-resolve --status --no-pager
106+ - &add_and_remove_tuntap |
107+ #!/bin/sh
108+ # LP: #1785108 would break dns when any device was removed.
109+ tapdev="mytap0"
110+ echo ==== Adding $tapdev ====
111+ ip tuntap add mode tap user root $tapdev
112+ udevadm settle
113+ echo ==== Removing $tapdev ====
114+ ip tuntap del mode tap $tapdev
115+ udevadm settle
116
117 runcmd:
118+ - [ sh, -c, *add_and_remove_tuntap ]
119 - [ mkdir, -p, /output ]
120 - [ cp, /etc/resolv.conf, /output]
121 - [ sh, -c, *get_resolved_status, --, /output/systemd-resolve-status.txt]
122@@ -271,7 +282,10 @@ class CloudImageTest(testlib.TestlibCase, PrivateOpenIscsiTest):
123 self.info['initrd']]
124 sys.stderr.write(' '.join(cmd) + "\n")
125
126- subprocess.check_call(cmd)
127+ env = os.environ.copy()
128+ env['BOOT_TIMEOUT'] = env.get('BOOT_TIMEOUT', '60m')
129+ subprocess.check_call(cmd, env=env)
130+
131 files = self.extract_files(output_disk)
132 print("files: %s" % files)
133 resolvconf = files.get('resolv.conf', "NO_RESOLVCONF_FOUND")
134diff --git a/debian/tests/tgt-boot-test b/debian/tests/tgt-boot-test
135index f3708a0..6ed7a9b 100755
136--- a/debian/tests/tgt-boot-test
137+++ b/debian/tests/tgt-boot-test
138@@ -514,7 +514,7 @@ main() {
139 local mem="512" start="$SECONDS" ret=""
140 local cmd=""
141 cmd=(
142- timeout --kill-after=1m --signal=TERM ${BOOT_TIMEOUT:-60m}
143+ ${BOOT_TIMEOUT:+timeout --kill-after=1m --signal=TERM $BOOT_TIMEOUT}
144 xkvm -v -v "${netdev_args[@]}" ${overlay_drive_xkvm} "${pt[@]}" --
145 -echr 0x5
146 -m $mem ${serial_log:+-serial "file:$serial_log"} -nographic
147diff --git a/debian/tests/xkvm b/debian/tests/xkvm
148index 9015140..9513723 100755
149--- a/debian/tests/xkvm
150+++ b/debian/tests/xkvm
151@@ -292,7 +292,7 @@ get_bios_opts() {
152
153 if [ -n "$nvram" ]; then
154 if [ ! -f "$nvram" ]; then
155- cp "$nvram_src" "$nvram" ||
156+ cp "$nvram_src" "$nvram" ||
157 { error "failed copy $nvram_src to $nvram"; return 1; }
158 debug 1 "copied $nvram_src to $nvram"
159 fi
160@@ -664,7 +664,7 @@ main() {
161
162 local bus_devices
163 bus_devices=( -device "$virtio_scsi_bus,id=virtio-scsi-xkvm" )
164- cmd=( "${kvmcmd[@]}" "${archopts[@]}"
165+ cmd=( "${kvmcmd[@]}" "${archopts[@]}"
166 "${bios_opts[@]}"
167 "${bus_devices[@]}"
168 "${netargs[@]}"

Subscribers

People subscribed via source and target branches