Merge ~kzapalowicz/snappy-hwe-snaps/+git/udisks2:feature/add-debug-config-option into ~snappy-hwe-team/snappy-hwe-snaps/+git/udisks2:master

Proposed by Konrad Zapałowicz
Status: Merged
Approved by: Simon Fels
Approved revision: 8118fb0ffbf930962c3b0572f63d98ab09add425
Merged at revision: 1024b0f6cb4d383a9456863d94c826e8c3e47feb
Proposed branch: ~kzapalowicz/snappy-hwe-snaps/+git/udisks2:feature/add-debug-config-option
Merge into: ~snappy-hwe-team/snappy-hwe-snaps/+git/udisks2:master
Diff against target: 228 lines (+130/-5)
8 files modified
docs/installation.md (+1/-0)
docs/metadata.yaml (+2/-0)
docs/reference/snap-configuration/debug.md (+50/-0)
docs/report-bug.md (+10/-2)
snap/hooks/configure (+24/-3)
tests/main/conf-debug/task.yaml (+30/-0)
tests/main/no-automount-for-boot-devices/task.yaml (+1/-0)
udisks2/udisks2.go (+12/-0)
Reviewer Review Type Date Requested Status
System Enablement Bot continuous-integration Approve
Simon Fels Approve
Review via email: mp+324922@code.launchpad.net

Description of the change

Add debug.enable configuration option

This option switches on/off the logging to the journal from
udisks2 package.

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

LGTM

review: Approve
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/docs/installation.md b/docs/installation.md
index 8abb851..d56d4b2 100644
--- a/docs/installation.md
+++ b/docs/installation.md
@@ -54,3 +54,4 @@ Now you have udisks2 successfully installed.
54## Next Steps54## Next Steps
5555
56 * [Enable Automount Support](reference/snap-configuration/automount.md)56 * [Enable Automount Support](reference/snap-configuration/automount.md)
57 * [Enable Debug Support](reference/snap-configuration/debug.md)
diff --git a/docs/metadata.yaml b/docs/metadata.yaml
index b5f1394..6b2d00d 100644
--- a/docs/metadata.yaml
+++ b/docs/metadata.yaml
@@ -15,6 +15,8 @@ navigation:
15 children:15 children:
16 - title: Automount Support16 - title: Automount Support
17 location: reference/snap-configuration/automount.md17 location: reference/snap-configuration/automount.md
18 - title: Debug Support
19 location: reference/snap-configuration/debug.md
18 - title: Supported Filesystems20 - title: Supported Filesystems
19 location: reference/supported-filesystems.md21 location: reference/supported-filesystems.md
20 - title: Available Commands22 - title: Available Commands
diff --git a/docs/reference/snap-configuration/debug.md b/docs/reference/snap-configuration/debug.md
21new file mode 10064423new file mode 100644
index 0000000..d6e4b2f
--- /dev/null
+++ b/docs/reference/snap-configuration/debug.md
@@ -0,0 +1,50 @@
1---
2title: Debug
3table_of_contents: True
4---
5
6# Debug
7
8Debug is a feature that controls the amount of logs produced by the udisks2
9snap. It is useful for collecting information required to either report a bug or
10investigate a udisks2 failure (if happens).
11
12The default is disabled by default and has to be explicitely turned on for
13usage.
14
15## Enable Debug
16
17The udisks2 snap provides a single configuration option which can be used to
18turn the debug feature either on or off:
19
20 * **debug.enable**
21
22The option takes a boolean value. The meaning of the possible values are:
23
24 * **true:** Enable logging debug information
25 * **false (default):** Disable logging debug information
26
27Chnaging the **debug.enable** configuration option does not have immediate
28effect and require a restart of the ciborium service.
29
30**Example:** Enable debug feature
31
32```
33$ snap set udisks2 debug.enable=true
34```
35
36<br/>
37**Example:** Disable debug feature.
38
39```
40$ snap set udisks2 debug.enable=false
41```
42
43## Viewing logs
44
45The debug information, when enabled, will be available in the journal and can
46be viewed with:
47
48```
49$ journalctl --no-pager -u snap.udisks2.ciborium
50```
diff --git a/docs/report-bug.md b/docs/report-bug.md
index 311a239..32f1a4c 100644
--- a/docs/report-bug.md
+++ b/docs/report-bug.md
@@ -7,9 +7,17 @@ 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:10When submitting a bug report, please first enable logging by setting the
11**debug.enabled** snao option to **true** and restarting the ciborium service.
1112
12 * */var/log/syslog*13```
14$ sudo snap set udisks2 debug.enable=true
15$ sudo systemctl restart snap.udisks2.ciborium.service
16```
17
18Now repeat the steps that lead to the failure and, please attach:
19
20 * $ journalctl --no-pager > system-log
1321
14And the output of the following two commands:22And the output of the following two commands:
1523
diff --git a/snap/hooks/configure b/snap/hooks/configure
index 12d498d..6d047f3 100755
--- a/snap/hooks/configure
+++ b/snap/hooks/configure
@@ -1,6 +1,7 @@
1#!/bin/sh1#!/bin/sh
22
3FLAG_FILE="$SNAP_COMMON/.automount_enabled"3# Option automount
4AUTOMOUNT_FILE="$SNAP_COMMON/.automount_enabled"
45
5value=$(snapctl get automount.enable)6value=$(snapctl get automount.enable)
6if [ -z "$value" ]; then7if [ -z "$value" ]; then
@@ -10,10 +11,30 @@ if [ -z "$value" ]; then
10fi11fi
1112
12if [ "$value" = "true" ]; then13if [ "$value" = "true" ]; then
13 touch "$FLAG_FILE"14 if [ ! -f "$AUTOMOUNT_FILE" ]; then
15 touch "$AUTOMOUNT_FILE"
16 fi
14elif [ "$value" = "false" ]; then17elif [ "$value" = "false" ]; then
15 rm -f "$FLAG_FILE"18 if [ -f "$AUTOMOUNT_FILE" ]; then
19 rm -f "$AUTOMOUNT_FILE"
20 fi
16fi21fi
1722
23# Option debug
24DEBUG_FILE="$SNAP_COMMON/.debug_enabled"
1825
26value=$(snapctl get debug.enable)
27if [ -z "$value" ]; then
28 snapctl set debug.enable="false"
29 "$value"="false"
30fi
1931
32if [ "$value" = "true" ]; then
33 if [ ! -f "$DEBUG_FILE" ]; then
34 touch "$DEBUG_FILE"
35 fi
36elif [ "$value" = "false" ]; then
37 if [ -f "$DEBUG_FILE" ]; then
38 rm -f "$DEBUG_FILE"
39 fi
40fi
diff --git a/tests/main/conf-debug/task.yaml b/tests/main/conf-debug/task.yaml
20new file mode 10064441new file mode 100644
index 0000000..b774b79
--- /dev/null
+++ b/tests/main/conf-debug/task.yaml
@@ -0,0 +1,30 @@
1summary: Test udisks2 snap debug configuration
2
3execute: |
4 . $TESTSLIB/utilities.sh
5 DATE=`date +"%F %T"`
6
7 # Service should be up and running
8 wait_for_systemd_service snap.udisks2.udisksd
9
10 # .. so should ciborium
11 wait_for_systemd_service snap.udisks2.ciborium
12
13 # Check that automount is disabled by default
14 test "$(snap get udisks2 debug.enable)" = false
15 test ! -e /var/snap/udisks2/common/.debug_enabled
16 journalctl --no-pager -u snap.udisks2.ciborium.service -b -S "$DATE" | grep -vPzq ".go"
17
18 # Check that enabling debug DTRT
19 snap set udisks2 debug.enable=true
20 test "$(snap get udisks2 debug.enable)" = true
21 DATE=`date +"%F %T"`
22 sudo systemctl restart snap.udisks2.ciborium.service
23 wait_for_systemd_service snap.udisks2.ciborium
24 test -e /var/snap/udisks2/common/.debug_enabled
25 journalctl --no-pager -u snap.udisks2.ciborium.service -b -S "$DATE" | grep -Pzq ".go"
26
27 # And for disabling
28 snap set udisks2 debug.enable=false
29 test "$(snap get udisks2 debug.enable)" = false
30 test ! -e /var/snap/udisks2/common/.debug_enabled
diff --git a/tests/main/no-automount-for-boot-devices/task.yaml b/tests/main/no-automount-for-boot-devices/task.yaml
index d4d86c6..1548217 100644
--- a/tests/main/no-automount-for-boot-devices/task.yaml
+++ b/tests/main/no-automount-for-boot-devices/task.yaml
@@ -42,6 +42,7 @@ execute: |
42 # wouldn't do otherwise if we keep it running (which we could as it42 # wouldn't do otherwise if we keep it running (which we could as it
43 # automatically detects if automount is enabled or not).43 # automatically detects if automount is enabled or not).
44 snap set udisks2 automount.enable=true44 snap set udisks2 automount.enable=true
45 snap set udisks2 debug.enable=true
45 systemctl restart snap.udisks2.ciborium46 systemctl restart snap.udisks2.ciborium
4647
47 wait_for_systemd_service snap.udisks2.ciborium48 wait_for_systemd_service snap.udisks2.ciborium
diff --git a/udisks2/udisks2.go b/udisks2/udisks2.go
index ec8217c..954dfa3 100644
--- a/udisks2/udisks2.go
+++ b/udisks2/udisks2.go
@@ -23,6 +23,7 @@ package udisks2
23import (23import (
24 "errors"24 "errors"
25 "fmt"25 "fmt"
26 "io/ioutil"
26 "os"27 "os"
27 "path"28 "path"
28 "path/filepath"29 "path/filepath"
@@ -52,8 +53,19 @@ const (
52 dbusAddedSignal = "InterfacesAdded"53 dbusAddedSignal = "InterfacesAdded"
53 dbusRemovedSignal = "InterfacesRemoved"54 dbusRemovedSignal = "InterfacesRemoved"
54 defaultMaximumWaitTime = 6455 defaultMaximumWaitTime = 64
56 debugEnabledFlagFile = ".debug_enabled"
55)57)
5658
59func init() {
60 snapCommon := os.Getenv("SNAP_COMMON")
61 path := filepath.Join(snapCommon, debugEnabledFlagFile)
62
63 // File does not exists which means debug is not enabled
64 if _, err := os.Stat(path); os.IsNotExist(err) {
65 log.SetOutput(ioutil.Discard)
66 }
67}
68
57type MountEvent struct {69type MountEvent struct {
58 Path dbus.ObjectPath70 Path dbus.ObjectPath
59 Mountpoint string71 Mountpoint string

Subscribers

People subscribed via source and target branches