Troubleshooting
Although we would love everything to work out of the box, the world, the cloud, and software are more complicated than that. In this guide we show you how to debug apps on Uniktaft Cloud (UKC) so that you may fix issues, or, in the worst case, be able to provide enough information for us to do so for you.
I have a problem with my app, how do I debug it?
Your application may crash, freeze or misbehave. To inspect it, try either:
This may, in certain times, provide insufficient information.
Why does my (large) filesystem build process get stuck?
In case of filesystems larger than about 800MB
, the build may get stuck. The
issue is caused by a problem in BuildKit, the current filesystem build component
used by Unikraft Cloud.
The current workaround is to reduce the filesystem image below 800 MB
; we are
working to integrate another filesystem build component that gets past the
BuildKit limitation.
I'm getting a gateway error, what gives?
When you query a Unikraft Cloud service via its public URL, such as below:
you may get a Bad Gateway
response:
This is the case when you specify the wrong internal application port when
deploying, for example if the application exposes port 8080 but you happen to
use 443:80
instead of 443:8080
.
Another error response you may get is:
This typically happens when you connect to your app with an HTTPS client (on
port 443
) and the application doesn't expose that port externally. This is the
case with database services such as MongoDB or
MariaDB that use a different protocol/port (e.g.,
27017
, 3306
).
To solve this, use the appropriate exposed port; this may require the use of TLS tunnel, as detailed below.
How do I connect to a non-TLS App?
Unikraft Cloud uses TLS to expose services to the outside world. However,
certain applications (such as MongoDB or
MariaDB) do not use TLS. In these cases, you can create
a TLS tunnel via the kraft cloud tunnel
, which will open a local end point (on
localhost
/ 127.0.0.1
) that will tunnel the client traffic via the TLS
tunnel. For an example of this please refer to the MariaDB
guide.
I'm getting a "no such file or directory" when building/deploying an image
When building / deploying an image, you may get the error below:
Generally, this means that the local kraft
cache is in an inconsistent state.
To solve this, remove the local kraft
cache and local packages:
I've launched an app but I can't see it/list it
The most common reason is when you (and us too!) deploy an app to one metro but do a listing on a different one. To set the metro you use, you can do it for a session by an env variable:
or for each indvidual command via the --metro
flag, for example:
How can I cache the app's filesystem for faster builds?
When using a Dockerfile
for the application filesystem, the commands are
passed to BuildKit.
By default, an ephemeral BuildKit container is started each time you invoke
kraft cloud deploy
. This means that the filesystem application data is then
removed, and that each deploy command will start from zero.
To prevent this, follow the instructions here:
The approach above will cache the builds in the BuildKit container filesystem. Another approach is to save the cache in a local host directory, for persistence:
where $HOME/.buildkit-cache
is a local path on your machine where you can
store caches from BuildKit itself.
What's a Kraftfile
?
A Kraftfile
is used by the kraft
CLI tool to understand how to build and
deploy your instance. In most cases, you can use the default Kraftfile
found
in each of our examples; but in case you're curious, here's a sample Kraftfile
and a brief explanation of it:
Kraftfile
The runtime
specifies one of the UKC runtimes (unikernels) built to run different languages and applications, in this case a Python one.
The rootfs
parameter simply tells kraft
to use a Dockerfile
in the same directory to build the root filesystem, and the cmd
parameter which command to run when deployed (although you can also specify this in the Dockerfile
).
Finally the labels
are there to specify run-time options; in the example
above, we're enabling stateful scale to zero, and asking UKC to wait for 1
second of no requests before putting our instance to sleep.
Debugging the Build, Packaging and Pushing Steps
The kraft cloud deploy
command performs several steps on your local device
before actually deploying your app to UKC:
- Downloads the runtime image (defined in the
Kraftfile
) from the UKC registry. - Builds the application filesystem using the
Dockerfile
via BuildKit. - Packages the application filesystem and the runtime in an OCI image.
- Pushes the OCI image to the to the UKC registry under your username's namespace.
In case any of these fail or report issues you can enable kraft
debugging by
using the --log-level
and --log-type
flags:
You should then see debug output for the 4 steps above, similar to:
Hopefully this output will give you better insights into what the issue is; if not, please report the issue to us with the output on our Discord server.
Debugging Running Apps
The most direct way to debug apps on UKC is to use the apps's console output,
which may include kernel output. To see it, after starting the UKC instance (via
kraft cloud deploy
or kraft cloud inst create
), use:
In case of a crash, you'll see a full crash output:
Use the recommended command for detailed output. You get something like:
This gives you a more clear reason of why the error occurred, in the stop reason
line. In this case, it's because of insufficient memory.
Some times the stop reason is insufficient for debugging. The next step is to enable debug tracing for the instance.
To do that, in your application of choice in the examples
repository, or in an application
directory you created, update the runtime
entry in the Kraftfile
to
reference the debug build of the image you use by adding -dbg
to the name of
the runtime. For example, if you want to run the http-go1.21
example with
debug output, update its Kraftfile
as follows:
Kraftfile
That is, simply change base:latest
to base:latest-dbg
. Now we're ready to re-deploy:
We can now can now inspect the logs as before and get the system call tracing:
This mechanism should work for all apps/runtimes and we hope will give you enough insights into what the problem is. If not, please contact us on the Discord server and provide this output so we can assist you in debugging.
While you try to debug/sort out what the issue with an app is, you can mitigate
crashes by setting a restart policy. For example, you could use kraft cloud deploy --restart on-failure
to have UKC automatically bring your app back on if
it crashes. You can find more info on restart policies
here.
Learn More
- The
kraft cloud
CLI reference - Unikraft Cloud's REST API reference
- Many more guides here