Skip to content

[kubeclt-plugin] fix get cluster all namespace #3809

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

Merged

Conversation

fscnick
Copy link
Contributor

@fscnick fscnick commented Jun 19, 2025

Why are these changes needed?

Either --all-namespaces is true or false on kubectl ray get cluster, it shows RayClusters in all namespaces. This pr changes the behavior to search the default namespace if --all-namespaces is false.

get-cluster-namespace

However, the original behavior seems intentionally. There are some test cases to ensure this behavior. But the original behavior isn't consistent with get node and get workergroup. Additionally, it doesn't align the convention like kubectl get po which only retrieves the resources from the default namespace instead of all namespaces. Kind correct me if the original behavior is expected.

Related issue number

Closes #3806

Checks

  • I've made sure the tests are passing.
  • Testing Strategy
    • Unit tests
    • Manual tests
    • This PR is not tested :(

}
if tc.namespace != nil {
fakeClusterGetOptions.namespace = *tc.namespace
}

kubeClientSet := kubefake.NewClientset()
rayClient := rayClientFake.NewSimpleClientset(tc.rayClusters...)
rayClient := rayClientFake.NewSimpleClientset(tc.injectedRayClusters...)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original code takes tc.rayClusters to inject to fake client and tc.rayClusters also be a condition to verify the result. That seems put what you expected and verify it. It might lack the capability of testing exclusion. Thus, add tc.injectedRayClusters to provide this possibility.

@@ -42,7 +42,7 @@ func TestRayClusterGetComplete(t *testing.T) {
name: "neither namespace nor args set",
namespace: "",
args: []string{},
expectedAllNamespaces: true,
expectedAllNamespaces: false,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original test case looks like the all namespace is expected if no namespace provide. However, it is not consistent with get nodes and get workergroup

@fscnick fscnick marked this pull request as ready for review June 19, 2025 18:09
@fscnick
Copy link
Contributor Author

fscnick commented Jun 19, 2025

@MortalHappiness PTAL

expectedOutput string
cluster string
expectedRayClusters []runtime.Object
injectedRayClusters []runtime.Object
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
injectedRayClusters []runtime.Object
allFakeRayClusters []runtime.Object

@kevin85421 kevin85421 merged commit 46b5b3e into ray-project:master Jun 20, 2025
25 checks passed
MortalHappiness pushed a commit to MortalHappiness/kuberay that referenced this pull request Jun 20, 2025
MortalHappiness added a commit that referenced this pull request Jun 20, 2025
@fscnick fscnick deleted the plugin-get-cluster-all-namespaces-issue branch June 20, 2025 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] kubectl-plugin get cluster without all-namespace still shows all-namespace.
3 participants