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

topology-updater: make -version always runnable #1297

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions cmd/nfd-topology-updater/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,8 @@ var DefaultKubeletStateDir = path.Join(string(hostpath.VarDir), "lib", "kubelet"
func main() {
flags := flag.NewFlagSet(ProgramName, flag.ExitOnError)

printVersion := flags.Bool("version", false, "Print version and exit.")

args, resourcemonitorArgs := parseArgs(flags, os.Args[1:]...)

if *printVersion {
fmt.Println(ProgramName, version.Get())
os.Exit(0)
}

// Assert that the version is known
if version.Undefined() {
klog.InfoS("version not set! Set -ldflags \"-X sigs.k8s.io/node-feature-discovery/pkg/version.version=`git describe --tags --dirty --always`\" during build or run.")
Expand All @@ -75,6 +68,7 @@ func main() {

func parseArgs(flags *flag.FlagSet, osArgs ...string) (*topology.Args, *resourcemonitor.Args) {
args, resourcemonitorArgs := initFlags(flags)
printVersion := flags.Bool("version", false, "Print version and exit.")

_ = flags.Parse(osArgs)
if len(flags.Args()) > 0 {
Expand All @@ -83,6 +77,11 @@ func parseArgs(flags *flag.FlagSet, osArgs ...string) (*topology.Args, *resource
os.Exit(2)
}

if *printVersion {
fmt.Println(ProgramName, version.Get())
os.Exit(0)
}

if len(resourcemonitorArgs.KubeletConfigURI) == 0 {
nodeAddress := os.Getenv("NODE_ADDRESS")
if len(nodeAddress) == 0 {
Expand Down