Troubleshooting
This guide explains how to debug apps on Unikraft Cloud so you can fix issues or collect enough information for the support team to help you. It follows platform best practices and supports efficient troubleshooting. If you need help, reach out to Unikraft Cloud Support on Discord or write to support@unikraft.cloud.
Debugging running apps
The most direct way to debug an app is to use the app console output, which may include kernel output. To see it, after starting the Unikraft Cloud instance, use:
In case of a crash, you'll see a full crash output:
or even
Inspect the instance details to see the stop reason:
This yields output like:
This output shows the stop reason. Here the cause is insufficient memory.
If the stop reason lacks detail, enable debug tracing for the instance.
To do that, pick an app from the examples repository or an app directory you created.
Update the runtime entry in the Kraftfile to reference the debug build by adding -dbg to the runtime name.
For example, if you want to run the httpserver-go1.21 example with debug output, update its Kraftfile as follows:
Kraftfile
That is, change base-compat:latest to base-compat:latest-dbg.
Now you're ready to re-deploy:
You can now inspect the logs as before and view system call tracing:
This mechanism works for all apps and runtimes. Contact Unikraft Cloud on the Discord server and include this output if you need more detail.
While you debug an issue you can mitigate crashes by setting a restart policy.
For example, use the CLI to set --restart on-failure so the platform restarts the app if it crashes.
Debugging the build and push steps
The CLI performs steps on your local device before actually deploying your app to Unikraft Cloud:
- Downloads the runtime image (defined in the
Kraftfile) from the Unikraft Cloud registry. - Builds the app filesystem using the
Dockerfilevia BuildKit. - Packages the app filesystem and the runtime in an Open Container Initiative (OCI) image.
- Pushes the OCI image to the to the Unikraft Cloud registry under your username's namespace.
If any of these steps fail, enable legacy CLI debugging with the --log-level and --log-type flags:
You should then see debug output for the 4 steps above. This output should give enough context to diagnose the issue.
Caching the app's filesystem for faster builds
When using a Dockerfile for the app filesystem, Unikraft Cloud passes the commands to BuildKit.
By default, each legacy kraft cloud deploy command starts an ephemeral BuildKit container.
The platform then removes the filesystem app data, so each deploy starts from zero.
To prevent this, follow the instructions here:
Code
The approach above caches builds in the BuildKit container filesystem. Another approach saves the cache in a local host directory:
Here $HOME/.buildkit-cache is a local path on your machine where BuildKit stores cache data.
Large filesystem build process gets stuck
When the filesystem is larger than about 800 MB, the build may get stuck.
A limitation in BuildKit, the current filesystem build component, causes the issue.
Work around this by reducing the filesystem image below 800 MB.
Work is in progress to integrate a component without this limitation.
Gateway error when accessing a service
When you query a Unikraft Cloud service via its public address, such as:
Code
you may get a Bad Gateway response:
This happens when you specify the wrong internal app port (for example, the app exposes port 8080 but you use 443:80 instead of 443:8080).
Another error response you may get is:
This happens when you connect with an HTTPS client (port 443) and the app doesn't expose that port.
Database services such as MongoDB or MariaDB use different ports (for example, 27017, 3306).
Use the correct exposed port. You may need a TLS tunnel (see below).
If you still have issues, it might mean that the app fails to start or crashes immediately. In that case, inspect the app logs first.
Connecting to a non-TLS app
Unikraft Cloud uses TLS to expose services to the outside world. Some apps (such as MongoDB or MariaDB) don't use TLS.
Create a TLS tunnel via the legacy CLI or socat, which opens a local endpoint (localhost / 127.0.0.1) and forwards traffic over TLS.
See the MariaDB guide for an example.
"No such file or directory" when building or deploying an image
When building / deploying an image using kraft, you may get the error below:
This often means the local kraft cache is in an inconsistent state.
To solve this, remove the local cache and local packages:
Launched app not visible in list
The most common reason is that you deployed an app to one metro but listed a different one.
Use the --metro flag per command, or use the legacy CLI environment variable for a session:
The UKC_METRO environment variable is only supported by the legacy CLI.
Learn more
- The CLI reference and the legacy CLI reference.
- Unikraft Cloud's REST API reference.
- Many more guides here.