From e77fc178dbc6b5ae233d4f1d2ee0b80fac83e5a3 Mon Sep 17 00:00:00 2001 From: Francesco Romani Date: Mon, 2 Sep 2024 12:32:24 +0200 Subject: [PATCH] [KNI][release-4.16] cmd: dump version on startup log the component version first time as startup to make the troubleshooting (a bit) easier. Signed-off-by: Francesco Romani (cherry picked from commit 37426d9020a3bd19e6e3abb605e96f2e9addbeb7) --- cmd/noderesourcetopology-plugin/main.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/cmd/noderesourcetopology-plugin/main.go b/cmd/noderesourcetopology-plugin/main.go index efaa9ba74..6d8d3da98 100644 --- a/cmd/noderesourcetopology-plugin/main.go +++ b/cmd/noderesourcetopology-plugin/main.go @@ -21,8 +21,11 @@ import ( "os" "time" + "github.com/go-logr/logr" + utilfeature "k8s.io/apiserver/pkg/util/feature" "k8s.io/component-base/logs" + "k8s.io/component-base/version" "k8s.io/klog/v2/klogr" "k8s.io/kubernetes/cmd/kube-scheduler/app" @@ -37,12 +40,13 @@ import ( ) func main() { + logh := klogr.NewWithOptions(klogr.WithFormat(klogr.FormatKlog)) + printVersion(logh) // this must be the first thing logged ever. Note: we can't use V() yet - no flags parsed + utilfeature.DefaultMutableFeatureGate.SetFromMap(knifeatures.Desired()) rand.Seed(time.Now().UnixNano()) - logh := klogr.NewWithOptions(klogr.WithFormat(klogr.FormatKlog)) - knistatus.Setup(logh) // Register custom plugins to the scheduler framework. @@ -64,3 +68,8 @@ func main() { os.Exit(1) } } + +func printVersion(logh logr.Logger) { + ver := version.Get() + logh.Info("starting noderesourcetopology scheduler", "version", ver.GitVersion, "goversion", ver.GoVersion, "platform", ver.Platform) +}