Skip to content

Panic in pkg/featureflag when importing API types #702

@estroz

Description

@estroz

Importing API types causes a panic.

Repro steps:

$ mkdir test-dra-import
$ cd test-dra-import/
$ go mod init github.com/my/test
go: creating new go.mod: module github.com/my/test
$ go get github.com/NVIDIA/k8s-dra-driver-gpu@latest
$ cat <<EOF > main.go
package main

import (
	"github.com/NVIDIA/k8s-dra-driver-gpu/api/nvidia.com/resource/v1beta1"
)

func main() {
	_ = v1beta1.ComputeDomain{}
}
EOF
$ go mod tidy
$ go run ./main.go
panic: could not parse "unknown" as version

goroutine 1 [running]:
k8s.io/apimachinery/pkg/util/version.MustParse(...)
        /home/estroz/go/pkg/mod/k8s.io/[email protected]/pkg/util/version/version.go:164
github.com/NVIDIA/k8s-dra-driver-gpu/pkg/featuregates.parseProjectVersion()
        /home/estroz/go/pkg/mod/github.com/!n!v!i!d!i!a/[email protected]/pkg/featuregates/featuregates.go:79 +0x1c5
github.com/NVIDIA/k8s-dra-driver-gpu/pkg/featuregates.init.0()
        /home/estroz/go/pkg/mod/github.com/!n!v!i!d!i!a/[email protected]/pkg/featuregates/featuregates.go:73 +0x13
exit status 2

This can be worked around in builds by setting variables in ldflags but not in tests

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Closed

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions