Skip to content

Commit 751a0ad

Browse files
authored
Config options fix (#2321)
* Added check that one of confi-text or config-file is specified Signed-off-by: Shmuel Kallner <kallner@il.ibm.com> * Added dummy config-file argument to get tests to pass Signed-off-by: Shmuel Kallner <kallner@il.ibm.com> * Add a very basic logger to log startup messages in case of errors Signed-off-by: Shmuel Kallner <kallner@il.ibm.com> --------- Signed-off-by: Shmuel Kallner <kallner@il.ibm.com>
1 parent 62e3111 commit 751a0ad

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

cmd/epp/runner/runner.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ func (r *Runner) WithCustomCollectors(collectors ...prometheus.Collector) *Runne
142142
}
143143

144144
func (r *Runner) Run(ctx context.Context) error {
145+
// Setup a very basic logger in case command line argument parsing fails
146+
logutil.InitSetupLogging()
147+
145148
setupLog.Info(r.eppExecutableName+" build", "commit-sha", version.CommitSHA, "build-ref", version.BuildRef)
146149

147150
opts := runserver.NewOptions()

pkg/common/observability/logging/logger.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ import (
2727
"sigs.k8s.io/controller-runtime/pkg/log/zap"
2828
)
2929

30+
func InitSetupLogging() {
31+
logger := zap.New(zap.RawZapOpts(uberzap.AddCaller()))
32+
ctrl.SetLogger(logger)
33+
}
34+
3035
func InitLogging(opts *zap.Options) {
3136
logger := zap.New(zap.UseFlagOptions(opts), zap.RawZapOpts(uberzap.AddCaller()))
3237
ctrl.SetLogger(logger)

pkg/epp/server/options.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,9 @@ func (opts *Options) Validate() error {
228228
}
229229
}
230230

231+
if opts.ConfigText == "" && opts.ConfigFile == "" {
232+
return fmt.Errorf("one of the %q and %q flags must be set", "configText", "configFile")
233+
}
231234
if opts.ConfigText != "" && opts.ConfigFile != "" {
232235
return fmt.Errorf("both the %q and %q flags can not be set at the same time", "configText", "configFile")
233236
}

pkg/epp/server/options_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ func TestEndpointTargetPorts(t *testing.T) {
8787
opts := NewOptions()
8888
opts.AddFlags(tt.fs)
8989

90-
argv := []string{"--endpoint-selector", "app=vllm"}
90+
argv := []string{"--endpoint-selector", "app=vllm",
91+
"--config-file", "fake-config.yaml"} // Needed to avoid an options validation error
9192
argv = append(argv, tt.args...)
9293

9394
if err := tt.fs.Parse(argv); err != nil {

0 commit comments

Comments
 (0)