-
Notifications
You must be signed in to change notification settings - Fork 168
Enhance pool namespace resolution: use flag if set, else NAMESPACE en… #1578
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
Enhance pool namespace resolution: use flag if set, else NAMESPACE en… #1578
Conversation
…v var, else default; add documentation for behavior
✅ Deploy Preview for gateway-api-inference-extension ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Welcome @jyizheng! |
Hi @jyizheng. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
cmd/epp/runner/runner.go
Outdated
@@ -188,9 +188,16 @@ func (r *Runner) Run(ctx context.Context) error { | |||
FilterProvider: filters.WithAuthenticationAndAuthorization, | |||
} | |||
|
|||
// Determine pool namespace: flag > NAMESPACE env var > default |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the user may intentionally set the default in the flag, the logic below doesn't account for that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. Just changed my code.
cmd/epp/runner/runner.go
Outdated
@@ -188,9 +188,16 @@ func (r *Runner) Run(ctx context.Context) error { | |||
FilterProvider: filters.WithAuthenticationAndAuthorization, | |||
} | |||
|
|||
// Determine pool namespace: flag > NAMESPACE env var > default | |||
resolvedPoolNamespace := *poolNamespace | |||
if resolvedPoolNamespace == runserver.DefaultPoolNamespace { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should just check if flag is nil/empty string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sense. Just fixed it.
/ok-to-test |
cmd/epp/runner/runner.go
Outdated
// Determine pool namespace: if flag set, use it; else NAMESPACE env var; else default | ||
resolvedPoolNamespace := "" | ||
poolNamespaceFlagSet := false | ||
flag.Visit(func(f *flag.Flag) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we do something like this? No need to check the flag name I think.
func resolvePoolNamespace() string {
// check if --pool-namespace flag is set
if *poolNamespace != "" {
return *poolNamespace
}
// Check if NAMESPACE env var is set
nsEnv := os.Getenv("NAMESPACE")
if nsEnv != "" {
return nsEnv
}
// Fallback to default
return runserver.DefaultPoolNamespace
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh to do this we should set the default value of the flag to "", which I think we we should do.
poolNamespace = flag.String("pool-namespace", runserver.DefaultPoolNamespace, "Namespace of the InferencePool this Endpoint Picker is associated with.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry pls see my last comment we should set the default value of the flag to ""
, right now the flag is defaulted to default
so it will never be empty. We should change that, otherwise it's misleading.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. Just replace runserver.DefaultPoolNamespace
with empty string. Is this ok?
docs/pool-namespace-behavior.md
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry one last comment, I suggest we add a new flags.md
doc under https://github.com/kubernetes-sigs/gateway-api-inference-extension/tree/main/site-src/guides/epp-configuration, this is where we document how to configure the EPP binary.
In flags.md
we can just start with the pool-namespace flag. Most flags should be self explanatory in their flag description so we don't need to document everything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. File relocated.
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ahg-g, jyizheng The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
as a followup, can you please update the helm chart of the epp deployment to add the namespace envvar? |
What type of PR is this?
feature
What this PR does / why we need it:
Provides a convenient default without the need to explicitly set when running in a namespace other than default.
Use flag (--pool-namespce) if set, else NAMESPACE env var, else default; add documentation for behavior
Which issue(s) this PR fixes:
#1569
Does this PR introduce a user-facing change?:
NONE