Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kraftkit Examples not working on Arch without proper Docker setup #2001

Open
cluosh opened this issue Dec 7, 2024 · 2 comments · May be fixed by #2136
Open

kraftkit Examples not working on Arch without proper Docker setup #2001

cluosh opened this issue Dec 7, 2024 · 2 comments · May be fixed by #2136
Assignees
Labels
kind/bug Something isn't working

Comments

@cluosh
Copy link

cluosh commented Dec 7, 2024

Describe the bug

During the Unikraft Workshop we discovered that kraftkit does not give a proper error message on Arch LInux if Docker is not installed/started/we do not have the correct permissions.

Steps to reproduce

Install kraftkit-bin from the AUR and don't start docker beforehand

Expected behavior

An error message that docker needs to be started/installed/user has correct permissions

Which architectures were you using or does this bug affect?

x86_64

Which operating system were you using or does this bug affect?

linux/arch

Relevant log output

i  use --as=kraftfile-runtime to skip this prompt in the future
Caught panic:

checked path: $XDG_RUNTIME_DIR

Restoring terminal...

goroutine 232 [running]:
runtime/debug.Stack()
	/usr/local/go/src/runtime/debug/stack.go:24 +0x5e
runtime/debug.PrintStack()
	/usr/local/go/src/runtime/debug/stack.go:16 +0x13
github.com/charmbracelet/bubbletea.(*Program).recoverFromPanic(0xc000143900)
	/go/pkg/mod/github.com/charmbracelet/[email protected]/tea.go:705 +0x91
panic({0x1e63bc0?, 0xc00048d3f8?})
	/usr/local/go/src/runtime/panic.go:770 +0x132
github.com/testcontainers/testcontainers-go/internal/core.MustExtractDockerHost.func1()
	/go/pkg/mod/github.com/testcontainers/[email protected]/internal/core/docker_host.go:91 +0x66
sync.(*Once).doSlow(0xc000aabc30?, 0xc000aabc80?)
	/usr/local/go/src/sync/once.go:74 +0xc2
sync.(*Once).Do(...)
	/usr/local/go/src/sync/once.go:65
github.com/testcontainers/testcontainers-go/internal/core.MustExtractDockerHost({0x2592198?, 0x37abcc0?})
	/go/pkg/mod/github.com/testcontainers/[email protected]/internal/core/docker_host.go:88 +0x58
github.com/testcontainers/testcontainers-go/internal/core.NewClient({0x2592198, 0x37abcc0}, {0x0, 0x0, 0x0?})
	/go/pkg/mod/github.com/testcontainers/[email protected]/internal/core/client.go:17 +0x88
github.com/testcontainers/testcontainers-go.NewDockerClientWithOpts({0x2592198, 0x37abcc0}, {0x0, 0x0, 0x0})
	/go/pkg/mod/github.com/testcontainers/[email protected]/docker_client.go:117 +0x71
github.com/testcontainers/testcontainers-go.NewDockerProvider({0xc0007ab560, 0x2, 0x21c1d7f?})
	/go/pkg/mod/github.com/testcontainers/[email protected]/provider.go:143 +0x10f
github.com/testcontainers/testcontainers-go.ProviderType.GetProvider(0x0, {0xc000aace28, 0x1, 0x586d1a?})
	/go/pkg/mod/github.com/testcontainers/[email protected]/provider.go:114 +0x3e5
github.com/testcontainers/testcontainers-go.GenericContainer({_, _}, {{{{0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}, ...}, ...}, ...})
	/go/pkg/mod/github.com/testcontainers/[email protected]/generic.go:59 +0x139
kraftkit.sh/initrd.(*dockerfile).Build(0xc000181c20, {0x25920b8, 0xc00071d6b0})
	/__w/kraftkit/kraftkit/initrd/dockerfile.go:283 +0xad9
kraftkit.sh/internal/cli/kraft/utils.BuildRootfs.func1({0x25920b8?, 0xc00071d6b0?})
	/__w/kraftkit/kraftkit/internal/cli/kraft/utils/rootfs.go:55 +0x63
kraftkit.sh/tui/processtree.(*ProcessTree).Init.(*ProcessTree).waitForProcessCmd.func2()
	/__w/kraftkit/kraftkit/tui/processtree/processtree.go:334 +0x11a
github.com/charmbracelet/bubbletea.(*Program).handleCommands.func1.1()
	/go/pkg/mod/github.com/charmbracelet/[email protected]/tea.go:324 +0x86
created by github.com/charmbracelet/bubbletea.(*Program).handleCommands.func1 in goroutine 227
	/go/pkg/mod/github.com/charmbracelet/[email protected]/tea.go:318 +0x139
 E  could not prepare deployment: could not package: could not package: could not build rootfs: program was killed: context canceled
@cluosh cluosh added the kind/bug Something isn't working label Dec 7, 2024
@craciunoiuc craciunoiuc self-assigned this Dec 10, 2024
@craciunoiuc
Copy link
Member

This looks like a panic generated by a library we use, and indeed the line that generates it is a library call.

I think it is easiest if we just wait for a fix in testcontainers to come out, before attempting any workaround.

Glad that you fixed the problem though!

@craciunoiuc
Copy link
Member

Update: I tracked down the code in their library and found this function deep down:

// MustExtractDockerHost Extracts the docker host from the different alternatives, caching the result to avoid unnecessary
// calculations. Use this function to get the actual Docker host. This function does not consider Windows containers at the moment.
// The possible alternatives are:
//
//  1. Docker host from the "tc.host" property in the ~/.testcontainers.properties file.
//  2. DOCKER_HOST environment variable.
//  3. Docker host from context.
//  4. Docker host from the default docker socket path, without the unix schema.
//  5. Docker host from the "docker.host" property in the ~/.testcontainers.properties file.
//  6. Rootless docker socket path.
//  7. Else, because the Docker host is not set, it panics.
func MustExtractDockerHost(ctx context.Context) string {
	dockerHostOnce.Do(func() {
		cache, err := extractDockerHost(ctx)
		if err != nil {
			panic(err)
		}

		dockerHostCache = cache
	})

	return dockerHostCache
}

Notice that on step 7 it says that it just panics if it doesn't find anything.

I will try to catch/interpret this to give out a better error, but there's nothing more that can be done.

craciunoiuc added a commit to craciunoiuc/kraftkit that referenced this issue Feb 6, 2025
@craciunoiuc craciunoiuc linked a pull request Feb 6, 2025 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants