Merge ~morphis/snappy-hwe-snaps/+git/network-manager:feature/enable-ethernet-config-item into ~snappy-hwe-team/snappy-hwe-snaps/+git/network-manager:master

Proposed by Simon Fels
Status: Merged
Approved by: Roberto Mier Escandon
Approved revision: 742ee696683b570c6553cdab706dea4c068ff699
Merged at revision: e52b1341a936bb549c2e0edf3886225932c142ec
Proposed branch: ~morphis/snappy-hwe-snaps/+git/network-manager:feature/enable-ethernet-config-item
Merge into: ~snappy-hwe-team/snappy-hwe-snaps/+git/network-manager:master
Diff against target: 325 lines (+169/-16)
11 files modified
docs/metadata.yaml (+2/-0)
docs/reference/configuration/ethernet_support.md (+47/-0)
docs/reference/snap-configuration/wowlan.md (+2/-0)
hooks/configure (+29/-0)
run-tests.sh (+7/-1)
snapcraft.yaml (+6/-4)
tests/lib/prepare.sh (+2/-1)
tests/lib/utilities.sh (+14/-4)
tests/main/aliases/task.yaml (+1/-6)
tests/main/conf-ethernet-support/task.yaml (+55/-0)
tests/main/set-hostname/task.yaml (+4/-0)
Reviewer Review Type Date Requested Status
Simon Fels Approve
System Enablement Bot continuous-integration Approve
Roberto Mier Escandon (community) Approve
Konrad Zapałowicz (community) code Needs Fixing
Review via email: mp+316935@code.launchpad.net

Description of the change

Add configuration item to allow users to enable ethernet support

The current implementation requires to reboot the device two times which is not really what we want but not possible to change until we have a network-setup-control interface which would allow our hook to change the netplan configuration directly.

To post a comment you must log in.
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Konrad Zapałowicz (kzapalowicz) wrote :

Just a minor vocabulary change and it will be good.

review: Needs Fixing (code)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Simon Fels (morphis) wrote :

Ok, we need to held this back until the interface network-setup-control is merged upstream. Otherwise we don't get this past our CI. Moving the card on trello to blocked and marking this MP as disapproved.

review: Disapprove
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Konrad Zapałowicz (kzapalowicz) wrote :

Seems network-setup-control is now merged to snapd, can the landing/story be unblocked? Is it still valid?

Revision history for this message
Roberto Mier Escandon (rmescandon) wrote :

What I've tried in my rpi3:

Steps:
- install network-manager
- connect interfaces
- snap set network-manager ethernet.enable=true
- verified that
    * 'network-manager.nmcli d' shows eth0 unmanaged
    * 'snap get network-manager ethernet.enable' returns true
    * content in /etc/netplan at this moment is 00-snapd-config.yaml
- reboot
- 'network-manager.nmcli d' shows eth0 connected with connection name as 'netplan-eth0'
- content in /etc/netplan is 00-default-nm-renderer.yaml and 00-snapd-config.yaml

I thinks this is the expected behaviour. My only concern is about leaving other yaml files in /etc/netplan not related with nm. Is that intended?

in this url [1] literally says:

"If you don't want any netplan configuration files being used by NetworkManager, delete all files from /etc/netplan. Any remaining files will be considered by NetworkManager and used to configure Ethernet and wireless network devices"

[1] https://docs.ubuntu.com/core/en/stacks/network/network-manager/docs/enable-ethernet-support

review: Needs Information
Revision history for this message
Roberto Mier Escandon (rmescandon) wrote :

There is one spread test that is always failing, though I'm not sure it is related with this MP.
That one is tests/main/wifi-no-wowlan-iface-removed

https://pastebin.canonical.com/192985/

review: Needs Fixing
Revision history for this message
Roberto Mier Escandon (rmescandon) wrote :

Tested locally merging trunk, resolving conflicts and fixing failures in spread tests specific for this change. All works fine.
Please apply this patch https://pastebin.canonical.com/194037/ to be approved

review: Needs Fixing
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Roberto Mier Escandon (rmescandon) wrote :

Please, apply this patch to solve spread failures https://pastebin.canonical.com/196067/

Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :

PASSED: Successfully build documentation, rev: 6aa9fd07140d511a21a7cc422440a663c2160e8a

Generated documentation is available at https://jenkins.canonical.com/system-enablement/job/snappy-hwe-snaps-snap-docs/776/

Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :

PASSED: Successfully build documentation, rev: 6aa9fd07140d511a21a7cc422440a663c2160e8a

Generated documentation is available at https://jenkins.canonical.com/system-enablement/job/snappy-hwe-snaps-snap-docs/777/

Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :

PASSED: Successfully build documentation, rev: 6aa9fd07140d511a21a7cc422440a663c2160e8a

Generated documentation is available at https://jenkins.canonical.com/system-enablement/job/snappy-hwe-snaps-snap-docs/781/

Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :

PASSED: Successfully build documentation, rev: 6aa9fd07140d511a21a7cc422440a663c2160e8a

Generated documentation is available at https://jenkins.canonical.com/system-enablement/job/snappy-hwe-snaps-snap-docs/784/

Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Roberto Mier Escandon (rmescandon) :
review: Approve
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :

PASSED: Successfully build documentation, rev: 0a5242cc51050c15fb754dcaf9ebd6b00d93d73e

Generated documentation is available at https://jenkins.canonical.com/system-enablement/job/snappy-hwe-snaps-snap-docs/829/

Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :

PASSED: Successfully build documentation, rev: 0a5242cc51050c15fb754dcaf9ebd6b00d93d73e

Generated documentation is available at https://jenkins.canonical.com/system-enablement/job/snappy-hwe-snaps-snap-docs/830/

Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :

PASSED: Successfully build documentation, rev: 0a5242cc51050c15fb754dcaf9ebd6b00d93d73e

Generated documentation is available at https://jenkins.canonical.com/system-enablement/job/snappy-hwe-snaps-snap-docs/831/

Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :

PASSED: Successfully build documentation, rev: 0a5242cc51050c15fb754dcaf9ebd6b00d93d73e

Generated documentation is available at https://jenkins.canonical.com/system-enablement/job/snappy-hwe-snaps-snap-docs/828/

Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :

PASSED: Successfully build documentation, rev: 3b7d25311ff11621ea77499a5707f934f869a47d

Generated documentation is available at https://jenkins.canonical.com/system-enablement/job/snappy-hwe-snaps-snap-docs/865/

Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :

PASSED: Successfully build documentation, rev: b2844cf8d184d9d31b0f7002095fdc5c68aa5aff

Generated documentation is available at https://jenkins.canonical.com/system-enablement/job/snappy-hwe-snaps-snap-docs/866/

Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :

PASSED: Successfully build documentation, rev: bf5c94e7e97d913a195c7cb1eb7201695cfeb876

Generated documentation is available at https://jenkins.canonical.com/system-enablement/job/snappy-hwe-snaps-snap-docs/868/

Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :

PASSED: Successfully build documentation, rev: 2ba7ef87e2579e8fb55b535beadfc822b08ee127

Generated documentation is available at https://jenkins.canonical.com/system-enablement/job/snappy-hwe-snaps-snap-docs/869/

Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :

PASSED: Successfully build documentation, rev: 742ee696683b570c6553cdab706dea4c068ff699

Generated documentation is available at https://jenkins.canonical.com/system-enablement/job/snappy-hwe-snaps-snap-docs/870/

Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Simon Fels (morphis) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/docs/metadata.yaml b/docs/metadata.yaml
2index 4fabdd1..82bf35f 100644
3--- a/docs/metadata.yaml
4+++ b/docs/metadata.yaml
5@@ -27,6 +27,8 @@ navigation:
6 children:
7 - title: Snap Configuration
8 children:
9+ - title: Ethernet Support
10+ location: reference/configuration/ethernet_support.md
11 - title: Debug
12 location: reference/snap-configuration/debug.md
13 - title: Wake on WLAN
14diff --git a/docs/reference/configuration/ethernet_support.md b/docs/reference/configuration/ethernet_support.md
15new file mode 100644
16index 0000000..fbc5929
17--- /dev/null
18+++ b/docs/reference/configuration/ethernet_support.md
19@@ -0,0 +1,47 @@
20+---
21+title: Ethernet Support
22+table_of_contents: true
23+---
24+
25+# Ethernet Support
26+
27+*Available since:* 1.2.2-12
28+
29+The NetworkManager snap provides a configuration option to adjust
30+if it should manage ethernet network connections.
31+
32+By default the NetworkManager snap **does not** manage ethernet network
33+devices as it would conflict with the default network management in
34+Ubuntu Core which is handled by [netplan](https://launchpad.net/netplan) and
35+[networkd](https://www.freedesktop.org/software/systemd/man/systemd-networkd.service.html).
36+
37+## Enable Ethernet Support
38+
39+To enable management of ethernet network devices the snap provides the
40+*ethernet.enable* configuration option.
41+
42+This configuration option accepts the following values
43+
44+ * **false (default):** Ethernet support is disabled. All network
45+ devices matching the expression 'en*' or 'eth*' will be ignored.
46+ * **true:** All ethernet devices available on the system will be
47+ managed by NetworkManager. networkd will not manage any of these
48+ anymore.
49+
50+Changing the *ethernet* configuration option needs a reboot of the
51+device it's running on.
52+
53+After the device has rebooted ethernet support is enabled NetworkManager will
54+take over management of all available ethernet network devices on the device.
55+
56+NetworkManager will reuse existing configurations files from */etc/netplan*
57+when ethernet support is enabled. Those will marked as immutable inside
58+NetworkManager and any changes need to be written manually into the relevant
59+files in */etc/netplan*.
60+
61+Example:
62+
63+```
64+ $ snap set network-manager ethernet.enable=true
65+ $ sudo reboot
66+```
67diff --git a/docs/reference/snap-configuration/wowlan.md b/docs/reference/snap-configuration/wowlan.md
68index d245062..2ae0791 100644
69--- a/docs/reference/snap-configuration/wowlan.md
70+++ b/docs/reference/snap-configuration/wowlan.md
71@@ -5,6 +5,8 @@ table_of_contents: True
72
73 # Wake on WLAN
74
75+*Available since:* 1.2.2-11
76+
77 Wake on WLAN (called WoWLAN in the following) is a feature which allows a device
78 to be woken up from standby power states to faciliate device management. It is based
79 on the well well-established standard for Wake on LAN. The functionality is not entirely
80diff --git a/hooks/configure b/hooks/configure
81index fd39ee4..386528a 100755
82--- a/hooks/configure
83+++ b/hooks/configure
84@@ -78,6 +78,23 @@ switch_wifi_wake_on_wlan() {
85 fi
86 }
87
88+switch_ethernet() {
89+ case "$1" in
90+ true)
91+ cat <<EOF > /etc/netplan/00-default-nm-renderer.yaml
92+network:
93+ renderer: NetworkManager
94+EOF
95+ ;;
96+ false)
97+ rm -f /etc/netplan/00-default-nm-renderer.yaml
98+ ;;
99+ *)
100+ echo "ERROR: Invalid value provided for ethernet"
101+ exit 1
102+ esac
103+}
104+
105 switch_debug_enable() {
106 DEBUG_FILE=$SNAP_DATA/.debug_enabled
107 # $1 true/false for enabling/disabling debug log level in nm
108@@ -115,6 +132,18 @@ else
109 switch_wifi_wake_on_wlan disabled ""
110 fi
111
112+value=`snapctl get ethernet.enable`
113+if [ -n "$value" ]; then
114+ switch_ethernet $value
115+else
116+ if [ -e /etc/netplan/00-default-nm-renderer.yaml ]; then
117+ value=true
118+ else
119+ value=false
120+ fi
121+ snapctl set ethernet.enable=$value
122+fi
123+
124 value=$(snapctl get debug.enable)
125 if [ -n "$value" ]; then
126 switch_debug_enable $value
127diff --git a/run-tests.sh b/run-tests.sh
128index 4f18f03..f069bfb 100755
129--- a/run-tests.sh
130+++ b/run-tests.sh
131@@ -66,5 +66,11 @@ else
132 clone_tests_extras
133 fi
134
135+# Any project-specific options for test-runner should be specified in
136+# .tests_config under EXTRA_ARGS
137+if [ -e ".tests_config" ]; then
138+ . .tests_config
139+fi
140+
141 echo "INFO: Executing tests runner"
142-cd $TESTS_EXTRAS_PATH && ./tests-runner.sh "$@"
143+cd $TESTS_EXTRAS_PATH && ./tests-runner.sh "$@" "$EXTRA_ARGS"
144diff --git a/snapcraft.yaml b/snapcraft.yaml
145index a7c2ea9..38a7895 100644
146--- a/snapcraft.yaml
147+++ b/snapcraft.yaml
148@@ -14,10 +14,6 @@ grade: stable
149 slots:
150 service: network-manager
151
152-hooks:
153- configure:
154- plugs: [nmcli]
155-
156 plugs:
157 nmcli: network-manager
158 wpa:
159@@ -25,6 +21,12 @@ plugs:
160 bus: system
161 name: fi.w1.wpa_supplicant1
162
163+hooks:
164+ configure:
165+ plugs:
166+ - nmcli
167+ - network-setup-control
168+
169 apps:
170 nmcli:
171 command: usr/bin/nmcli
172diff --git a/tests/lib/prepare.sh b/tests/lib/prepare.sh
173index ffdd477..33886eb 100644
174--- a/tests/lib/prepare.sh
175+++ b/tests/lib/prepare.sh
176@@ -28,8 +28,9 @@ rm -f /home/network-manager/nm-state.tar.gz
177
178 snap_install network-manager
179 # FIXME: Until the store snap-declaration is updated we need to connect
180-# this plug manually.
181+# this plugs manually.
182 snap connect network-manager:firewall-control
183+snap connect network-manager:network-setup-control
184
185 # Snapshot of the current snapd state for a later restore
186 systemctl stop snapd.service snapd.socket
187diff --git a/tests/lib/utilities.sh b/tests/lib/utilities.sh
188index b82593a..10a955a 100644
189--- a/tests/lib/utilities.sh
190+++ b/tests/lib/utilities.sh
191@@ -20,10 +20,15 @@ switch_netplan_to_network_manager() {
192 return 0
193 fi
194
195- cat <<-EOF > /etc/netplan/00-default-nm-renderer.yaml
196+ # set ethernet.enable in case the snap is already installed
197+ if snap list | grep -q network-manager ; then
198+ snap set network-manager ethernet.enable=true
199+ else
200+ cat << EOF > /etc/netplan/00-default-nm-renderer.yaml
201 network:
202 renderer: NetworkManager
203- EOF
204+EOF
205+ fi
206 }
207
208 switch_netplan_to_networkd() {
209@@ -31,7 +36,12 @@ switch_netplan_to_networkd() {
210 return 0
211 fi
212
213- rm /etc/netplan/00-default-nm-renderer.yaml
214+ # unset ethernet.enable in case the snap is already installed
215+ if snap list | grep -q network-manager ; then
216+ snap set network-manager ethernet.enable=false
217+ else
218+ rm /etc/netplan/00-default-nm-renderer.yaml
219+ fi
220 }
221
222 # waits for a service to be active. Besides that, waits enough
223@@ -75,7 +85,7 @@ wait_for_network_manager() {
224 }
225
226 stop_after_first_reboot() {
227- if [ $SPREAD_REBOOT -eq 1 ] ; then
228+ if [ $SPREAD_REBOOT -gt 0 ] ; then
229 exit 0
230 fi
231 }
232diff --git a/tests/main/aliases/task.yaml b/tests/main/aliases/task.yaml
233index f3fd040..1ae0e05 100644
234--- a/tests/main/aliases/task.yaml
235+++ b/tests/main/aliases/task.yaml
236@@ -5,12 +5,7 @@ execute: |
237 # have them approved from the store in our snap-declaration assertion.
238 test ! -e /snap/bin/nmcli
239
240- snapd_version=$(snap version | awk '/^snapd / {print $2; exit}')
241- target=$SNAP_NAME.nmcli
242- if dpkg --compare-versions $snapd_version lt 2.25 ; then
243- target=$SNAP_NAME
244- fi
245- snap alias $target nmcli
246+ snap alias $SNAP_NAME.nmcli nmcli
247
248 test -e /snap/bin/nmcli
249
250diff --git a/tests/main/conf-ethernet-support/task.yaml b/tests/main/conf-ethernet-support/task.yaml
251new file mode 100644
252index 0000000..5816a2b
253--- /dev/null
254+++ b/tests/main/conf-ethernet-support/task.yaml
255@@ -0,0 +1,55 @@
256+summary: Verify ethernet support can be enabled via configuration option
257+
258+execute: |
259+ . $TESTSLIB/utilities.sh
260+
261+ # We need to have the network-setup-control interface available as
262+ # otherwise the hook can't do its job
263+ snap interfaces | grep network-setup-control
264+
265+ case "$SPREAD_REBOOT" in
266+ 0)
267+ # We should now have the interface available
268+ snap interfaces | grep network-setup-control
269+
270+ # In the default setup NetworkManager doesn't take over ethernet
271+ wait_for_network_manager
272+
273+ /snap/bin/network-manager.nmcli d | grep 'eth0.*unmanaged'
274+
275+ # By default ethernet is disabled
276+ test "`snap get network-manager ethernet.enable`" = "false"
277+
278+ # Enable ethernet support requires us to reboot two times to get
279+ # things into a right state.
280+ snap set network-manager ethernet.enable=true
281+ test "`snap get network-manager ethernet.enable`" = "true"
282+
283+ REBOOT
284+ ;;
285+ 1)
286+ wait_for_network_manager
287+
288+ # NetworkManager now controls eth0 and networkd does not
289+ /snap/bin/network-manager.nmcli d | grep 'eth0.*connected'
290+ # ... and we're running with the netplan configuration
291+ /snap/bin/network-manager.nmcli d | grep 'netplan-eth0'
292+ networkctl status eth0 | grep 'State: routable'
293+
294+ # Now lets switch back to network by using the configuration
295+ # item again and doing another reboot.
296+ snap set network-manager ethernet.enable=false
297+ test "`snap get network-manager ethernet.enable`" = "false"
298+ REBOOT
299+ ;;
300+ 2)
301+ wait_for_network_manager
302+
303+ # networkd manages eth0 and NetworkManager does not
304+ networkctl | grep 'eth0.*routable'
305+ /snap/bin/network-manager.nmcli d | grep 'eth0.*unmanaged'
306+ ;;
307+ *)
308+ exit 1
309+ ;;
310+ esac
311diff --git a/tests/main/set-hostname/task.yaml b/tests/main/set-hostname/task.yaml
312index ddcabd9..69b27c8 100644
313--- a/tests/main/set-hostname/task.yaml
314+++ b/tests/main/set-hostname/task.yaml
315@@ -1,6 +1,10 @@
316 summary: Verify we can modify the hostname of the system
317
318 execute: |
319+ . "$TESTSLIB/utilities.sh"
320+
321+ wait_for_network_manager
322+
323 # Print out current hostname for nm and hostnamed to have a reference
324 # for debugging later.
325 /snap/bin/network-manager.nmcli general hostname

Subscribers

People subscribed via source and target branches