Merge ~smoser/ubuntu/+source/open-iscsi:fix/1802354-disco-iscsid-run-if-rootfs into ubuntu/+source/open-iscsi:ubuntu/devel

Proposed by Scott Moser
Status: Merged
Merged at revision: e43f63f2fd4b0a3d7c430fb09f2ca725c73d09f4
Proposed branch: ~smoser/ubuntu/+source/open-iscsi:fix/1802354-disco-iscsid-run-if-rootfs
Merge into: ubuntu/+source/open-iscsi:ubuntu/devel
Diff against target: 174 lines (+62/-4)
6 files modified
debian/changelog (+11/-0)
debian/iscsi-disk.rules (+3/-0)
debian/open-iscsi.install (+1/-0)
debian/tests/patch-image (+6/-0)
debian/tests/test-open-iscsi.py (+39/-4)
debian/tests/tgt-boot-test (+2/-0)
Reviewer Review Type Date Requested Status
Steve Langasek (community) Approve
Christian Ehrhardt  Pending
Dimitri John Ledkov Pending
git-ubuntu developers Pending
Review via email: mp+358737@code.launchpad.net

Commit message

Add udev rule for iscsi disks to ensure iscsid is running.

This change makes open-iscsi install a udev rule that includes
systemd_wants [1] to ensure that if there are iscsi disks attached
then iscsid.service will be running.

 [1] https://www.freedesktop.org/software/systemd/man/systemd.device.html

This fixes a regression caused when iscsid was changed to be socket
activated under bug 1755858. The problematic case was when the
only iscsi mount was performed by the initramfs.

LP: #1802354

Description of the change

see commit message

To post a comment you must log in.
Revision history for this message
Steve Langasek (vorlon) wrote :

LGTM.

review: Approve

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 e242fa5..135aac7 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,14 @@
6+open-iscsi (2.0.874-5ubuntu10) UNRELEASED; urgency=medium
7+
8+ * d/iscsi-disk.rules, d/tests: Add a udev rule so that iscsid.service
9+ will be run when udev disks are attached. (LP: #1802354)
10+ * debian/tests: improve tgt boot test
11+ - disable snapd and snap.seeded services to avoid unnecessary
12+ resource consumption during tests.
13+ - save artifacts from the test run.
14+
15+ -- Scott Moser <smoser@ubuntu.com> Tue, 13 Nov 2018 20:00:31 -0500
16+
17 open-iscsi (2.0.874-5ubuntu9) cosmic; urgency=medium
18
19 * d/net-interface-handler: replace 'domainsearch' with the correct
20diff --git a/debian/iscsi-disk.rules b/debian/iscsi-disk.rules
21new file mode 100644
22index 0000000..e0ef836
23--- /dev/null
24+++ b/debian/iscsi-disk.rules
25@@ -0,0 +1,3 @@
26+# When iscsi disks are present, iscsid.service should be running. LP: #1802354
27+# ID_PATH looks like ip-<ipv4-dotted-quad>:<port>-iscsi-<target>-lun-<lun>
28+SUBSYSTEM=="block", ACTION=="add", ENV{ID_PATH}=="*-iscsi-*", ENV{SYSTEMD_WANTS}="iscsid.service"
29diff --git a/debian/open-iscsi.install b/debian/open-iscsi.install
30index 1e09755..14cddd4 100755
31--- a/debian/open-iscsi.install
32+++ b/debian/open-iscsi.install
33@@ -15,4 +15,5 @@ debian/extra/activate-storage.sh /lib/open-iscsi
34 debian/open-iscsi.kmod => /lib/modules-load.d/open-iscsi.conf
35 debian/net-interface-handler /lib/open-iscsi
36 debian/iscsi-network-interface.rules => /lib/udev/rules.d/70-iscsi-network-interface.rules
37+debian/iscsi-disk.rules => /lib/udev/rules.d/70-iscsi-disk.rules
38 debian/open-iscsi.finalrd /usr/share/finalrd
39diff --git a/debian/tests/patch-image b/debian/tests/patch-image
40index 95cacc5..0688912 100755
41--- a/debian/tests/patch-image
42+++ b/debian/tests/patch-image
43@@ -251,6 +251,10 @@ main() {
44 [ -f "${pkg}" ] && debs[${#debs[@]}]="$pkg" ||
45 packages[${packages[@]}]="$pkg"
46 done
47+ if [ "${#packages[@]}" -eq 0 -a "${#debs[@]}" -eq 0 ]; then
48+ packages=( open-iscsi )
49+ debug 1 "no packages or debs given, using packages=${packages[*]}"
50+ fi
51 fi
52
53 # if open-iscsi is not in the packages list above, we handle it specifically
54@@ -309,6 +313,7 @@ main() {
55 mount -o bind /dev "$target"/dev || :
56 mount -o bind /dev/pts "$target"/dev/pts || :
57
58+ debug 1 "${#packages[@]} packages: ${packages[*]}"
59 if [ "${#packages[@]}" != "0" ]; then
60 DEBIAN_FRONTEND=noninteractive chroot "$target" sh -exc '
61 mypkg=$1
62@@ -322,6 +327,7 @@ main() {
63 fail "failed to install ${packages[*]} in $target"
64 fi
65
66+ debug 1 "${#debs[@]} debs: ${debs[*]}"
67 if [ "${#debs[@]}" != "0" ]; then
68 local tmpd=""
69 tmpd=$(mktemp -d "${target}/tmp/${0##*/}.XXXXXX")
70diff --git a/debian/tests/test-open-iscsi.py b/debian/tests/test-open-iscsi.py
71index 27a5e0b..deff8fc 100644
72--- a/debian/tests/test-open-iscsi.py
73+++ b/debian/tests/test-open-iscsi.py
74@@ -75,6 +75,13 @@ bukket:
75 exit
76 fi
77 systemd-resolve --status --no-pager
78+
79+ - &get_iscsid_status |
80+ [ "${1:--}" != "-" ] && exec >"$1" 2>&1
81+ udevadm settle
82+ systemctl is-active iscsid.service
83+ systemctl status --no-pager --full iscsid.service
84+
85 - &add_and_remove_tuntap |
86 #!/bin/sh
87 # LP: #1785108 would break dns when any device was removed.
88@@ -86,11 +93,20 @@ bukket:
89 ip tuntap del mode tap $tapdev
90 udevadm settle
91
92+ - &collect_debug_mounts |
93+ [ "${1:--}" != "-" ] && exec >"$1" 2>&1
94+ [ -x /usr/local/bin/debug-mounts ] || exit 0
95+ /usr/local/bin/debug-mounts
96+
97 runcmd:
98 - [ sh, -c, *add_and_remove_tuntap ]
99 - [ mkdir, -p, /output ]
100- - [ cp, /etc/resolv.conf, /output]
101- - [ sh, -c, *get_resolved_status, --, /output/systemd-resolve-status.txt]
102+ - [ cp, /etc/resolv.conf, /output ]
103+ - [ sh, -c, *get_resolved_status, --, /output/systemd-resolve-status.txt ]
104+ - [ sh, -c, *get_iscsid_status, --, /output/iscsid-status.txt ]
105+ - [ sh, -c, *collect_debug_mounts, --, /output/debug-mounts.txt ]
106+ - [ sh, -c, 'journalctl --boot=0 --output=short-monotonic > /output/journal.txt' ]
107+ - [ sh, -c, 'dpkg-query --show > /output/manifest.txt' ]
108 - [ tar, -C, /output, -cf, /dev/disk/by-id/virtio-output-disk, . ]
109
110 power_state:
111@@ -243,7 +259,7 @@ class CloudImageTest(testlib.TestlibCase, PrivateOpenIscsiTest):
112 path = os.path.join(self.tmpdir, 'output-disk.img')
113 subprocess.check_call([
114 'qemu-img', 'create', '-f', 'raw', path, '10M'])
115- return path
116+ return path
117
118 def extract_files(self, path):
119 # get contents in a dictionary of tarball at 'path'
120@@ -273,6 +289,10 @@ class CloudImageTest(testlib.TestlibCase, PrivateOpenIscsiTest):
121 netdev = ("--netdev=user,net={network},host={host},dns={dns},"
122 "dnssearch={dnssearch}").format(**info)
123
124+ artifacts_dir = os.environ.get('AUTOPKGTEST_ARTIFACTS')
125+ if artifacts_dir and not os.path.isdir(artifacts_dir):
126+ os.makedirs(artifacts_dir)
127+
128 output_disk = self.create_output_disk()
129 cmd = [
130 tgt_boot_cmd, '-v', netdev,
131@@ -286,8 +306,14 @@ class CloudImageTest(testlib.TestlibCase, PrivateOpenIscsiTest):
132 env['BOOT_TIMEOUT'] = env.get('BOOT_TIMEOUT', '60m')
133 subprocess.check_call(cmd, env=env)
134
135+ if artifacts_dir:
136+ tgz = os.path.join(artifacts_dir, "tgt-collected.tar.gz")
137+ shutil.copy(output_disk, tgz)
138+ print("Copied output_disk '%s' to artifacts dir '%s'" %
139+ (output_disk, tgz))
140+
141 files = self.extract_files(output_disk)
142- print("files: %s" % files)
143+ print("collected files: %s" % files.keys())
144 resolvconf = files.get('resolv.conf', "NO_RESOLVCONF_FOUND")
145 resolve_status = files.get('systemd-resolve-status.txt')
146
147@@ -322,6 +348,15 @@ class CloudImageTest(testlib.TestlibCase, PrivateOpenIscsiTest):
148 msg=("search addr '%s' not in systemd-resolve status: %s" %
149 (dns_search, resolve_status)))
150
151+ # iscsid-status.txt has first line output from
152+ # 'systemctl is-active iscsid.service' and then 'systemcl status'
153+ iscsid_status = files.get('iscsid-status.txt')
154+ is_active = iscsid_status.splitlines()[0]
155+ self.assertEqual(
156+ "active", is_active,
157+ msg=("Expected iscsid.service active, found '%s'.\n%s\n" %
158+ (is_active, iscsid_status)))
159+
160
161 def get_image(top_d, release):
162 cmd = ['get-image', top_d, 'cloud-daily', release]
163diff --git a/debian/tests/tgt-boot-test b/debian/tests/tgt-boot-test
164index 6ed7a9b..65a38c7 100755
165--- a/debian/tests/tgt-boot-test
166+++ b/debian/tests/tgt-boot-test
167@@ -16,6 +16,8 @@ _DEF_CMDLINE_TMPL=(
168 net.ifnames=0 BOOTIF_DEFAULT=eth0
169 root={root} {overlay_drive}
170 console=ttyS0 {cmdline_ds}
171+ # LP: #1796137
172+ systemd.mask=snapd.seeded.service systemd.mask=snapd.service
173 )
174 DEF_CMDLINE_TMPL="${_DEF_CMDLINE_TMPL[*]}"
175

Subscribers

People subscribed via source and target branches