Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Add document about debugging snaps. #261
Conversation
kyrofa
reviewed
Jan 26, 2016
| +Further, systemd has log dump facility to look at all system and snap | ||
| +services. The "snappy service" command provides a easy way to monitor and | ||
| +inspect snap services. To get the status of all snap services run "snappy | ||
| +service status". To inspect the the logs run "snappy service logs". Both |
kyrofa
reviewed
Jan 26, 2016
| +In order to test a new snap on a Snappy system you need to install it first. | ||
| +This is called sideloading and it can be done via | ||
| +`snappy-remote --url=ssh://ubuntu@webdm.local/ install snapname.snap`. | ||
| +Alternatively the nap can be copied via scp into the Snappy system and |
kyrofa
reviewed
Jan 26, 2016
| +service status". To inspect the logs run "snappy service logs". Both commands | ||
| +can take a snap name to limit to a specific snap and also `<snapname>` to | ||
| +limit to only a specific service of a snap (ie for the shout service in | ||
| +`shout.sergiusens` run: `sudo snappy service logs shout`). |
kyrofa
Jan 26, 2016
Member
Both commands can take a snap name to limit to a specific snap and also
<snapname>to limit to only a specific service of a snap[...]
I don't quite understand what you're saying here. In my testing, there was no way to limit the logs to only a specific service of the .snap-- only sudo snappy service logs <package name>.
ie for the shout service in [...]
Pedantic, but you probably want "e.g." here instead of "i.e.".
kyrofa
Jan 27, 2016
Member
Ah, I understand that snappy service logs is a valid command, as is snappy service logs <snapname>. What I mean to say is that the sentence "Both commands can take a snap name to limit to a specific snap and also to limit to only a specific service of a snap" is not clear to me. snappy service logs <snapname> does indeed limit it to services contained in that given snap, but what if that .snap contains three services? It will show the logs for all three jumbled together. There doesn't seem to be a way to get the log for a single service out of it, which "to limit to only a specific service of a snap" implies.
kyrofa
reviewed
Jan 26, 2016
| +example, the snap `pastebinit.mvo` contains a `pastebinit` script. The binary | ||
| +on disk will be called `pastebinit.pastebinit`. The exception of this rule are | ||
| +frameworks which may have short binary names. E.g. the docker package contains | ||
| +a docker binary. |
kyrofa
Jan 26, 2016
Member
Perhaps the framework sentence should be removed considering that frameworks as we know them will not exist in 16.04.
kyrofa
reviewed
Jan 26, 2016
| +To find out what paths are available to write the `hello-world` package is | ||
| +helpful. After installing it the command `hello-world.env` is available that | ||
| +will show the environment that the snap binaries see. The | ||
| +`SNAP_APP_USER_DATA_PATH` and `SNAP_APP_DATA_PATH` contain the directories |
dholbach
Jan 27, 2016
Contributor
Hum, are you commenting on the environment variable names? This is what I see on rolling/edge:
(amd64)ubuntu@localhost:$ hello-world.env | grep SNAP_APP$
SNAP_APP_PATH=/apps/hello-world.mvo/2.0
SNAP_APP_USER_DATA_PATH=/home/ubuntu/apps/hello-world.mvo/2.0
SNAP_APP_TMPDIR=/tmp
SNAP_APP_DATA_PATH=/var/lib/apps/hello-world.mvo/2.0
(amd64)ubuntu@localhost:
kyrofa
Jan 27, 2016
Member
Yeah try grepping for only SNAP. For more information see the PR that added them. The variables are still there, but they've been deprecated and replaced with different names.
kyrofa
reviewed
Jan 26, 2016
| +log messages (rarely)-- if you feel this is the case, reboot and try again): | ||
| + | ||
| + $ sudo snappy install snappy-debug | ||
| + $ sudo snappy-debug.security disable-rate-limiting |
kyrofa
Jan 26, 2016
Member
Might be worth pointing out that snappy-debug.security scanlog does this automatically while running.
dholbach
Jan 27, 2016
Contributor
What's a bit weird is that I can't run this under sudo, I get:
sudo: snappy-debug.security: command not found
Running this as the ubuntu user, I get
sysctl: permission denied on key 'kernel.printk_ratelimit'
but the other output is fine...
kyrofa
Jan 27, 2016
Member
Oh odd... I can run it as sudo on 15.04 just fine-- I've not tried on rolling.
dholbach
Jan 27, 2016
Contributor
You are right about 15.04. Shall we document the behaviour you see and treat rolling as a bug? It looks likely to me. @sergiusens - what do you think?
|
Excellent document, though some of it is specific to 15.04 (e.g. using deprecated environment variables, etc.). |
|
Aside from my previous comment, here's a preemptive |
kyrofa
reviewed
Jan 27, 2016
| +* Attempting to write to files outside of `SNAP_DATA` and `SNAP_USER_DATA`. | ||
| + This is a very common problem for apps that are being ported to Ubuntu Core | ||
| + or packaged as snaps for the first time. Typical issues might include: | ||
| + * writing to files in the read only `SNAP_DIR`. Fix this by writing |
kyrofa
reviewed
Jan 27, 2016
| + This is a very common problem for apps that are being ported to Ubuntu Core | ||
| + or packaged as snaps for the first time. Typical issues might include: | ||
| + * writing to files in the read only `SNAP_DIR`. Fix this by writing | ||
| + to `SNAP_DATA` for `services` and either `SNAP_APP_DATA` or |
kyrofa
Jan 27, 2016
Member
I believe there's only $SNAP_DATA and $SNAP_USER_DATA, no $SNAP_APP_DATA.
kyrofa
reviewed
Jan 27, 2016
| + or similar | ||
| + * improperly evaluating or typoing `SNAP_` variables so the program | ||
| + uses the wrong path. Eg, using `$SNAP_APP_DATA/foo` instead of | ||
| + `$SNAP_DIR/foo` (`SNAP_APP_DATA` is non-existent so it would |
kyrofa
reviewed
Jan 27, 2016
| + * hard coded paths in the program. The program should be adjusted ideally | ||
| + to understand `SNAP_` variables or use relative paths | ||
| +* Attempting to read files outside of `SNAP_DIR`, `SNAP_DATA` and | ||
| + `SNAP_USER`. This usually happens if your program is looking for something |
kyrofa
reviewed
Jan 27, 2016
| + | ||
| +### Find a binary in the file system hierarchy | ||
| + | ||
| +All binary names can be found in `/apps/bin/`. The snappy tool will generate |
|
|
|
Thanks for this! |
dholbach commentedJan 26, 2016
LP: #1538016