direktiv / vorteil

turn your applications and containers into micro virtual machines
https://direktiv.io
Apache License 2.0
174 stars 13 forks source link

vkern.CLIArgs crashes with non-existent directories #58

Closed jensg-st closed 4 years ago

jensg-st commented 4 years ago

Problem description

If vkern.CLIArgs point to non-existent directories it crashes with a NPE

Expected behaviour

The following code snippet should throw an error or create /tmp/doesntexist"

    ksrc, err := vkern.CLI(vkern.CLIArgs{
        Directory:          "/tmp/doesntexist",
        DropPath:           "/tmp/doesntexist",
        RemoteRepositories: []string{"https://downloads.vorteil.io/kernels"},
    }, nil)

Actual behaviour

NPE with:

goroutine 1 [running]:
github.com/vorteil/vorteil/pkg/vkern.(*CLIRemoteManager).forceUpdate(0xc0001eac60, 0x9f0e60, 0xc0000240c8, 0x0, 0x0)
    /home/jensg/go/pkg/mod/github.com/vorteil/vorteil@v0.0.0-20200925083208-efe91efe644b/pkg/vkern/cli.go:141 +0xf8
github.com/vorteil/vorteil/pkg/vkern.(*CLIRemoteManager).update(0xc0001eac60, 0x9f0e60, 0xc0000240c8, 0x0, 0xc000139910)
    /home/jensg/go/pkg/mod/github.com/vorteil/vorteil@v0.0.0-20200925083208-efe91efe644b/pkg/vkern/cli.go:130 +0x74
github.com/vorteil/vorteil/pkg/vkern.(*CLIRemoteManager).List(0xc0001eac60, 0x9f0e60, 0xc0000240c8, 0x0, 0x0, 0x0, 0x0, 0x0)
    /home/jensg/go/pkg/mod/github.com/vorteil/vorteil@v0.0.0-20200925083208-efe91efe644b/pkg/vkern/cli.go:382 +0x5a
github.com/vorteil/vorteil/pkg/vkern.(*CompoundManager).List(0xc0001f21c0, 0x9f0e60, 0xc0000240c8, 0x0, 0x93598f, 0x3, 0x0, 0x0)
    /home/jensg/go/pkg/mod/github.com/vorteil/vorteil@v0.0.0-20200925083208-efe91efe644b/pkg/vkern/manager-compund.go:61 +0xbe
github.com/vorteil/vorteil/pkg/vkern.(*CompoundManager).Get(0xc0001f21c0, 0x9f0e60, 0xc0000240c8, 0xc0001ab620, 0x7, 0xc000139c08, 0x7f6d87, 0xc0001a49c0)
    /home/jensg/go/pkg/mod/github.com/vorteil/vorteil@v0.0.0-20200925083208-efe91efe644b/pkg/vkern/manager-compund.go:30 +0x43
github.com/vorteil/vorteil/pkg/vimg.(*Builder).loadKernel(0xc00012ef00, 0x9f0e60, 0xc0000240c8, 0x93598f, 0x3)
    /home/jensg/go/pkg/mod/github.com/vorteil/vorteil@v0.0.0-20200925083208-efe91efe644b/pkg/vimg/os.go:49 +0x7e
github.com/vorteil/vorteil/pkg/vimg.(*Builder).calculateMinimumOSPartitionSize(0xc00012ef00, 0x9f0e60, 0xc0000240c8, 0x0, 0x0)
    /home/jensg/go/pkg/mod/github.com/vorteil/vorteil@v0.0.0-20200925083208-efe91efe644b/pkg/vimg/os.go:65 +0x6a
github.com/vorteil/vorteil/pkg/vimg.(*Builder).calculateMinimumSize(0xc00012ef00, 0x9f0e60, 0xc0000240c8, 0x0, 0x0)
    /home/jensg/go/pkg/mod/github.com/vorteil/vorteil@v0.0.0-20200925083208-efe91efe644b/pkg/vimg/builder.go:139 +0x4b
github.com/vorteil/vorteil/pkg/vimg.NewBuilder(0x9f0e60, 0xc0000240c8, 0xc000139d50, 0x7f420886b4e0, 0xc0001ec450, 0xc00019ac00)
    /home/jensg/go/pkg/mod/github.com/vorteil/vorteil@v0.0.0-20200925083208-efe91efe644b/pkg/vimg/builder.go:105 +0x1fe
github.com/vorteil/vorteil/pkg/vdisk.CreateBuilder(...)
    /home/jensg/go/pkg/mod/github.com/vorteil/vorteil@v0.0.0-20200925083208-efe91efe644b/pkg/vdisk/build.go:67
github.com/vorteil/vorteil/pkg/vdisk.build(0x9f0e60, 0xc0000240c8, 0x9ec740, 0xc000011098, 0xc00000c960, 0xc0001e6c00, 0x0, 0x0)
    /home/jensg/go/pkg/mod/github.com/vorteil/vorteil@v0.0.0-20200925083208-efe91efe644b/pkg/vdisk/build.go:78 +0x20b
github.com/vorteil/vorteil/pkg/vdisk.Build(0x9f0e60, 0xc0000240c8, 0x9ec740, 0xc000011098, 0xc0001e6c00, 0x0, 0x0)
    /home/jensg/go/pkg/mod/github.com/vorteil/vorteil@v0.0.0-20200925083208-efe91efe644b/pkg/vdisk/build.go:121 +0x109

System details

Please include details about the system that the issue can be reproduced on, including:

jensg-st commented 4 years ago

It does not seem to be an issue if there is a cached-kernel-manifest in the directory. But If I just "touch" a file it crashes as well with a different error:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x7eb665]

goroutine 1 [running]:
github.com/vorteil/vorteil/pkg/vkern.NewCLIRemoteManager(0x944f61, 0x24, 0xc0001e27b0, 0x27, 0x0, 0x0, 0x1, 0xc0000291a0, 0x1c)
    /home/jensg/go/pkg/mod/github.com/vorteil/vorteil@v0.0.0-20200925083208-efe91efe644b/pkg/vkern/cli.go:425 +0x545
github.com/vorteil/vorteil/pkg/vkern.CLI(0x9375ae, 0xa, 0x9375ae, 0xa, 0xc0001bcf70, 0x1, 0x1, 0x0, 0x0, 0x40e648, ...)
    /home/jensg/go/pkg/mod/github.com/vorteil/vorteil@v0.0.0-20200925083208-efe91efe644b/pkg/vkern/cli.go:454 +0x22d
main.main()
    /home/jensg/vcontainerd/testme/gg.go:46 +0x466
jensg-st commented 4 years ago

seems to be a logging issue