Skip to content

Commit

Permalink
Merge pull request #230 from openshift-kni/log-version-startup-4.14
Browse files Browse the repository at this point in the history
[KNI][release-4.14] cmd: dump version on startup
  • Loading branch information
openshift-merge-bot[bot] authored Sep 3, 2024
2 parents 756bddb + 4baefe2 commit 6d75490
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions cmd/noderesourcetopology-plugin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,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"
"k8s.io/klog/v2/klogr"
"k8s.io/kubernetes/cmd/kube-scheduler/app"
Expand All @@ -45,7 +48,7 @@ const (
PFPStatusDumpEnvVar string = "PFP_STATUS_DUMP"
)

func setupPFPStatusDump() {
func setupPFPStatusDump(logh logr.Logger) {
dumpDir, ok := os.LookupEnv(PFPStatusDumpEnvVar)
if !ok || dumpDir == "" {
klog.InfoS("PFP Status dump disabled", "variableFound", ok, "valueGiven", dumpDir != "")
Expand All @@ -55,13 +58,15 @@ func setupPFPStatusDump() {
klog.InfoS("PFP Status dump enabled", "statusDirectory", dumpDir)

ch := make(chan podfingerprint.Status)
logh := klogr.NewWithOptions(klogr.WithFormat(klogr.FormatKlog))

podfingerprint.SetCompletionSink(ch)
go pfpstatus.RunForever(context.Background(), logh, dumpDir, ch)
}

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())
Expand All @@ -83,9 +88,14 @@ func main() {
logs.InitLogs()
defer logs.FlushLogs()

setupPFPStatusDump()
setupPFPStatusDump(logh)

if err := command.Execute(); err != nil {
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)
}

0 comments on commit 6d75490

Please sign in to comment.