[kubectl-plugin][Refactor] Standardize namespace resolution to respect kubeconfig context.#4367
[kubectl-plugin][Refactor] Standardize namespace resolution to respect kubeconfig context.#4367kash2104 wants to merge 1 commit intoray-project:masterfrom
Conversation
| namespace, _, err := options.cmdFactory.ToRawKubeConfigLoader().Namespace() | ||
| if err != nil{ | ||
| return "", fmt.Errorf("failed to get current namespace: %w", err) | ||
| } |
There was a problem hiding this comment.
Config file namespace ignored due to always-set options.namespace
High Severity
The resolveNamespace() function can no longer use the namespace from a config file. Previously, cmd.Flags().GetString("namespace") returned an empty string when the user didn't pass --namespace, allowing the config file namespace to be used. Now, ToRawKubeConfigLoader().Namespace() always returns a value (at minimum "default"), so options.namespace is never empty. This causes the condition if options.namespace != "" to always be true, making the else if branch that uses rayClusterConfig.Namespace unreachable. Additionally, the error check at line 249 will now incorrectly fail when a config file specifies a namespace different from the kubeconfig default.
Additional Locations (2)
There was a problem hiding this comment.
Agree, and I think you should add test to check this
Future-Outlier
left a comment
There was a problem hiding this comment.
cc @win5923 @lorriexingfang @AndySung320 @400Ping to review
|
Currently working on resolving the failing tests. |
0d9c447 to
f7a7f45
Compare
ab69d83 to
1d28033
Compare
win5923
left a comment
There was a problem hiding this comment.
CI keeps failing. Could you take a look?
https://github.com/ray-project/kuberay/actions/runs/21089666265/job/60659060831?pr=4367
|
I tried but the CI that is failing is Would appreciate help for debugging and passing this test. |
|
Hi @kash2104 ,
|
b8db8cb to
e904e1a
Compare
4b21de4 to
b1ff884
Compare
AndySung320
left a comment
There was a problem hiding this comment.
It looks like the Go-build-and-test / Lint (pre-commit) check is still failing.
Could you take a look and fix the lint issues?
16f91e9 to
0d67742
Compare
|
@AndySung320 Have fixed the failing tests. |
Future-Outlier
left a comment
There was a problem hiding this comment.
Should we also change completion.go?
|
If we change |
yes |
| @@ -61,10 +61,11 @@ func TestRayCreateClusterComplete(t *testing.T) { | |||
|
|
|||
| for name, tc := range tests { | |||
There was a problem hiding this comment.
Would it be possible to add a test case that respects the namespace in kubeconfig?
| @@ -70,11 +69,16 @@ func TestRayClusterGetComplete(t *testing.T) { | |||
|
|
|||
| for _, tc := range tests { | |||
9760507 to
e4e5aff
Compare
| namespace, _, err := options.cmdFactory.ToRawKubeConfigLoader().Namespace() | ||
| if err != nil{ | ||
| return "", fmt.Errorf("failed to get current namespace: %w", err) | ||
| } |
| flags: map[string]string{ | ||
| "namespace": "", | ||
| }, |
There was a problem hiding this comment.
Why should it add an empty namespace flag? It seems a bit of different from the description above.
Why are these changes needed?
Currently kubectl-plugin failed to respect the kubeconfig context by hardcoding the namespace value to default.
This PR uses Factory's namespace resolution in order to use namespace configured in kubeconfig.
Related issue number
Closes #4318
Checks