Merge ~alfonsosanchezbeato/snappy-hwe-snaps/+git/modem-manager:add-debug-hook into ~snappy-hwe-team/snappy-hwe-snaps/+git/modem-manager:master

Proposed by Alfonso Sanchez-Beato
Status: Merged
Approved by: Roberto Mier Escandon
Approved revision: 3018d407a97c4e1202c86d2fc7160471343bbcab
Merged at revision: 6fc7f8627dfb9fdcf7e986e4bc1175510e0a317e
Proposed branch: ~alfonsosanchezbeato/snappy-hwe-snaps/+git/modem-manager:add-debug-hook
Merge into: ~snappy-hwe-team/snappy-hwe-snaps/+git/modem-manager:master
Diff against target: 271 lines (+165/-10)
10 files modified
.gitignore (+1/-0)
bin/mmcli-internal (+25/-0)
bin/modemmanager (+9/-3)
docs/installation.md (+1/-0)
docs/metadata.yaml (+4/-0)
docs/reference/snap-configuration/debug.md (+51/-0)
docs/report-bug.md (+5/-1)
hooks/configure (+26/-0)
snapcraft.yaml (+23/-6)
tests/main/debug-config-option/task.yaml (+20/-0)
Reviewer Review Type Date Requested Status
System Enablement Bot continuous-integration Approve
Roberto Mier Escandon (community) Approve
Simon Fels Approve
Review via email: mp+333120@code.launchpad.net

Description of the change

Add configure hook with debug option

To post a comment you must log in.
Revision history for this message
Simon Fels (morphis) wrote :

LGTM

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

a pair of comments

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

@Roberto, thanks for the comments. MP re-pushed.

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

lgtm

review: Approve
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: 3018d407a97c4e1202c86d2fc7160471343bbcab

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

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

PASSED: Successfully build documentation, rev: 5059c9be388f89bba3bf94afc859512fd2394711

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

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/.gitignore b/.gitignore
index 363fb44..d21a10c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,7 @@
1parts1parts
2prime2prime
3stage3stage
4snap
4.tests-extras5.tests-extras
5.spread-reuse*6.spread-reuse*
6*.snap7*.snap
diff --git a/bin/mmcli-internal b/bin/mmcli-internal
7new file mode 1007558new file mode 100755
index 0000000..cea01b0
--- /dev/null
+++ b/bin/mmcli-internal
@@ -0,0 +1,25 @@
1#!/bin/sh
2
3# This file is for internal use from hooks only
4
5case $SNAP_ARCH in
6amd64)
7 TRIPLET="x86_64-linux-gnu"
8 ;;
9armhf)
10 TRIPLET="arm-linux-gnueabihf"
11 ;;
12arm64)
13 TRIPLET="aarch64-linux-gnu"
14 ;;
15*)
16 TRIPLET="$SNAP_ARCH-linux-gnu"
17 ;;
18esac
19
20export PATH="$SNAP/usr/sbin:$SNAP/usr/bin:$SNAP/sbin:$SNAP/bin:$PATH"
21export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$SNAP/lib:$SNAP/usr/lib:$SNAP/lib/$TRIPLET:$SNAP/usr/lib/$TRIPLET"
22export LD_LIBRARY_PATH="$SNAP/lib:$SNAP/usr/lib:$SNAP/usr/lib/$TRIPLET:$LD_LIBRARY_PATH"
23export LD_LIBRARY_PATH=$SNAP_LIBRARY_PATH:$LD_LIBRARY_PATH
24
25exec "$SNAP"/usr/bin/mmcli "$@"
diff --git a/bin/modemmanager b/bin/modemmanager
index bafdfbc..6088439 100755
--- a/bin/modemmanager
+++ b/bin/modemmanager
@@ -1,11 +1,17 @@
1#!/bin/sh1#!/bin/sh
22
3set -e3set -ex
4set -x
54
6# Until we've reworked the patch which adds snappy support to5# Until we've reworked the patch which adds snappy support to
7# ModemManager we keep this as a rework to make the plugin6# ModemManager we keep this as a rework to make the plugin
8# loader happy and find the plugins at the right location7# loader happy and find the plugins at the right location
9export SNAP_APP_PATH=$SNAP8export SNAP_APP_PATH=$SNAP
109
11exec $SNAP/usr/sbin/ModemManager "$@"10LOG_LEVEL="INFO"
11DEBUG=""
12if [ -f "$SNAP_DATA"/.debug_enabled ]; then
13 LOG_LEVEL="DEBUG"
14 DEBUG="--debug"
15fi
16
17exec "$SNAP"/usr/sbin/ModemManager $DEBUG --log-level="$LOG_LEVEL" "$@"
diff --git a/docs/installation.md b/docs/installation.md
index 3d193dd..c74fda3 100644
--- a/docs/installation.md
+++ b/docs/installation.md
@@ -68,3 +68,4 @@ we use _sudo_ with them.
68 * [Gathering Modem Information](gathering-modem-information.md)68 * [Gathering Modem Information](gathering-modem-information.md)
69 * [Entering SIM Passwords](entering-sim-passwords.md)69 * [Entering SIM Passwords](entering-sim-passwords.md)
70 * [Configuring Cellular Connections](configuring-cellular-connections.md)70 * [Configuring Cellular Connections](configuring-cellular-connections.md)
71 * [Enable Debug Support](reference/snap-configuration/debug.md)
diff --git a/docs/metadata.yaml b/docs/metadata.yaml
index 7b9567d..dc2d961 100644
--- a/docs/metadata.yaml
+++ b/docs/metadata.yaml
@@ -17,6 +17,10 @@ navigation:
17 location: configuring-cellular-connections.md17 location: configuring-cellular-connections.md
18 - title: Reference18 - title: Reference
19 children:19 children:
20 - title: Snap Configuration
21 children:
22 - title: Debug
23 location: reference/snap-configuration/debug.md
20 - title: Available Commands24 - title: Available Commands
21 location: reference/available-commands.md25 location: reference/available-commands.md
22 - title: DBUS API26 - title: DBUS API
diff --git a/docs/reference/snap-configuration/debug.md b/docs/reference/snap-configuration/debug.md
23new file mode 10064427new file mode 100644
index 0000000..16b3bd8
--- /dev/null
+++ b/docs/reference/snap-configuration/debug.md
@@ -0,0 +1,51 @@
1---
2title: Debug
3table_of_contents: True
4---
5
6# Debug
7
8The debug configuration option controls the amount of logs produced by the
9modem-manager snap. It is useful for collecting information required to either
10report a bug or investigate a modem-manager failure.
11
12It is disabled by default and has to be explicitely turned on for usage.
13
14Note that the debug logs may contain sensitive information.
15
16## Enable Debug
17
18The modem-manager snap provides a single configuration option which can be used to
19turn the debug feature either on or off:
20
21 * **debug.enable**
22
23The option takes a boolean value. The meaning of the possible values are:
24
25 * **true:** Enable logging debug information
26 * **false (default):** Disable logging debug information
27
28Changing the **debug** configuration option has immediate effect and also
29affects future executions of the MM daemon.
30
31**Example:** Enable debug feature
32
33```
34$ snap set modem-manager debug.enable=true
35```
36
37<br/>
38**Example:** Disable debug feature.
39
40```
41$ snap set modem-manager debug.enable=false
42```
43
44## Viewing logs
45
46The debug information, when enabled, will be available in the journal and can
47be viewed with:
48
49```
50$ journalctl --no-pager -u snap.modem-manager.modemmanager.service
51```
diff --git a/docs/report-bug.md b/docs/report-bug.md
index 48f661a..b263433 100644
--- a/docs/report-bug.md
+++ b/docs/report-bug.md
@@ -7,7 +7,11 @@ table_of_contents: False
77
8Bugs can be reported [here](https://bugs.launchpad.net/snappy-hwe-snaps/+filebug).8Bugs can be reported [here](https://bugs.launchpad.net/snappy-hwe-snaps/+filebug).
99
10When submitting a bug report, please attach system log coming from the journal:10If the bug can be reproduced, [enabling the debug
11output](reference/snap-configuration/debug.md) before doing so is
12highly recommended.
13
14When submitting the bug report, please attach system log coming from the journal:
1115
12 * $ journalctl --no-pager > system-log16 * $ journalctl --no-pager > system-log
1317
diff --git a/hooks/configure b/hooks/configure
14new file mode 10075518new file mode 100755
index 0000000..c4fd410
--- /dev/null
+++ b/hooks/configure
@@ -0,0 +1,26 @@
1#!/bin/bash
2
3set -ex
4
5exec > "$SNAP_COMMON"/hook-log.txt 2>&1
6
7# $1 true/false for enabling/disabling debug log level in MM
8# We create/remove the file for future executions and also change
9# the logging level of the running daemon.
10switch_debug_enable() {
11 DEBUG_FILE=$SNAP_DATA/.debug_enabled
12 if [ "$1" = "true" ]; then
13 "$SNAP"/bin/mmcli-internal --set-logging=DEBUG
14 touch "$DEBUG_FILE"
15 else
16 "$SNAP"/bin/mmcli-internal --set-logging=INFO
17 rm -f "$DEBUG_FILE"
18 fi
19}
20
21value=$(snapctl get debug.enable)
22if [ -z "$value" ]; then
23 value="false"
24 snapctl set debug.enable="$value"
25fi
26switch_debug_enable "$value"
diff --git a/snapcraft.yaml b/snapcraft.yaml
index edd364d..77b3b8c 100644
--- a/snapcraft.yaml
+++ b/snapcraft.yaml
@@ -17,6 +17,10 @@ slots:
17plugs:17plugs:
18 mmcli: modem-manager18 mmcli: modem-manager
1919
20hooks:
21 configure:
22 plugs: [mmcli]
23
20apps:24apps:
21 mmcli:25 mmcli:
22 command: bin/mmcli26 command: bin/mmcli
@@ -28,12 +32,25 @@ apps:
28 slots: [service]32 slots: [service]
2933
30parts:34parts:
31 modemmanager-common:35 modemmanager-hooks:
32 plugin: copy36 plugin: dump
33 files:37 source: hooks
34 bin/modemmanager: bin/modemmanager38 organize:
35 bin/mmcli: bin/mmcli39 configure: meta/hooks/configure
36 data/copyright: usr/share/doc/modem-manager/copyright40
41 modemmanager-bin:
42 plugin: dump
43 source: bin
44 organize:
45 modemmanager: bin/modemmanager
46 mmcli: bin/mmcli
47 mmcli-internal: bin/mmcli-internal
48
49 modemmanager-data:
50 plugin: dump
51 source: data
52 organize:
53 copyright: usr/share/doc/modem-manager/copyright
3754
38 libmbim:55 libmbim:
39 plugin: autotools56 plugin: autotools
diff --git a/tests/main/debug-config-option/task.yaml b/tests/main/debug-config-option/task.yaml
40new file mode 10064457new file mode 100644
index 0000000..3d54557
--- /dev/null
+++ b/tests/main/debug-config-option/task.yaml
@@ -0,0 +1,20 @@
1summary: Test modem-manager snap debug configuration
2
3execute: |
4 . $TESTSLIB/utilities.sh
5
6 test "$(snap get modem-manager debug.enable)" = "false"
7
8 journalctl --rotate; journalctl --vacuum-time=1ms
9 snap set modem-manager debug.enable=true
10 test "$(snap get modem-manager debug.enable)" = "true"
11 test -e /var/snap/modem-manager/current/.debug_enabled
12 journalctl --no-pager -u snap.modem-manager.modemmanager.service |
13 MATCH "logging: level 'DEBUG'"
14
15 journalctl --rotate; journalctl --vacuum-time=1ms
16 snap set modem-manager debug.enable=false
17 test "$(snap get modem-manager debug.enable)" = "false"
18 test ! -e /var/snap/modem-manager/current/.debug_enabled
19 journalctl --no-pager -u snap.modem-manager.modemmanager.service |
20 MATCH "logging: level 'INFO'"

Subscribers

People subscribed via source and target branches