Skip to content
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

[kueuectl] Added kueuectl list pods command #2280

Open
wants to merge 28 commits into
base: main
Choose a base branch
from

Conversation

Kavinraja-G
Copy link
Contributor

@Kavinraja-G Kavinraja-G commented May 25, 2024

What type of PR is this?

/kind feature

What this PR does / why we need it:

Adds kueuectl list pods --for job/job-name. This will help users to list all the pods controlled by a specific Job in a namespace.

Which issue(s) this PR fixes:

Fixes #2204

Special notes for your reviewer:

Nil

Does this PR introduce a user-facing change?

Adds kueuectl list pods --for job/job-name

@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. release-note Denotes a PR that will be considered when it comes time to generate release notes. labels May 25, 2024
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label May 25, 2024
@k8s-ci-robot
Copy link
Contributor

Welcome @Kavinraja-G!

It looks like this is your first PR to kubernetes-sigs/kueue 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/kueue has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label May 25, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @Kavinraja-G. 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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

@k8s-ci-robot k8s-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label May 25, 2024
Copy link

netlify bot commented May 25, 2024

Deploy Preview for kubernetes-sigs-kueue canceled.

Name Link
🔨 Latest commit ded5836
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-kueue/deploys/66937530993b7c0008cad536

Copy link
Contributor

@mbobrovskyi mbobrovskyi left a comment

Choose a reason for hiding this comment

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

Don't forget to add docs here.

cmd/kueuectl/app/list/helpers.go Outdated Show resolved Hide resolved
cmd/kueuectl/app/list/list_pods.go Outdated Show resolved Hide resolved
cmd/kueuectl/app/list/list_pods.go Outdated Show resolved Hide resolved
cmd/kueuectl/app/list/list_pods.go Outdated Show resolved Hide resolved
cmd/kueuectl/app/list/list_pods_test.go Outdated Show resolved Hide resolved
cmd/kueuectl/app/list/list_pods_test.go Outdated Show resolved Hide resolved
cmd/kueuectl/app/list/list_pods_test.go Show resolved Hide resolved
@mbobrovskyi
Copy link
Contributor

/assign

@mbobrovskyi
Copy link
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels May 27, 2024
@k8s-ci-robot k8s-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels May 28, 2024
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 28, 2024
cmd/kueuectl/app/list/list_pods.go Outdated Show resolved Hide resolved
cmd/kueuectl/app/list/list_pods.go Outdated Show resolved Hide resolved
cmd/kueuectl/app/list/list_pods.go Outdated Show resolved Hide resolved
cmd/kueuectl/app/list/list_pods_test.go Outdated Show resolved Hide resolved
@mbobrovskyi
Copy link
Contributor

/test pull-kueue-test-e2e-main-1-27

@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 28, 2024
cmd/kueuectl/app/testing/fake.go Outdated Show resolved Hide resolved
cmd/kueuectl/app/list/list_pods.go Outdated Show resolved Hide resolved
cmd/kueuectl/app/list/list_pods.go Outdated Show resolved Hide resolved
@@ -41,6 +41,11 @@ func NewTestClientGetter() *TestClientGetter {
}
}

func (f *TestClientGetter) WithRestMapper(mapper meta.RESTMapper) *TestClientGetter {
Copy link
Contributor

Choose a reason for hiding this comment

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

We already have WithRESTMapper.

Comment on lines +314 to +316
if len(o.LabelSelector) != 0 {
o.PodLabelSelector = "," + o.PodLabelSelector
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if len(o.LabelSelector) != 0 {
o.PodLabelSelector = "," + o.PodLabelSelector
}
podLabelSelector := o.PodLabelSelector
if len(o.LabelSelector) != 0 {
podLabelSelector = "," + o.PodLabelSelector
}

FieldSelectorParam(o.FieldSelector).
LabelSelectorParam(o.LabelSelector+o.PodLabelSelector).
ResourceTypeOrNameArgs(true, "pods").
ContinueOnError().
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
ContinueOnError().
ContinueOnError().
RequestChunksOf(o.Limit).

func (o *PodOptions) transformRequests(req *rest.Request) {
req.SetHeader("Accept", strings.Join([]string{
fmt.Sprintf("application/json;as=Table;v=%s;g=%s", metav1.SchemeGroupVersion.Version, metav1.GroupName),
fmt.Sprintf("application/json;as=Table;v=%s;g=%s", metav1beta1.SchemeGroupVersion.Version, metav1beta1.GroupName),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
fmt.Sprintf("application/json;as=Table;v=%s;g=%s", metav1beta1.SchemeGroupVersion.Version, metav1beta1.GroupName),

Do we need it?

Comment on lines +117 to +122
Run: func(cmd *cobra.Command, args []string) {
cobra.CheckErr(o.Complete(clientGetter))
if o.ForObject != nil {
cobra.CheckErr(o.Run(cmd.Context(), clientGetter))
}
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Run: func(cmd *cobra.Command, args []string) {
cobra.CheckErr(o.Complete(clientGetter))
if o.ForObject != nil {
cobra.CheckErr(o.Run(cmd.Context(), clientGetter))
}
},
RunE: func(cmd *cobra.Command, args []string) error {
cmd.SilenceUsage = true
err := o.Complete(clientGetter)
if err != nil {
return err
}
if o.ForObject == nil {
return nil
}
return o.Run(clientGetter)
},

We already fixed another commands #2578.

Comment on lines +56 to +57
belonging to the specified namespace, matching
the label selector or the field selector.`
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
belonging to the specified namespace, matching
the label selector or the field selector.`
belonging to the specified namespace, matching
the label selector or the field selector.`

To do not add tabs on --help.

}

// fetchDynamicResourceInfos builds and executes a dynamic client query for a resource specified in --for
func (o *PodOptions) fetchDynamicResourceInfos(clientGetter util.ClientGetter) ([]*resource.Info, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe...

Suggested change
func (o *PodOptions) fetchDynamicResourceInfos(clientGetter util.ClientGetter) ([]*resource.Info, error) {
func (o *PodOptions) getForObjectInfos(clientGetter util.ClientGetter) ([]*resource.Info, error) {

}

// getPodsUsingAPI gets the pods raw infos directly from the API server
func (o *PodOptions) getPodsUsingAPI(clientGetter util.ClientGetter) ([]*resource.Info, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

And...

Suggested change
func (o *PodOptions) getPodsUsingAPI(clientGetter util.ClientGetter) ([]*resource.Info, error) {
func (o *PodOptions) getPodsInfos(clientGetter util.ClientGetter) ([]*resource.Info, error) {

Comment on lines +978 to +980
clientset := k8sfake.NewSimpleClientset()
tf.K8sClientset = clientset
tf.K8sClientset.Discovery().(*fakediscovery.FakeDiscovery).Resources = tc.apiResourceLists
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
clientset := k8sfake.NewSimpleClientset()
tf.K8sClientset = clientset
tf.K8sClientset.Discovery().(*fakediscovery.FakeDiscovery).Resources = tc.apiResourceLists

Looks like we don't need it more?

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you also add test case for pod groups?

@k8s-ci-robot k8s-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jul 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

kueuectl: list pods for a job
6 participants