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

[BUG] Unable to run a cluster that mounts existing docker volumes on windows #567

Closed
dhenneke opened this issue Apr 22, 2021 · 1 comment
Assignees
Labels
bug Something isn't working
Milestone

Comments

@dhenneke
Copy link

What did you do

  1. Create a docker volume docker volume create my-docker-volume

  2. Create a new config file:

apiVersion: k3d.io/v1alpha2
kind: Simple
name: test
servers: 1
agents: 0
volumes:
  - volume: my-docker-volume:/var/lib/rancher/k3s/storage
    nodeFilters:
      - all
  1. Run k3d cluster create -c config.yaml

What did you expect to happen

The cluster boots. But it crashes with the following error:

INFO[0000] Using config file config.yaml
panic: runtime error: index out of range [2] with length 2

goroutine 1 [running]:
github.com/rancher/k3d/v4/pkg/runtimes/util.ValidateVolumeMount(0x1a373b0, 0x1f21da8, 0xc0004310e0, 0x2d, 0x0, 0x0)
        /drone/src/pkg/runtimes/util/volumes.go:66 +0x4d2
github.com/rancher/k3d/v4/pkg/config.ValidateClusterConfig(0x1a27898, 0xc000036050, 0x1a373b0, 0x1f21da8, 0x0, 0x0, 0x0, 0x0, 0xc000405790, 0x4, ...)
        /drone/src/pkg/config/validate.go:93 +0x17e
github.com/rancher/k3d/v4/cmd/cluster.NewCmdClusterCreate.func2(0xc0003c6000, 0xc00037f5e0, 0x0, 0x2)
        /drone/src/cmd/cluster/clusterCreate.go:159 +0x7b9
github.com/spf13/cobra.(*Command).execute(0xc0003c6000, 0xc00037f5c0, 0x2, 0x2, 0xc0003c6000, 0xc00037f5c0)
        /drone/src/vendor/github.com/spf13/cobra/command.go:856 +0x2c2
github.com/spf13/cobra.(*Command).ExecuteC(0x1ecfda0, 0xc000138010, 0x4, 0x7)
        /drone/src/vendor/github.com/spf13/cobra/command.go:960 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
        /drone/src/vendor/github.com/spf13/cobra/command.go:897
github.com/rancher/k3d/v4/cmd.Execute()
        /drone/src/cmd/root.go:95 +0x65
main.main()
        /drone/src/main.go:27 +0x27

#510 added a workaround to allow c:\folder:/mnt/test mounts, however this breaks volume-mounts like docker-volume:/mnt/test.
https://github.com/rancher/k3d/blob/fd793fe4cba780471c69daeac1ae8234332478d1/cmd/util/volumes.go#L67-L70

An option could be to add an additional check that makes sure that there are enough array elements:

- } else if rt.GOOS == "windows" {
+ } else if rt.GOOS == "windows" && len(split) == 3 {
    src = split[0] + ":" + split[1]
    dest = split[2]
  } ...

Which OS & Architecture

  • Windows

Which version of k3d

C:\WINDOWS\system32>k3d --version
k3d version v4.4.2
k3s version v1.20.6-k3s1 (default)
@dhenneke dhenneke added the bug Something isn't working label Apr 22, 2021
@iwilltry42 iwilltry42 self-assigned this Apr 23, 2021
@iwilltry42 iwilltry42 added this to the v4.4.3 milestone Apr 23, 2021
@iwilltry42
Copy link
Member

Hi @dhenneke , thanks for pointing this out!
Fix will be included in the next release 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants