Merge ~alfonsosanchezbeato/snappy-hwe-snaps/+git/network-manager:not-use-core-support into ~snappy-hwe-team/snappy-hwe-snaps/+git/network-manager:master

Proposed by Alfonso Sanchez-Beato
Status: Merged
Approved by: Simon Fels
Approved revision: 58e9965d9fe017fbe3979b9f521366c1e5a91c37
Merged at revision: ad1b4817f991279fc128f0fdc4febfe83ee41ab9
Proposed branch: ~alfonsosanchezbeato/snappy-hwe-snaps/+git/network-manager:not-use-core-support
Merge into: ~snappy-hwe-team/snappy-hwe-snaps/+git/network-manager:master
Diff against target: 120 lines (+19/-21)
6 files modified
bin/nmcli-internal (+7/-0)
docs/reference/snap-configuration/debug.md (+2/-2)
hooks/configure (+4/-3)
snapcraft.yaml (+2/-1)
tests/main/debug-config-option/task.yaml (+4/-14)
tests/main/installation/task.yaml (+0/-1)
Reviewer Review Type Date Requested Status
Simon Fels Approve
Roberto Mier Escandon (community) Approve
System Enablement Bot continuous-integration Approve
Review via email: mp+328576@code.launchpad.net

Description of the change

Change debug activation to avoid having to re-start NM.
To be able to re-start NM the core-support plug was being used, which
would have never been accepted in the Ubuntu store, as that interface
is meant to be used by the core snap only. Instead, avoid having to
restart by using nmcli to dynamically activate/deactivate debug option.
For this we need to use the nmcli plug instead for the configure hook.

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
Simon Fels (morphis) :
review: Needs Fixing
Revision history for this message
Roberto Mier Escandon (rmescandon) wrote :

I've tested this solution and works perfectly without needing to restart the service.
However it is needed to change the spread tests for not to search for log level in nm daemon start command.

Also, having the log level set in the bin/network-manager explicitly could be misleading, since if you set it to a different value of the one set at the beginning, the startup command in a ps would report other than the current. On the other hand, I'm not sure if it is possible setting the log level somehow at the beginning without having that as startup param...

review: Needs Fixing
Revision history for this message
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote :

PR re-pushed after addressing comments.

@rmescandon, yeah, having different command line logging option than the one is really being used can be misleading, agreed. Note however that the right way of getting the logging config is "nmcli g logging".

Anyway, this could be solved by changing NetworkManager.conf instead of using the command line argument. We can force a reload of that file without re-starting the daemon, which would solve that coherence problem. However, that should be something addressed in another PR.

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: Approve (continuous-integration)
Revision history for this message
Roberto Mier Escandon (rmescandon) wrote :

LGTM

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

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/bin/nmcli-internal b/bin/nmcli-internal
2new file mode 100755
3index 0000000..c4986b7
4--- /dev/null
5+++ b/bin/nmcli-internal
6@@ -0,0 +1,7 @@
7+#!/bin/sh
8+# This file is for internal use from hooks only
9+export PATH="$SNAP/usr/sbin:$SNAP/usr/bin:$SNAP/sbin:$SNAP/bin:$PATH"
10+export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$SNAP/usr/lib:$SNAP/usr/lib/x86_64-linux-gnu"
11+export LD_LIBRARY_PATH="$SNAP/usr/lib:$SNAP/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH"
12+export LD_LIBRARY_PATH=$SNAP_LIBRARY_PATH:$LD_LIBRARY_PATH
13+exec "$SNAP/usr/bin/nmcli" "$@"
14diff --git a/docs/reference/snap-configuration/debug.md b/docs/reference/snap-configuration/debug.md
15index 321143a..e16d17c 100644
16--- a/docs/reference/snap-configuration/debug.md
17+++ b/docs/reference/snap-configuration/debug.md
18@@ -25,8 +25,8 @@ The option takes a boolean value. The meaning of the possible values are:
19 * **true:** Enable logging debug information
20 * **false (default):** Disable logging debug information
21
22-Changing the **debug** configuration option has an immediate
23-effect as the network-manager service restarts just after setting the new value.
24+Changing the **debug** configuration option has immediate effect and also
25+affects future executions of the NM daemon.
26
27 **Example:** Enable debug feature
28
29diff --git a/hooks/configure b/hooks/configure
30index 0b8dcab..fd39ee4 100755
31--- a/hooks/configure
32+++ b/hooks/configure
33@@ -81,18 +81,19 @@ switch_wifi_wake_on_wlan() {
34 switch_debug_enable() {
35 DEBUG_FILE=$SNAP_DATA/.debug_enabled
36 # $1 true/false for enabling/disabling debug log level in nm
37+ # We create/remove the file for future executions and also change
38+ # the logging level of the running daemon.
39 if [ "$1" = "true" ]; then
40 if [ ! -f "$DEBUG_FILE" ]; then
41 touch "$DEBUG_FILE"
42+ "$SNAP"/bin/nmcli-internal g log level DEBUG
43 fi
44 else
45 if [ -f "$DEBUG_FILE" ]; then
46 rm -f "$DEBUG_FILE"
47+ "$SNAP"/bin/nmcli-internal g log level INFO
48 fi
49 fi
50-
51- # restart service to apply debug flag enable/disable
52- systemctl restart snap.network-manager.networkmanager.service
53 }
54
55 value="`snapctl get wifi.powersave`"
56diff --git a/snapcraft.yaml b/snapcraft.yaml
57index c24ce46..2708a70 100644
58--- a/snapcraft.yaml
59+++ b/snapcraft.yaml
60@@ -16,7 +16,7 @@ slots:
61
62 hooks:
63 configure:
64- plugs: [core-support]
65+ plugs: [nmcli]
66
67 plugs:
68 nmcli: network-manager
69@@ -56,6 +56,7 @@ parts:
70 files:
71 bin/networkmanager: bin/networkmanager
72 bin/dhcp-lease-mover: bin/dhcp-lease-mover
73+ bin/nmcli-internal: bin/nmcli-internal
74 conf/NetworkManager.conf: etc/NetworkManager/NetworkManager.conf
75 data/copyright: usr/share/doc/network-manager/copyright
76 startup-hooks/99-wol-by-default.sh: startup-hooks/99-wol-by-default.sh
77diff --git a/tests/main/debug-config-option/task.yaml b/tests/main/debug-config-option/task.yaml
78index 435574f..cddab8c 100644
79--- a/tests/main/debug-config-option/task.yaml
80+++ b/tests/main/debug-config-option/task.yaml
81@@ -2,26 +2,16 @@ summary: Test network-manager snap debug configuration
82
83 execute: |
84 . $TESTSLIB/utilities.sh
85-
86+
87 test "$(snap get network-manager debug.enable)" = "false"
88- ! journalctl --no-pager -u snap.network-manager.networkmanager.service | grep -Pzq "<debug>"
89+ ! journalctl --no-pager -u snap.network-manager.networkmanager.service | MATCH "<debug>"
90
91 snap set network-manager debug.enable=true
92- wait_for_network_manager
93 test "$(snap get network-manager debug.enable)" = "true"
94 test -e /var/snap/network-manager/current/.debug_enabled
95- ps -ef | grep -Pzq "NetworkManager.*\-\-log\-level=DEBUG"
96- journalctl --no-pager -u snap.network-manager.networkmanager.service | grep -Pzq "<debug>"
97+ network-manager.nmcli g log | MATCH "^DEBUG"
98
99 snap set network-manager debug.enable=false
100- wait_for_network_manager
101-
102- # Clean up logs. From now on there shouldn't be any new debug log for network manager
103- journalctl --rotate
104- sleep .1
105- journalctl --vacuum-time=1ms
106- dmesg -c > /dev/null
107-
108 test "$(snap get network-manager debug.enable)" = "false"
109 test ! -e /var/snap/network-manager/current/.debug_enabled
110- ! journalctl --no-pager -u snap.network-manager.networkmanager.service | grep -Pzq "<debug>"
111+ network-manager.nmcli g log | MATCH "^INFO"
112diff --git a/tests/main/installation/task.yaml b/tests/main/installation/task.yaml
113index 2c7e605..bdaf48d 100644
114--- a/tests/main/installation/task.yaml
115+++ b/tests/main/installation/task.yaml
116@@ -15,4 +15,3 @@ execute: |
117 snap interfaces | grep -Pzq ":firewall-control +[a-z,-]*network-manager"
118 snap interfaces | grep -Pzq ":network-setup-observe +[a-z,-]*network-manager"
119 snap interfaces | grep -Pzq "network-manager:service +network-manager:nmcli"
120- snap interfaces | grep -Pzq ":core-support +[a-z,\-,:\,]*network-manager"

Subscribers

People subscribed via source and target branches