Skip to content

Unable to pass --feature-gates to k0s config validate #6611

@kawaemon

Description

@kawaemon

When a configuration needs feature flag to pass validation (such as IPv6SingleStack), there are no way to pass k0s config validate command because it doesn't accept --feature-gates.

This means there is no way to use k0sctl, because it runs k0s config validate in the middle of installation process.

Also current implementation even panics when it's missing. I think it should give some kind error messages.

> git status
On branch main
Your branch is up to date with 'origin/main'.

nothing to commit, working tree clean

> git log --oneline | head -n 1
55941d5f4 Merge pull request #6603 from twz123/demote-coredns-reconciler-log

> make
make: Nothing to be done for 'build'.

> ./k0s version
v1.34.1+k0s.0-114-g55941d5f4

> ./k0s controller --help | grep -- '--feature-gates'
      --feature-gates mapStringBool                    feature gates to enable (comma separated list of key=value pairs)

> ./k0s config validate --help | grep -- '--feature-gates'

> cat ~/cluster.yml
apiVersion: k0s.k0sproject.io/v1beta1
kind: ClusterConfig
metadata:
  name: k0s
spec:
  network:
    podCIDR: fd00::/108
    serviceCIDR: fd01::/108

> ./k0s config validate --config ~/cluster.yml  --feature-gates="IPv6SingleStack=true"
Error: unknown flag: --feature-gates

> ./k0s config validate --config ~/cluster.yml
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x26a2c2a]

goroutine 1 [running]:
github.com/k0sproject/k0s/pkg/featuregate.(*FeatureGates).isEnabled(...)
        github.com/k0sproject/k0s/pkg/featuregate/featuregate.go:43
github.com/k0sproject/k0s/pkg/featuregate.IsEnabled(...)
        github.com/k0sproject/k0s/pkg/featuregate/featuregate.go:120
github.com/k0sproject/k0s/pkg/apis/k0s/v1beta1.(*Network).Validate(0xc000cabc20)
        github.com/k0sproject/k0s/pkg/apis/k0s/v1beta1/network.go:119 +0x1d6a
github.com/k0sproject/k0s/pkg/apis/k0s/v1beta1.(*ClusterSpec).Validate(0xc000ee2880)
        github.com/k0sproject/k0s/pkg/apis/k0s/v1beta1/clusterconfig_types.go:405 +0x51a
github.com/k0sproject/k0s/pkg/apis/k0s/v1beta1.(*ClusterConfig).Validate(0xc000273600?)
        github.com/k0sproject/k0s/pkg/apis/k0s/v1beta1/clusterconfig_types.go:467 +0x2b
github.com/k0sproject/k0s/cmd/config.NewValidateCmd.func1(0xc0010d9700?, {0xc000954080?, 0x4?, 0x40811f4?})
        github.com/k0sproject/k0s/cmd/config/validate.go:52 +0x105
github.com/spf13/cobra.(*Command).execute(0xc00049a008, {0xc000954060, 0x2, 0x2})
        github.com/spf13/[email protected]/command.go:1015 +0xb02
github.com/spf13/cobra.(*Command).ExecuteC(0xc00078e008)
        github.com/spf13/[email protected]/command.go:1148 +0x465
github.com/spf13/cobra.(*Command).Execute(...)
        github.com/spf13/[email protected]/command.go:1071
github.com/spf13/cobra.(*Command).ExecuteContext(...)
        github.com/spf13/[email protected]/command.go:1064
github.com/k0sproject/k0s/internal/supervised.run({0x4962b40, 0xc00089e730}, 0xc00078e008)
        github.com/k0sproject/k0s/internal/supervised/supervised_other.go:17 +0x9d
github.com/k0sproject/k0s/internal/supervised.Run(...)
        github.com/k0sproject/k0s/internal/supervised/supervised.go:32
main.run({0x4962b40, 0xc00089e730})
        github.com/k0sproject/k0s/main.go:48 +0x269
main.main()
        github.com/k0sproject/k0s/main.go:33 +0xb0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions