Merge ~kzapalowicz/snappy-hwe-snaps/+git/udisks2:feature/add-debug-config-option into ~snappy-hwe-team/snappy-hwe-snaps/+git/udisks2:master
- Git
- lp:~kzapalowicz/snappy-hwe-snaps/+git/udisks2
- feature/add-debug-config-option
- Merge into master
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) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
System Enablement Bot | continuous-integration | Approve | |
Simon Fels | Approve | ||
Review via email: mp+324922@code.launchpad.net |
Commit message
Description of the change
Add debug.enable configuration option
This option switches on/off the logging to the journal from
udisks2 package.
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:039e7b88fc5
https:/
Executed test runs:
FAILURE: https:/
None: https:/
FAILURE: https:/
None: https:/
Click here to trigger a rebuild:
https:/
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:e6f9ef1d479
https:/
Executed test runs:
FAILURE: https:/
None: https:/
None: https:/
Click here to trigger a rebuild:
https:/
Simon Fels (morphis) : | # |
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:e6f9ef1d479
https:/
Executed test runs:
SUCCESS: https:/
None: https:/
SUCCESS: https:/
None: https:/
Click here to trigger a rebuild:
https:/
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:bc122bf6840
https:/
Executed test runs:
FAILURE: https:/
None: https:/
FAILURE: https:/
None: https:/
Click here to trigger a rebuild:
https:/
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:2e95202a07a
https:/
Executed test runs:
SUCCESS: https:/
None: https:/
SUCCESS: https:/
None: https:/
Click here to trigger a rebuild:
https:/
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:d0a4b67d6a1
https:/
Executed test runs:
SUCCESS: https:/
None: https:/
SUCCESS: https:/
None: https:/
Click here to trigger a rebuild:
https:/
Simon Fels (morphis) : | # |
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:8118fb0ffbf
https:/
Executed test runs:
SUCCESS: https:/
None: https:/
SUCCESS: https:/
None: https:/
Click here to trigger a rebuild:
https:/
Preview Diff
1 | diff --git a/docs/installation.md b/docs/installation.md | |||
2 | index 8abb851..d56d4b2 100644 | |||
3 | --- a/docs/installation.md | |||
4 | +++ b/docs/installation.md | |||
5 | @@ -54,3 +54,4 @@ Now you have udisks2 successfully installed. | |||
6 | 54 | ## Next Steps | 54 | ## Next Steps |
7 | 55 | 55 | ||
8 | 56 | * [Enable Automount Support](reference/snap-configuration/automount.md) | 56 | * [Enable Automount Support](reference/snap-configuration/automount.md) |
9 | 57 | * [Enable Debug Support](reference/snap-configuration/debug.md) | ||
10 | diff --git a/docs/metadata.yaml b/docs/metadata.yaml | |||
11 | index b5f1394..6b2d00d 100644 | |||
12 | --- a/docs/metadata.yaml | |||
13 | +++ b/docs/metadata.yaml | |||
14 | @@ -15,6 +15,8 @@ navigation: | |||
15 | 15 | children: | 15 | children: |
16 | 16 | - title: Automount Support | 16 | - title: Automount Support |
17 | 17 | location: reference/snap-configuration/automount.md | 17 | location: reference/snap-configuration/automount.md |
18 | 18 | - title: Debug Support | ||
19 | 19 | location: reference/snap-configuration/debug.md | ||
20 | 18 | - title: Supported Filesystems | 20 | - title: Supported Filesystems |
21 | 19 | location: reference/supported-filesystems.md | 21 | location: reference/supported-filesystems.md |
22 | 20 | - title: Available Commands | 22 | - title: Available Commands |
23 | diff --git a/docs/reference/snap-configuration/debug.md b/docs/reference/snap-configuration/debug.md | |||
24 | 21 | new file mode 100644 | 23 | new file mode 100644 |
25 | index 0000000..d6e4b2f | |||
26 | --- /dev/null | |||
27 | +++ b/docs/reference/snap-configuration/debug.md | |||
28 | @@ -0,0 +1,50 @@ | |||
29 | 1 | --- | ||
30 | 2 | title: Debug | ||
31 | 3 | table_of_contents: True | ||
32 | 4 | --- | ||
33 | 5 | |||
34 | 6 | # Debug | ||
35 | 7 | |||
36 | 8 | Debug is a feature that controls the amount of logs produced by the udisks2 | ||
37 | 9 | snap. It is useful for collecting information required to either report a bug or | ||
38 | 10 | investigate a udisks2 failure (if happens). | ||
39 | 11 | |||
40 | 12 | The default is disabled by default and has to be explicitely turned on for | ||
41 | 13 | usage. | ||
42 | 14 | |||
43 | 15 | ## Enable Debug | ||
44 | 16 | |||
45 | 17 | The udisks2 snap provides a single configuration option which can be used to | ||
46 | 18 | turn the debug feature either on or off: | ||
47 | 19 | |||
48 | 20 | * **debug.enable** | ||
49 | 21 | |||
50 | 22 | The option takes a boolean value. The meaning of the possible values are: | ||
51 | 23 | |||
52 | 24 | * **true:** Enable logging debug information | ||
53 | 25 | * **false (default):** Disable logging debug information | ||
54 | 26 | |||
55 | 27 | Chnaging the **debug.enable** configuration option does not have immediate | ||
56 | 28 | effect and require a restart of the ciborium service. | ||
57 | 29 | |||
58 | 30 | **Example:** Enable debug feature | ||
59 | 31 | |||
60 | 32 | ``` | ||
61 | 33 | $ snap set udisks2 debug.enable=true | ||
62 | 34 | ``` | ||
63 | 35 | |||
64 | 36 | <br/> | ||
65 | 37 | **Example:** Disable debug feature. | ||
66 | 38 | |||
67 | 39 | ``` | ||
68 | 40 | $ snap set udisks2 debug.enable=false | ||
69 | 41 | ``` | ||
70 | 42 | |||
71 | 43 | ## Viewing logs | ||
72 | 44 | |||
73 | 45 | The debug information, when enabled, will be available in the journal and can | ||
74 | 46 | be viewed with: | ||
75 | 47 | |||
76 | 48 | ``` | ||
77 | 49 | $ journalctl --no-pager -u snap.udisks2.ciborium | ||
78 | 50 | ``` | ||
79 | diff --git a/docs/report-bug.md b/docs/report-bug.md | |||
80 | index 311a239..32f1a4c 100644 | |||
81 | --- a/docs/report-bug.md | |||
82 | +++ b/docs/report-bug.md | |||
83 | @@ -7,9 +7,17 @@ table_of_contents: False | |||
84 | 7 | 7 | ||
85 | 8 | Bugs can be reported [here](https://bugs.launchpad.net/snappy-hwe-snaps/+filebug). | 8 | Bugs can be reported [here](https://bugs.launchpad.net/snappy-hwe-snaps/+filebug). |
86 | 9 | 9 | ||
88 | 10 | When submitting a bug report, please attach: | 10 | When submitting a bug report, please first enable logging by setting the |
89 | 11 | **debug.enabled** snao option to **true** and restarting the ciborium service. | ||
90 | 11 | 12 | ||
92 | 12 | * */var/log/syslog* | 13 | ``` |
93 | 14 | $ sudo snap set udisks2 debug.enable=true | ||
94 | 15 | $ sudo systemctl restart snap.udisks2.ciborium.service | ||
95 | 16 | ``` | ||
96 | 17 | |||
97 | 18 | Now repeat the steps that lead to the failure and, please attach: | ||
98 | 19 | |||
99 | 20 | * $ journalctl --no-pager > system-log | ||
100 | 13 | 21 | ||
101 | 14 | And the output of the following two commands: | 22 | And the output of the following two commands: |
102 | 15 | 23 | ||
103 | diff --git a/snap/hooks/configure b/snap/hooks/configure | |||
104 | index 12d498d..6d047f3 100755 | |||
105 | --- a/snap/hooks/configure | |||
106 | +++ b/snap/hooks/configure | |||
107 | @@ -1,6 +1,7 @@ | |||
108 | 1 | #!/bin/sh | 1 | #!/bin/sh |
109 | 2 | 2 | ||
111 | 3 | FLAG_FILE="$SNAP_COMMON/.automount_enabled" | 3 | # Option automount |
112 | 4 | AUTOMOUNT_FILE="$SNAP_COMMON/.automount_enabled" | ||
113 | 4 | 5 | ||
114 | 5 | value=$(snapctl get automount.enable) | 6 | value=$(snapctl get automount.enable) |
115 | 6 | if [ -z "$value" ]; then | 7 | if [ -z "$value" ]; then |
116 | @@ -10,10 +11,30 @@ if [ -z "$value" ]; then | |||
117 | 10 | fi | 11 | fi |
118 | 11 | 12 | ||
119 | 12 | if [ "$value" = "true" ]; then | 13 | if [ "$value" = "true" ]; then |
121 | 13 | touch "$FLAG_FILE" | 14 | if [ ! -f "$AUTOMOUNT_FILE" ]; then |
122 | 15 | touch "$AUTOMOUNT_FILE" | ||
123 | 16 | fi | ||
124 | 14 | elif [ "$value" = "false" ]; then | 17 | elif [ "$value" = "false" ]; then |
126 | 15 | rm -f "$FLAG_FILE" | 18 | if [ -f "$AUTOMOUNT_FILE" ]; then |
127 | 19 | rm -f "$AUTOMOUNT_FILE" | ||
128 | 20 | fi | ||
129 | 16 | fi | 21 | fi |
130 | 17 | 22 | ||
131 | 23 | # Option debug | ||
132 | 24 | DEBUG_FILE="$SNAP_COMMON/.debug_enabled" | ||
133 | 18 | 25 | ||
134 | 26 | value=$(snapctl get debug.enable) | ||
135 | 27 | if [ -z "$value" ]; then | ||
136 | 28 | snapctl set debug.enable="false" | ||
137 | 29 | "$value"="false" | ||
138 | 30 | fi | ||
139 | 19 | 31 | ||
140 | 32 | if [ "$value" = "true" ]; then | ||
141 | 33 | if [ ! -f "$DEBUG_FILE" ]; then | ||
142 | 34 | touch "$DEBUG_FILE" | ||
143 | 35 | fi | ||
144 | 36 | elif [ "$value" = "false" ]; then | ||
145 | 37 | if [ -f "$DEBUG_FILE" ]; then | ||
146 | 38 | rm -f "$DEBUG_FILE" | ||
147 | 39 | fi | ||
148 | 40 | fi | ||
149 | diff --git a/tests/main/conf-debug/task.yaml b/tests/main/conf-debug/task.yaml | |||
150 | 20 | new file mode 100644 | 41 | new file mode 100644 |
151 | index 0000000..b774b79 | |||
152 | --- /dev/null | |||
153 | +++ b/tests/main/conf-debug/task.yaml | |||
154 | @@ -0,0 +1,30 @@ | |||
155 | 1 | summary: Test udisks2 snap debug configuration | ||
156 | 2 | |||
157 | 3 | execute: | | ||
158 | 4 | . $TESTSLIB/utilities.sh | ||
159 | 5 | DATE=`date +"%F %T"` | ||
160 | 6 | |||
161 | 7 | # Service should be up and running | ||
162 | 8 | wait_for_systemd_service snap.udisks2.udisksd | ||
163 | 9 | |||
164 | 10 | # .. so should ciborium | ||
165 | 11 | wait_for_systemd_service snap.udisks2.ciborium | ||
166 | 12 | |||
167 | 13 | # Check that automount is disabled by default | ||
168 | 14 | test "$(snap get udisks2 debug.enable)" = false | ||
169 | 15 | test ! -e /var/snap/udisks2/common/.debug_enabled | ||
170 | 16 | journalctl --no-pager -u snap.udisks2.ciborium.service -b -S "$DATE" | grep -vPzq ".go" | ||
171 | 17 | |||
172 | 18 | # Check that enabling debug DTRT | ||
173 | 19 | snap set udisks2 debug.enable=true | ||
174 | 20 | test "$(snap get udisks2 debug.enable)" = true | ||
175 | 21 | DATE=`date +"%F %T"` | ||
176 | 22 | sudo systemctl restart snap.udisks2.ciborium.service | ||
177 | 23 | wait_for_systemd_service snap.udisks2.ciborium | ||
178 | 24 | test -e /var/snap/udisks2/common/.debug_enabled | ||
179 | 25 | journalctl --no-pager -u snap.udisks2.ciborium.service -b -S "$DATE" | grep -Pzq ".go" | ||
180 | 26 | |||
181 | 27 | # And for disabling | ||
182 | 28 | snap set udisks2 debug.enable=false | ||
183 | 29 | test "$(snap get udisks2 debug.enable)" = false | ||
184 | 30 | test ! -e /var/snap/udisks2/common/.debug_enabled | ||
185 | diff --git a/tests/main/no-automount-for-boot-devices/task.yaml b/tests/main/no-automount-for-boot-devices/task.yaml | |||
186 | index d4d86c6..1548217 100644 | |||
187 | --- a/tests/main/no-automount-for-boot-devices/task.yaml | |||
188 | +++ b/tests/main/no-automount-for-boot-devices/task.yaml | |||
189 | @@ -42,6 +42,7 @@ execute: | | |||
190 | 42 | # wouldn't do otherwise if we keep it running (which we could as it | 42 | # wouldn't do otherwise if we keep it running (which we could as it |
191 | 43 | # automatically detects if automount is enabled or not). | 43 | # automatically detects if automount is enabled or not). |
192 | 44 | snap set udisks2 automount.enable=true | 44 | snap set udisks2 automount.enable=true |
193 | 45 | snap set udisks2 debug.enable=true | ||
194 | 45 | systemctl restart snap.udisks2.ciborium | 46 | systemctl restart snap.udisks2.ciborium |
195 | 46 | 47 | ||
196 | 47 | wait_for_systemd_service snap.udisks2.ciborium | 48 | wait_for_systemd_service snap.udisks2.ciborium |
197 | diff --git a/udisks2/udisks2.go b/udisks2/udisks2.go | |||
198 | index ec8217c..954dfa3 100644 | |||
199 | --- a/udisks2/udisks2.go | |||
200 | +++ b/udisks2/udisks2.go | |||
201 | @@ -23,6 +23,7 @@ package udisks2 | |||
202 | 23 | import ( | 23 | import ( |
203 | 24 | "errors" | 24 | "errors" |
204 | 25 | "fmt" | 25 | "fmt" |
205 | 26 | "io/ioutil" | ||
206 | 26 | "os" | 27 | "os" |
207 | 27 | "path" | 28 | "path" |
208 | 28 | "path/filepath" | 29 | "path/filepath" |
209 | @@ -52,8 +53,19 @@ const ( | |||
210 | 52 | dbusAddedSignal = "InterfacesAdded" | 53 | dbusAddedSignal = "InterfacesAdded" |
211 | 53 | dbusRemovedSignal = "InterfacesRemoved" | 54 | dbusRemovedSignal = "InterfacesRemoved" |
212 | 54 | defaultMaximumWaitTime = 64 | 55 | defaultMaximumWaitTime = 64 |
213 | 56 | debugEnabledFlagFile = ".debug_enabled" | ||
214 | 55 | ) | 57 | ) |
215 | 56 | 58 | ||
216 | 59 | func init() { | ||
217 | 60 | snapCommon := os.Getenv("SNAP_COMMON") | ||
218 | 61 | path := filepath.Join(snapCommon, debugEnabledFlagFile) | ||
219 | 62 | |||
220 | 63 | // File does not exists which means debug is not enabled | ||
221 | 64 | if _, err := os.Stat(path); os.IsNotExist(err) { | ||
222 | 65 | log.SetOutput(ioutil.Discard) | ||
223 | 66 | } | ||
224 | 67 | } | ||
225 | 68 | |||
226 | 57 | type MountEvent struct { | 69 | type MountEvent struct { |
227 | 58 | Path dbus.ObjectPath | 70 | Path dbus.ObjectPath |
228 | 59 | Mountpoint string | 71 | Mountpoint string |
FAILED: Continuous integration, rev:039e7b88fc5 d7380de7adecf30 b311be9b9923dc /jenkins. canonical. com/system- enablement/ job/generic- build-snap/ 1552/ /jenkins. canonical. com/system- enablement/ job/generic- build-snap- worker/ 1862/console /jenkins. canonical. com/system- enablement/ job/generic- update- snap-mp/ 1460/console /jenkins. canonical. com/system- enablement/ job/generic- test-snap/ 2244/console /jenkins. canonical. com/system- enablement/ job/generic- cleanup- snap/1441
https:/
Executed test runs:
FAILURE: https:/
None: https:/
FAILURE: https:/
SUCCESS: https:/
Click here to trigger a rebuild: /jenkins. canonical. com/system- enablement/ job/generic- build-snap/ 1552/rebuild
https:/