Skip to content

snap: Allow enabling debug logging and dqlite tracing - #1570

Open
wak327 wants to merge 4 commits into
canonical:mainfrom
wak327:snap-daemon-debug
Open

wak327 wants to merge 4 commits into
canonical:mainfrom
wak327:snap-daemon-debug

Conversation

@wak327

@wak327 wak327 commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Fixes #806

The daemon already has a --debug flag, but the snap gives users no way to turn it on. This PR adds two snap config options, following how the LXD snap does it:

Changes:

  • snap/hooks/configure: snapd refuses snap set unless the snap has a configure hook. This hook validates that both keys are empty, true or false.
  • snapcraft/commands/daemon.start: reads both keys with snapctl get when the daemon starts. The hook doesn't restart the daemon, so changes take effect after snap restart microcloud. The LXD snap behaves the same way.
  • doc/how-to/snaps.md: adds an "Enable debug logging" section.

Usage:

sudo snap set microcloud daemon.debug=true
sudo snap restart microcloud

This affects MicroCloud's own logs, which go through the LXD logger. Microcluster's slog handler stays at its default level. Passing our level to it ties into the logger rework in #1084, so I left it out here.

Testing: I couldn't build the snap locally. I ran both scripts with stubbed snapctl and microcloudd binaries to check the arguments and environment for every combination of the two keys, and to check that the hook rejects values other than true and false.

Checklist

@wak327

wak327 commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

@roosterfish this adds snap set microcloud daemon.debug=true along the lines of your proposal in the issue. I couldn't build the snap locally, so I tested the hook and daemon.start with a stubbed snapctl. A quick check on an edge build would be welcome.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No unresolved blocking issues were identified.

No open issues 🎉

What changed in this PR

Adds snap configuration for daemon debug logging and dqlite tracing, with validation and documentation.

Changes:

  • Adds daemon.debug and db.trace startup handling.
  • Validates both options via the configure hook.
  • Documents configuration usage.
File Summary
snapcraft/​commands/​daemon.start Applies debug and tracing settings at startup.
snap/​hooks/​configure Validates snap configuration values.
doc/​how-to/​snaps.md Documents the new snap options.

Review effort: Lite

@roosterfish roosterfish left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! To make it more accessible for users, please also add a note to the snapcraft.yaml, similar to how it's done in LXD ("Supported configuration options for the snap (snap set lxd [=...]):").

Comment thread snap/hooks/configure Outdated
@wak327
wak327 force-pushed the snap-daemon-debug branch from ddae415 to 1a10cbd Compare October 21, 2026 14:15
@wak327

wak327 commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

@roosterfish I addressed both points: the configure hook now rejects unsupported keys (402ec9f), and the snap description lists the supported options in the same style as LXD (1a10cbd). I also rebased onto main and folded the hook change into the commit that adds the hook. Could you take another look?

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The configure hook does not correctly enumerate configured keys, so unsupported snap configuration keys are not rejected.

1 open issue

Review effort: Lite

Comment thread snap/hooks/configure Outdated
Comment thread snap/hooks/configure Outdated
@wak327

wak327 commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

@roosterfish I fixed how the configure hook reads the config: it now uses snapctl get "" "" to get the whole document, since a single empty key is rejected, and it fails if snapctl fails instead of skipping the check. I squashed the fix into the commit that adds the hook (d9a1855), so the PR is back to four commits. Could you take another look?

@wak327
wak327 force-pushed the snap-daemon-debug branch 2 times, most recently from 31352da to 25e972e Compare October 25, 2026 18:03
@wak327

wak327 commented Oct 25, 2026

Copy link
Copy Markdown
Contributor Author

@roosterfish I simplified the configure hook as you suggested: it now just compares each set key against daemon.debug and db.trace, with a short awk script to list the keys. It's squashed into the hook commit (eff8732). Could you take another look?

Comment thread snap/hooks/configure Outdated
Comment thread snap/hooks/configure Outdated
Reject unsupported config keys and validate the daemon.debug and db.trace config keys.

Signed-off-by: Waleed Khalid <wak327@gmail.com>
…ite tracing

Pass --debug to the daemon if daemon.debug is set to true.
Set LIBDQLITE_TRACE=1 if db.trace is set to true.

Signed-off-by: Waleed Khalid <wak327@gmail.com>
Signed-off-by: Waleed Khalid <wak327@gmail.com>
Signed-off-by: Waleed Khalid <wak327@gmail.com>
@wak327
wak327 force-pushed the snap-daemon-debug branch from 25e972e to 77ebf75 Compare October 27, 2026 20:27
@wak327

wak327 commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

@roosterfish the supported keys are now declared once in supported_keys and used for both checks, and the error only names the unsupported key. Squashed into the hook commit (f1016f0). Could you take another look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Documentation Documentation needs updating

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow enabling debug logging in MicroCloud

3 participants