Merge ~slyon/netplan/+git/ubuntu:slyon/ubuntu/focal into ~ubuntu-core-dev/netplan/+git/ubuntu:ubuntu/focal
- Git
- lp:~slyon/netplan/+git/ubuntu
- slyon/ubuntu/focal
- Merge into ubuntu/focal
Proposed by
Lukas Märdian
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 70622df41f1ab8852fba7372cd1982e12809e9c7 | ||||
Proposed branch: | ~slyon/netplan/+git/ubuntu:slyon/ubuntu/focal | ||||
Merge into: | ~ubuntu-core-dev/netplan/+git/ubuntu:ubuntu/focal | ||||
Diff against target: |
263 lines (+193/-45) 4 files modified
debian/changelog (+17/-0) debian/patches/0001-Fix-LP-1874377-Not-connect-to-WiFi-after-netplan-app.patch (+175/-0) debian/patches/series (+1/-1) dev/null (+0/-44) |
||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Łukasz Zemczak | Approve | ||
Review via email: mp+383325@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Łukasz Zemczak (sil2100) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | diff --git a/debian/changelog b/debian/changelog |
2 | index 2855a8e..5d3b7c6 100644 |
3 | --- a/debian/changelog |
4 | +++ b/debian/changelog |
5 | @@ -1,3 +1,20 @@ |
6 | +netplan.io (0.99-0ubuntu3~20.04.1) UNRELEASED; urgency=medium |
7 | + |
8 | + * Backport upstream bug fix for 0.99 to 20.04. (LP: #1871825) |
9 | + - Upstream provides an imporved fix, which handles additional edge cases |
10 | + for "Not connect to WiFi after 'netplan apply'" (LP: #1874377) |
11 | + |
12 | + -- Lukas Märdian <lukas.maerdian@canonical.com> Mon, 04 May 2020 11:37:05 +0200 |
13 | + |
14 | +netplan.io (0.99-0ubuntu3) groovy; urgency=medium |
15 | + |
16 | + * Drop d/p/0001-Not-connect-to-WiFi-after-netplan-apply.patch |
17 | + - Replaced by upstream fix |
18 | + * Add d/p/0001-Fix-LP-1874377-Not-connect-to-WiFi-after-netplan-app.patch: |
19 | + - Proper upstream fix, which handles edge cases better and contains tests |
20 | + |
21 | + -- Lukas Märdian <lukas.maerdian@canonical.com> Thu, 30 Apr 2020 12:51:36 +0200 |
22 | + |
23 | netplan.io (0.99-0ubuntu2) focal; urgency=medium |
24 | |
25 | [ Lukas Märdian ] |
26 | diff --git a/debian/patches/0001-Fix-LP-1874377-Not-connect-to-WiFi-after-netplan-app.patch b/debian/patches/0001-Fix-LP-1874377-Not-connect-to-WiFi-after-netplan-app.patch |
27 | new file mode 100644 |
28 | index 0000000..d401e97 |
29 | --- /dev/null |
30 | +++ b/debian/patches/0001-Fix-LP-1874377-Not-connect-to-WiFi-after-netplan-app.patch |
31 | @@ -0,0 +1,175 @@ |
32 | +From: Lukas Maerdian <lukas.maerdian@canonical.com> |
33 | +Date: Tue, 28 Apr 2020 14:35:36 +0200 |
34 | +Subject: Fix LP#1874377: Not connect to WiFi after 'netplan apply' (#133) |
35 | + |
36 | +* Fix LP#1874377: Not connect to WiFi after 'netplan apply' |
37 | + |
38 | +Seems like the 'netplan apply' command was not properly adopted in #109 when wired wpa_supplicant support was introduced. |
39 | + |
40 | +Fixes: https://bugs.launchpad.net/ubuntu/+source/netplan.io/+bug/1874377 |
41 | +--- |
42 | + netplan/cli/commands/apply.py | 10 ++++-- |
43 | + netplan/cli/utils.py | 7 +++++ |
44 | + src/networkd.c | 4 +++ |
45 | + tests/generator/test_wifis.py | 71 +++++++++++++++++++++++++++++++++++++++++++ |
46 | + tests/integration/base.py | 2 +- |
47 | + 5 files changed, 91 insertions(+), 3 deletions(-) |
48 | + |
49 | +diff --git a/netplan/cli/commands/apply.py b/netplan/cli/commands/apply.py |
50 | +index 0ec95f5..cf9f122 100644 |
51 | +--- a/netplan/cli/commands/apply.py |
52 | ++++ b/netplan/cli/commands/apply.py |
53 | +@@ -108,7 +108,13 @@ class NetplanApply(utils.NetplanCommand): |
54 | + # stop backends |
55 | + if restart_networkd: |
56 | + logging.debug('netplan generated networkd configuration changed, restarting networkd') |
57 | +- utils.systemctl_networkd('stop', sync=sync, extra_services=['netplan-wpa@*.service']) |
58 | ++ wpa_services = ['netplan-wpa-*.service'] |
59 | ++ # Historically (up to v0.98) we had netplan-wpa@*.service files, in case of an |
60 | ++ # upgraded system, we need to make sure to stop those. |
61 | ++ if utils.systemctl_is_active('netplan-wpa@*.service'): |
62 | ++ wpa_services.insert(0, 'netplan-wpa@*.service') |
63 | ++ utils.systemctl_networkd('stop', sync=sync, extra_services=wpa_services) |
64 | ++ |
65 | + else: |
66 | + logging.debug('no netplan generated networkd configuration exists') |
67 | + |
68 | +@@ -169,7 +175,7 @@ class NetplanApply(utils.NetplanCommand): |
69 | + |
70 | + # (re)start backends |
71 | + if restart_networkd: |
72 | +- netplan_wpa = [os.path.basename(f) for f in glob.glob('/run/systemd/system/*.wants/netplan-wpa@*.service')] |
73 | ++ netplan_wpa = [os.path.basename(f) for f in glob.glob('/run/systemd/system/*.wants/netplan-wpa-*.service')] |
74 | + utils.systemctl_networkd('start', sync=sync, extra_services=netplan_wpa) |
75 | + if restart_nm: |
76 | + utils.systemctl_network_manager('start', sync=sync) |
77 | +diff --git a/netplan/cli/utils.py b/netplan/cli/utils.py |
78 | +index 5f54b1a..c0eee03 100644 |
79 | +--- a/netplan/cli/utils.py |
80 | ++++ b/netplan/cli/utils.py |
81 | +@@ -86,6 +86,13 @@ def systemctl_networkd(action, sync=False, extra_services=[]): # pragma: nocove |
82 | + subprocess.check_call(command) |
83 | + |
84 | + |
85 | ++def systemctl_is_active(unit_pattern): # pragma: nocover (covered in autopkgtest) |
86 | ++ '''Return True if at least one matching unit is running''' |
87 | ++ if subprocess.call(['systemctl', '--quiet', 'is-active', unit_pattern]) == 0: |
88 | ++ return True |
89 | ++ return False |
90 | ++ |
91 | ++ |
92 | + def get_interface_driver_name(interface, only_down=False): # pragma: nocover (covered in autopkgtest) |
93 | + devdir = os.path.join('/sys/class/net', interface) |
94 | + if only_down: |
95 | +diff --git a/src/networkd.c b/src/networkd.c |
96 | +index e2bb111..6f6173a 100644 |
97 | +--- a/src/networkd.c |
98 | ++++ b/src/networkd.c |
99 | +@@ -990,8 +990,12 @@ cleanup_networkd_conf(const char* rootdir) |
100 | + { |
101 | + unlink_glob(rootdir, "/run/systemd/network/10-netplan-*"); |
102 | + unlink_glob(rootdir, "/run/netplan/wpa-*.conf"); |
103 | ++ unlink_glob(rootdir, "/run/systemd/system/systemd-networkd.service.wants/netplan-wpa-*.service"); |
104 | + unlink_glob(rootdir, "/run/systemd/system/netplan-wpa-*.service"); |
105 | + unlink_glob(rootdir, "/run/udev/rules.d/99-netplan-*"); |
106 | ++ /* Historically (up to v0.98) we had netplan-wpa@*.service files, in case of an |
107 | ++ * upgraded system, we need to make sure to clean those up. */ |
108 | ++ unlink_glob(rootdir, "/run/systemd/system/systemd-networkd.service.wants/netplan-wpa@*.service"); |
109 | + } |
110 | + |
111 | + /** |
112 | +diff --git a/tests/generator/test_wifis.py b/tests/generator/test_wifis.py |
113 | +index 8eb804e..d5b79cf 100644 |
114 | +--- a/tests/generator/test_wifis.py |
115 | ++++ b/tests/generator/test_wifis.py |
116 | +@@ -116,6 +116,77 @@ network={ |
117 | + self.assertTrue(os.path.islink(os.path.join( |
118 | + self.workdir.name, 'run/systemd/system/systemd-networkd.service.wants/netplan-wpa-wl0.service'))) |
119 | + |
120 | ++ def test_wifi_upgrade(self): |
121 | ++ # pretend an old 'netplan-wpa@*.service' link still exists on an upgraded system |
122 | ++ os.makedirs(os.path.join(self.workdir.name, 'lib/systemd/system')) |
123 | ++ os.makedirs(os.path.join(self.workdir.name, 'run/systemd/system/systemd-networkd.service.wants')) |
124 | ++ with open(os.path.join(self.workdir.name, 'lib/systemd/system/netplan-wpa@.service'), 'w') as out: |
125 | ++ out.write('''[Unit] |
126 | ++Description=WPA supplicant for netplan %I |
127 | ++DefaultDependencies=no |
128 | ++Requires=sys-subsystem-net-devices-%i.device |
129 | ++After=sys-subsystem-net-devices-%i.device |
130 | ++Before=network.target |
131 | ++Wants=network.target |
132 | ++ |
133 | ++[Service] |
134 | ++Type=simple |
135 | ++ExecStart=/sbin/wpa_supplicant -c /run/netplan/wpa-%I.conf -i%I''') |
136 | ++ os.symlink(os.path.join(self.workdir.name, 'lib/systemd/system/netplan-wpa@.service'), |
137 | ++ os.path.join(self.workdir.name, 'run/systemd/system/systemd-networkd.service.wants/netplan-wpa@wl0.service')) |
138 | ++ |
139 | ++ # run generate, which should cleanup the old files/symlinks |
140 | ++ self.generate('''network: |
141 | ++ version: 2 |
142 | ++ wifis: |
143 | ++ wl0: |
144 | ++ access-points: |
145 | ++ "Joe's Home": |
146 | ++ password: "s0s3kr1t" |
147 | ++ dhcp4: yes''') |
148 | ++ |
149 | ++ # verify new files/links exist, while old have been removed |
150 | ++ self.assertTrue(os.path.isfile(os.path.join( |
151 | ++ self.workdir.name, 'run/systemd/system/netplan-wpa-wl0.service'))) |
152 | ++ self.assertTrue(os.path.islink(os.path.join( |
153 | ++ self.workdir.name, 'run/systemd/system/systemd-networkd.service.wants/netplan-wpa-wl0.service'))) |
154 | ++ # old files/links |
155 | ++ self.assertTrue(os.path.isfile(os.path.join( |
156 | ++ self.workdir.name, 'lib/systemd/system/netplan-wpa@.service'))) |
157 | ++ self.assertFalse(os.path.islink(os.path.join( |
158 | ++ self.workdir.name, 'run/systemd/system/systemd-networkd.service.wants/netplan-wpa@wl0.service'))) |
159 | ++ |
160 | ++ # pretend another old systemd service file exists for wl1 |
161 | ++ os.symlink(os.path.join(self.workdir.name, 'lib/systemd/system/netplan-wpa@.service'), |
162 | ++ os.path.join(self.workdir.name, 'run/systemd/system/systemd-networkd.service.wants/netplan-wpa@wl1.service')) |
163 | ++ |
164 | ++ # run generate again, to verify the historical netplan-wpa@.service links and wl0 links are gone |
165 | ++ self.generate('''network: |
166 | ++ version: 2 |
167 | ++ wifis: |
168 | ++ wl1: |
169 | ++ access-points: |
170 | ++ "Other Home": |
171 | ++ password: "s0s3kr1t" |
172 | ++ dhcp4: yes''') |
173 | ++ |
174 | ++ # verify new files/links exist, while old have been removed |
175 | ++ self.assertTrue(os.path.isfile(os.path.join( |
176 | ++ self.workdir.name, 'run/systemd/system/netplan-wpa-wl1.service'))) |
177 | ++ self.assertTrue(os.path.islink(os.path.join( |
178 | ++ self.workdir.name, 'run/systemd/system/systemd-networkd.service.wants/netplan-wpa-wl1.service'))) |
179 | ++ # old files/links |
180 | ++ self.assertTrue(os.path.isfile(os.path.join( |
181 | ++ self.workdir.name, 'lib/systemd/system/netplan-wpa@.service'))) |
182 | ++ self.assertFalse(os.path.islink(os.path.join( |
183 | ++ self.workdir.name, 'run/systemd/system/systemd-networkd.service.wants/netplan-wpa@wl1.service'))) |
184 | ++ self.assertFalse(os.path.islink(os.path.join( |
185 | ++ self.workdir.name, 'run/systemd/system/systemd-networkd.service.wants/netplan-wpa@wl0.service'))) |
186 | ++ self.assertFalse(os.path.isfile(os.path.join( |
187 | ++ self.workdir.name, 'run/systemd/system/netplan-wpa-wl0.service'))) |
188 | ++ self.assertFalse(os.path.islink(os.path.join( |
189 | ++ self.workdir.name, 'run/systemd/system/systemd-networkd.service.wants/netplan-wpa-wl0.service'))) |
190 | ++ |
191 | + def test_wifi_route(self): |
192 | + self.generate('''network: |
193 | + version: 2 |
194 | +diff --git a/tests/integration/base.py b/tests/integration/base.py |
195 | +index ed7100e..16fd2ee 100644 |
196 | +--- a/tests/integration/base.py |
197 | ++++ b/tests/integration/base.py |
198 | +@@ -93,7 +93,7 @@ class IntegrationTestsBase(unittest.TestCase): |
199 | + pass |
200 | + |
201 | + def tearDown(self): |
202 | +- subprocess.call(['systemctl', 'stop', 'NetworkManager', 'systemd-networkd', 'netplan-wpa@*', |
203 | ++ subprocess.call(['systemctl', 'stop', 'NetworkManager', 'systemd-networkd', 'netplan-wpa-*', |
204 | + 'systemd-networkd.socket']) |
205 | + # NM has KillMode=process and leaks dhclient processes |
206 | + subprocess.call(['systemctl', 'kill', 'NetworkManager']) |
207 | diff --git a/debian/patches/0001-Not-connect-to-WiFi-after-netplan-apply.patch b/debian/patches/0001-Not-connect-to-WiFi-after-netplan-apply.patch |
208 | deleted file mode 100644 |
209 | index 384908d..0000000 |
210 | --- a/debian/patches/0001-Not-connect-to-WiFi-after-netplan-apply.patch |
211 | +++ /dev/null |
212 | @@ -1,44 +0,0 @@ |
213 | -From: Łukasz sil2100' Zemczak <lukasz.zemczak@canonical.com> |
214 | -Date: Thu, 23 Apr 2020 15:19:33 +0200 |
215 | -Subject: Not connect to WiFi after 'netplan apply' |
216 | - |
217 | ---- |
218 | - netplan/cli/commands/apply.py | 4 ++-- |
219 | - tests/integration/base.py | 2 +- |
220 | - 2 files changed, 3 insertions(+), 3 deletions(-) |
221 | - |
222 | -diff --git a/netplan/cli/commands/apply.py b/netplan/cli/commands/apply.py |
223 | -index 0ec95f5..8e9ef61 100644 |
224 | ---- a/netplan/cli/commands/apply.py |
225 | -+++ b/netplan/cli/commands/apply.py |
226 | -@@ -108,7 +108,7 @@ class NetplanApply(utils.NetplanCommand): |
227 | - # stop backends |
228 | - if restart_networkd: |
229 | - logging.debug('netplan generated networkd configuration changed, restarting networkd') |
230 | -- utils.systemctl_networkd('stop', sync=sync, extra_services=['netplan-wpa@*.service']) |
231 | -+ utils.systemctl_networkd('stop', sync=sync, extra_services=['netplan-wpa-*.service']) |
232 | - else: |
233 | - logging.debug('no netplan generated networkd configuration exists') |
234 | - |
235 | -@@ -169,7 +169,7 @@ class NetplanApply(utils.NetplanCommand): |
236 | - |
237 | - # (re)start backends |
238 | - if restart_networkd: |
239 | -- netplan_wpa = [os.path.basename(f) for f in glob.glob('/run/systemd/system/*.wants/netplan-wpa@*.service')] |
240 | -+ netplan_wpa = [os.path.basename(f) for f in glob.glob('/run/systemd/system/*.wants/netplan-wpa-*.service')] |
241 | - utils.systemctl_networkd('start', sync=sync, extra_services=netplan_wpa) |
242 | - if restart_nm: |
243 | - utils.systemctl_network_manager('start', sync=sync) |
244 | -diff --git a/tests/integration/base.py b/tests/integration/base.py |
245 | -index ed7100e..16fd2ee 100644 |
246 | ---- a/tests/integration/base.py |
247 | -+++ b/tests/integration/base.py |
248 | -@@ -93,7 +93,7 @@ class IntegrationTestsBase(unittest.TestCase): |
249 | - pass |
250 | - |
251 | - def tearDown(self): |
252 | -- subprocess.call(['systemctl', 'stop', 'NetworkManager', 'systemd-networkd', 'netplan-wpa@*', |
253 | -+ subprocess.call(['systemctl', 'stop', 'NetworkManager', 'systemd-networkd', 'netplan-wpa-*', |
254 | - 'systemd-networkd.socket']) |
255 | - # NM has KillMode=process and leaks dhclient processes |
256 | - subprocess.call(['systemctl', 'kill', 'NetworkManager']) |
257 | diff --git a/debian/patches/series b/debian/patches/series |
258 | index 6fe0295..817f04c 100644 |
259 | --- a/debian/patches/series |
260 | +++ b/debian/patches/series |
261 | @@ -1 +1 @@ |
262 | -0001-Not-connect-to-WiFi-after-netplan-apply.patch |
263 | +0001-Fix-LP-1874377-Not-connect-to-WiFi-after-netplan-app.patch |