Merge ~morphis/snappy-hwe-snaps/+git/network-manager:netplan-support into ~snappy-hwe-team/snappy-hwe-snaps/+git/network-manager:master

Proposed by Simon Fels
Status: Merged
Approved by: Tony Espy
Approved revision: f3b5400dfb64fc6d89e517f3c61ea797abce2090
Merged at revision: 6abb25470df3a5f9278d631b775aa8f935013180
Proposed branch: ~morphis/snappy-hwe-snaps/+git/network-manager:netplan-support
Merge into: ~snappy-hwe-team/snappy-hwe-snaps/+git/network-manager:master
Diff against target: 92 lines (+30/-16)
3 files modified
bin/networkmanager (+28/-9)
conf/NetworkManager.conf (+0/-6)
snapcraft.yaml (+2/-1)
Reviewer Review Type Date Requested Status
Tony Espy Approve
System Enablement Bot continuous-integration Approve
Review via email: mp+306488@code.launchpad.net

Description of the change

Add support for netplan.

This adds support to take configuration files into account which are generated by netplan. There are a few things we have to change for that:

* Don't copy default configuration to $SNAP_DATA but rather check if one is available there and use that one conditionally
* Manage ethernet devices again but only if netplan renders NetworkManager connection files (checks if /etc/netplan/00-default-nm-renderer.yaml is present)
* Don't auto configure ethernet ports when netplan is used to avoid mismatches between console-conf UI and actual configuration

To post a comment you must log in.
Revision history for this message
Tony Espy (awe) wrote :

Looks good to me.

Please add a comment if/when you've tested on a real system, and I'll top-approve.

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

PASSED: Continuous integration, rev:3798516ad2ff97eb260191ed862b5d16d89f1935
https://jenkins.canonical.com/system-enablement/job/generic-build-snap/88/
Executed test runs:

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-enablement/job/generic-build-snap/88/rebuild

review: Approve (continuous-integration)
Revision history for this message
Simon Fels (morphis) wrote :

Things are looking good from first test results. Lets wait until the necessary changes for snapd/netplan have landed in a new edge OS snap so we can properly test everything.

Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Scott Sweeny (ssweeny) wrote :

I looked up the NetworkManager.conf manpage[1] and if I'm reading that right you should be able to specify a globbed set of interface names using the interface-name: syntax.

The section on no-auto-default directs you to the "Device List Format" section, which specifies that globbing is supported when you use interface-name.

[1] http://manpages.ubuntu.com/manpages/xenial/man5/NetworkManager.conf.5.html

Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Approve (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: Approve (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Tony Espy (awe) wrote :

Too questions based on updates to this merge proposal:

1. What does the functionality does the 'network-setup-observe' interface cover? Ideally this would be explained in the commit message, but as it's a one-liner, it's not clear.

2. Is commit 6730e78 still required? I thought with the addition of Scott's changes to write DHCP lease files to /run/NetworkManager/dhcp, and the associated change to probert, we no longer have to disable ethernet mgmt by NM.

review: Needs Information
Revision history for this message
Simon Fels (morphis) wrote :

1) The network-setup-observe interface allows read-only access to /etc/netplan and /etc/network. We need it actually to check if the file /etc/netplan/00-default-nm-renderer.yaml exists to switch into the correct mode we're running the snap in.

2) 6730e78 isn't about disabling ethernet configuration. It sets the no-auto-default configuration item to prevent automatic network configuration of ethernet ports as this now done via the netplan configuration which is created automatically on first boot and maintained further inside console-conf.

Revision history for this message
Tony Espy (awe) wrote :

Got it, thanks for the note re: the observer interface. That sounds correct, but again in the future we should try and add more context/detail to our commit messages.

Re: auto-config of ethernet devices, that makes sense, this was yet another missing detail in our plan ( at least missing in my mind ). I wasn't sure if netplan actually had support for generating NM configuration files, and thus thought we were relying on NM's autoconfig for them.

Revision history for this message
Tony Espy (awe) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/bin/networkmanager b/bin/networkmanager
2index fb800cf..b7821e3 100755
3--- a/bin/networkmanager
4+++ b/bin/networkmanager
5@@ -9,24 +9,43 @@ mkdir -p $SNAP_DATA/run
6 # Create DHCP lease directory
7 mkdir -p /run/NetworkManager/dhcp
8
9-# Copy config into place
10-#
11-# TODO: if/when snappy grows support for provisioning
12-# files into $SNAP_DATA, this code should be removed
13-# in favor of the new mechanism.
14-if [ ! -e $SNAP_DATA/NetworkManager.conf ]; then
15- cp $SNAP/etc/NetworkManager/NetworkManager.conf $SNAP_DATA
16+# Select which config we're going to use. We offer our users
17+# to provide their own configuration file in $SNAP_DATA but
18+# will fallback if no one exists to the default one we ship
19+# in $SNAP
20+NM_CONF="$SNAP/etc/NetworkManager/NetworkManager.conf"
21+if [ -e $SNAP_DATA/NetworkManager.conf ]; then
22+ NM_CONF="$SNAP_DATA/NetworkManager.conf"
23 fi
24
25 # A directory where users can place any additional configuration
26 # files for NetworkManager
27 mkdir -p $SNAP_DATA/conf.d
28
29+# If netplan is not configured to render by default to NetworkManager
30+# configuration files we disable management of any ethernet device
31+# as this will clash with any configuration netplan puts in place
32+# for networkd.
33+if [ ! -e "/etc/netplan/00-default-nm-renderer.yaml" ] ; then
34+ if [ ! -e "$SNAP_DATA/conf.d/disable-ethernet.conf" ] ; then
35+ echo "[keyfile]" > $SNAP_DATA/conf.d/disable-ethernet.conf
36+ echo "unmanaged-devices+=interface-name:eth*,interface-name:enx*" >> $SNAP_DATA/conf.d/disable-ethernet.conf
37+ fi
38+else
39+ if [ ! -e "$SNAP_DATA/conf.d/no-auto-default-ethernet.conf" ] ; then
40+ # If we're running as the only network management service
41+ # and are configured via netplan on first boot then we should
42+ # not try to auto configure ethernet ports as this is up to
43+ # netplan and will be the same for networkd.
44+ echo "[main]" > $SNAP_DATA/conf.d/no-auto-default-ethernet.conf
45+ echo "no-auto-default=interface-name:eth*,interface-name:enx*" >> $SNAP_DATA/conf.d/no-auto-default-ethernet.conf
46+ fi
47+fi
48+
49 export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$SNAP/usr/lib/NetworkManager"
50
51-# TODO drop DEBUG
52 $SNAP/usr/sbin/NetworkManager \
53 --config-dir=$SNAP_DATA/conf.d/ \
54- --config=$SNAP_DATA/NetworkManager.conf \
55+ --config=$NM_CONF \
56 --log-level=INFO \
57 --no-daemon
58diff --git a/conf/NetworkManager.conf b/conf/NetworkManager.conf
59index 43db0f9..1950212 100644
60--- a/conf/NetworkManager.conf
61+++ b/conf/NetworkManager.conf
62@@ -15,9 +15,3 @@ dhcp=internal
63
64 [ifupdown]
65 managed=false
66-
67-[keyfile]
68-# Ignore all ethernet devices for now until the core
69-# image has a config option to disable network support
70-# in cloud-init
71-unmanaged-devices+=interface-name:eth*,interface-name:enx*
72diff --git a/snapcraft.yaml b/snapcraft.yaml
73index 01b0652..2915ccd 100644
74--- a/snapcraft.yaml
75+++ b/snapcraft.yaml
76@@ -9,6 +9,7 @@ description: |
77 VPN serivces.
78 Please find the source code at https://code.launchpad.net/~snappy-hwe-team/snappy-hwe-snaps/+git/network-manager
79 confinement: strict
80+grade: stable
81
82 slots:
83 service: network-manager
84@@ -24,7 +25,7 @@ apps:
85 command: bin/networkmanager
86 daemon: simple
87 slots: [service]
88- plugs: [modem-manager, ppp]
89+ plugs: [modem-manager, ppp, network-setup-observe]
90
91 parts:
92 networkmanager-common:

Subscribers

People subscribed via source and target branches