Skip to content

Commit 82c2d65

Browse files
committed
fix: Bind klog flags to CLI options
1 parent 4c5bb31 commit 82c2d65

File tree

2 files changed

+12
-19
lines changed

2 files changed

+12
-19
lines changed

cmd/kar-controllers/app/options/options.go

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ package options
3232

3333
import (
3434
"flag"
35-
klog "k8s.io/klog/v2"
3635
"os"
3736
"strconv"
3837
"strings"
@@ -51,10 +50,10 @@ type ServerOption struct {
5150
BackoffTime int // Number of seconds a job will go away for, if it can not be scheduled. Default is 20.
5251
// Head of line job will not be bumped away for at least HeadOfLineHoldingTime seconds by higher priority jobs.
5352
// Default setting to 0 disables this mechanism.
54-
HeadOfLineHoldingTime int
55-
QuotaEnabled bool // Controller is to evaluate quota per request
56-
QuotaRestURL string
57-
HealthProbeListenAddr string
53+
HeadOfLineHoldingTime int
54+
QuotaEnabled bool // Controller is to evaluate quota per request
55+
QuotaRestURL string
56+
HealthProbeListenAddr string
5857
DispatchResourceReservationTimeout int64
5958
}
6059

@@ -78,13 +77,11 @@ func (s *ServerOption) AddFlags(fs *flag.FlagSet) {
7877
fs.BoolVar(&s.Preemption, "preemption", s.Preemption, "Set controller to allow preemption if set to true. Note: when set to true, the Kubernetes Scheduler must be configured to enable preemption. Default is false.")
7978
fs.IntVar(&s.BackoffTime, "backofftime", s.BackoffTime, "Number of seconds a job will go away for, if it can not be scheduled. Default is 20.")
8079
fs.IntVar(&s.HeadOfLineHoldingTime, "headoflineholdingtime", s.HeadOfLineHoldingTime, "Number of seconds a job can stay at the Head Of Line without being bumped. Default is 0.")
81-
fs.BoolVar(&s.QuotaEnabled,"quotaEnabled", s.QuotaEnabled,"Enable quota policy evaluation. Default is false.")
80+
fs.BoolVar(&s.QuotaEnabled, "quotaEnabled", s.QuotaEnabled, "Enable quota policy evaluation. Default is false.")
8281
fs.StringVar(&s.QuotaRestURL, "quotaURL", s.QuotaRestURL, "URL for ReST quota management. Default is none.")
8382
fs.IntVar(&s.SecurePort, "secure-port", 6443, "The port on which to serve secured, authenticated access for metrics.")
8483
fs.StringVar(&s.HealthProbeListenAddr, "healthProbeListenAddr", ":8081", "Listen address for health probes. Defaults to ':8081'")
8584
fs.Int64Var(&s.DispatchResourceReservationTimeout, "dispatchResourceReservationTimeout", s.DispatchResourceReservationTimeout, "Resource reservation timeout for pods to be created once AppWrapper is dispatched, in millisecond. Defaults to '300000', 5 minutes")
86-
flag.Parse()
87-
klog.V(4).Infof("[AddFlags] Controller configuration: %#v", s)
8885
}
8986

9087
func (s *ServerOption) loadDefaultsFromEnvVars() {
@@ -148,7 +145,3 @@ func (s *ServerOption) loadDefaultsFromEnvVars() {
148145
}
149146
}
150147
}
151-
152-
func (s *ServerOption) CheckOptionOrDie() {
153-
154-
}

cmd/kar-controllers/main.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,21 @@ package main
3333
import (
3434
"flag"
3535
"fmt"
36+
"os"
37+
38+
"k8s.io/klog/v2"
3639

3740
"github.com/project-codeflare/multi-cluster-app-dispatcher/cmd/kar-controllers/app"
3841
"github.com/project-codeflare/multi-cluster-app-dispatcher/cmd/kar-controllers/app/options"
39-
40-
"os"
4142
)
4243

4344
func main() {
44-
//flag.Parse()
45-
4645
s := options.NewServerOption()
47-
s.AddFlags(flag.CommandLine)
4846

49-
// flag.InitFlags()
50-
s.CheckOptionOrDie()
47+
flagSet := flag.CommandLine
48+
klog.InitFlags(flagSet)
49+
s.AddFlags(flagSet)
50+
flag.Parse()
5151

5252
if err := app.Run(s); err != nil {
5353
fmt.Fprintf(os.Stderr, "%v\n", err)

0 commit comments

Comments
 (0)