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

feat: add vcctl pod list #3530

Merged
merged 1 commit into from
Aug 15, 2024

Conversation

googs1025
Copy link
Member

@googs1025 googs1025 commented Jun 16, 2024

What type of PR is this?

/kind feature

New features: support list pod created by vcjob

What this PR does / why we need it:

  • Add vcctl pod command feature
    • -j, --job string list pod with specified job name
    • -k, --kubeconfig string (optional) absolute path to the kubeconfig file (default "/root/.kube/config")
    • -s, --master string the address of apiserver
    • -n, --namespace string the namespace of job (default "default")
    • --all-namespaces list jobs in all namespaces
    • -h, --help help for list
    • -q, --queue string list pod with specified queue name

Which issue(s) this PR fixes:

Fixes part of: #3495

Special notes for your reviewer:

None

Does this PR introduce a user-facing change?

Added vcctl pod command feature

How to use it:

root@VM-0-9-ubuntu:~/volcano/_output/bin# vcctl pod list -h
list pod information created by vcjob

Usage:
  vcctl pod list [flags]

root@VM-0-16-ubuntu:~/volcano/example/jobflow# vcctl pod list -h
list pod information created by vcjob

Usage:
  vcctl pod list [flags]

Flags:
      --all-namespaces      list jobs in all namespaces
  -h, --help                help for list
  -j, --job string          list pod with specified job name
  -k, --kubeconfig string   (optional) absolute path to the kubeconfig file (default "/root/.kube/config")
  -s, --master string       the address of apiserver
  -n, --namespace string    the namespace of job (default "default")
  -q, --queue string        list pod with specified queue name

Global Flags:
      --log-flush-frequency duration   Maximum number of seconds between log flushes (default 5s)
  -v, --v Level                        number for the log level verbosity
      --vmodule moduleSpec             comma-separated list of pattern=N settings for file-filtered logging (only works for the default text log format)

root@VM-0-9-ubuntu:~/volcano/_output/bin# vcctl pod list
Name                                  Ready      Status           Restart  Age
tensorflow-dist-mnist-worker-0        0/1        Completed        0        12d
tensorflow-dist-mnist-worker-1        0/1        Completed        0        12d

root@VM-0-9-ubuntu:~/volcano/_output/bin# vcctl pod list -j tensorflow-dist-mnist
Name                                  Ready      Status           Restart  Age
tensorflow-dist-mnist-worker-0        0/1        Completed        0        12d
tensorflow-dist-mnist-worker-1        0/1        Completed        0        12d

root@VM-0-9-ubuntu:~/volcano/_output/bin# vcctl pod list -j tensorflow-dist-mnist1
No resources found

root@VM-0-16-ubuntu:~/volcano/example/jobflow# vcctl pod list -q=default -j=test-a
Name                          Ready      Status         Restart  Age
test-a-default-nginx-0        1/1        Running        0        10s

root@VM-0-16-ubuntu:~/volcano/example/jobflow# vcctl pod list -q=default
Name                          Ready      Status           Restart  Age
test-a-default-nginx-0        0/1        Completed        0        47s
test-b-default-nginx-0        0/1        Completed        0        33s
test-c-default-nginx-0        0/1        Completed        0        19s
test-d-default-nginx-0        0/1        Completed        0        19s
test-e-default-nginx-0        1/1        Running          0        5s

root@VM-0-9-ubuntu:~/volcano/_output/bin# kubectl get pods
NAME                                   READY   STATUS      RESTARTS   AGE
job-pod-failure-policy-example-72jrr   0/1     Error       0          10d
kueue-sleep-jqf8t                      0/1     Completed   0          8d
kueue-sleep-sfqbd                      0/1     Completed   0          8d
network-jobset-leader-0-0-pb422        0/1     Completed   0          6d

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

None


@volcano-sh-bot volcano-sh-bot added the kind/feature Categorizes issue or PR as related to a new feature. label Jun 16, 2024
@volcano-sh-bot volcano-sh-bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Jun 16, 2024
@googs1025 googs1025 mentioned this pull request Jun 16, 2024
5 tasks
@googs1025 googs1025 force-pushed the add_vcctl_pod_command branch 2 times, most recently from 53a780d to aa25e6e Compare June 16, 2024 08:18
@googs1025
Copy link
Member Author

/assign @Monokaix

@Monokaix
Copy link
Member

Please descibe more details about what sub commands and what flags are added by this pr: )

@googs1025
Copy link
Member Author

Please descibe more details about what sub commands and what flags are added by this pr: )

done

@wuyueandrew
Copy link
Contributor

wuyueandrew commented Jun 19, 2024

Bro, Because of #3524 can not query pod assigned to queue. There are several other job type like deployment , pod needed to query by queue name. Could u plz take query pod by queue name into your consideration.

@googs1025
Copy link
Member Author

Bro, Because of #3524 can not query pod assigned to queue. There are several other job type like deployment , pod needed to query by queue name. Could u plz take query pod by queue name into your consideration.

Ok, I will add this feature

@wuyueandrew
Copy link
Contributor

Bro, Because of #3524 can not query pod assigned to queue. There are several other job type like deployment , pod needed to query by queue name. Could u plz take query pod by queue name into your consideration.

Ok, I will add this feature

thanks bro, it is very useful

@googs1025 googs1025 changed the title feat: add vcctl pod list [WIP]: feat: add vcctl pod list Jun 19, 2024
@volcano-sh-bot volcano-sh-bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 19, 2024
@googs1025 googs1025 force-pushed the add_vcctl_pod_command branch 2 times, most recently from f71319e to a724316 Compare June 19, 2024 11:44
@googs1025 googs1025 changed the title [WIP]: feat: add vcctl pod list feat: add vcctl pod list Jun 19, 2024
@volcano-sh-bot volcano-sh-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 19, 2024
@googs1025
Copy link
Member Author

Bro, Because of #3524 can not query pod assigned to queue. There are several other job type like deployment , pod needed to query by queue name. Could u plz take query pod by queue name into your consideration.

Ok, I will add this feature

thanks bro, it is very useful

already support in this pr

pkg/cli/pod/pod.go Outdated Show resolved Hide resolved
pkg/cli/pod/pod.go Outdated Show resolved Hide resolved
@googs1025 googs1025 force-pushed the add_vcctl_pod_command branch 2 times, most recently from 869b49e to 2b0633e Compare June 20, 2024 08:42
pkg/cli/pod/pod.go Outdated Show resolved Hide resolved
pkg/cli/pod/pod.go Outdated Show resolved Hide resolved
@googs1025 googs1025 changed the title [wip]feat: add vcctl pod list feat: add vcctl pod list Aug 5, 2024
@volcano-sh-bot volcano-sh-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 5, 2024
pkg/cli/pod/pod.go Outdated Show resolved Hide resolved
pkg/cli/pod/pod.go Outdated Show resolved Hide resolved
pkg/cli/pod/pod.go Outdated Show resolved Hide resolved
pkg/cli/pod/pod.go Outdated Show resolved Hide resolved
@googs1025 googs1025 force-pushed the add_vcctl_pod_command branch 4 times, most recently from 3d015f9 to 3fea772 Compare August 6, 2024 11:56
@googs1025
Copy link
Member Author

googs1025 commented Aug 6, 2024

# query by queue name
root@VM-0-14-ubuntu:~/volcano/_output/bin# vcctl pod list -q=test
Name                                       Ready      Status           Restart  Age
job-1-nginx-0                              0/1        Completed        0        32h
deploy-with-volcano-bf5784c5f-wrl4k        1/1        Running          0        26h

# query by job name and queue name
root@VM-0-14-ubuntu:~/volcano/_output/bin# vcctl pod list -q=test -j=job-1
Name                 Ready      Status           Restart  Age
job-1-nginx-0        0/1        Completed        0        32h

# query by job name and queue name, but not match
root@VM-0-14-ubuntu:~/volcano/_output/bin# vcctl pod list -q=aaaa -j=job-1
Failed to list pod: the input vcjob job-1 does not match the queue aaaa

@volcano-sh-bot volcano-sh-bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Aug 6, 2024
@googs1025 googs1025 requested a review from Monokaix August 7, 2024 00:36
var pods corev1.PodList

// filter pods based on annotationKey and annotationValue
filterByAnnotationFunc := func(pods *corev1.PodList, annotationKey, annotationValue string) *corev1.PodList {
Copy link
Member

Choose a reason for hiding this comment

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

Please extract filterByAnnotationFunc and filterByLabelFunc as a seperate func.

Copy link
Member Author

Choose a reason for hiding this comment

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

fix

pods.Items = append(pods.Items, listVcjobPodsRes.Items...)
if listPodFlags.QueueName != "" {
// if queue is specified, check if the queue name used by the pod matches with the one passed in
_, err := filterByLabelFunc(listVcjobPodsRes, v1alpha1.QueueNameKey, listPodFlags.QueueName, true)
Copy link
Member

Choose a reason for hiding this comment

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

There is no need to set a flag in filterByLabelFunc, which increased
code complexity, just compare pods.Items[0].queueName and listPodFlags.QueueName is ok.

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

}

// filterByAnnotationFunc filter pods based on annotationKey and annotationValue
func filterByAnnotationFunc(pods *corev1.PodList, annotationKey, annotationValue string) *corev1.PodList {
Copy link
Member

Choose a reason for hiding this comment

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

filterByAnnotationFunc => filterPodsByAnnotation

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

pkg/cli/pod/pod.go Outdated Show resolved Hide resolved
pkg/cli/pod/pod.go Outdated Show resolved Hide resolved
Signed-off-by: googs1025 <googs1025@gmail.com>
@@ -1,3 +1,19 @@
/*
Copyright 2024 The Volcano Authors.
Copy link
Member

Choose a reason for hiding this comment

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

It is recommended to remove the year #3668

Copy link
Member

Choose a reason for hiding this comment

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

I think we can remove year in auto generated files: )

@Monokaix
Copy link
Member

/lgtm
/approve

@volcano-sh-bot volcano-sh-bot added the lgtm Indicates that a PR is ready to be merged. label Aug 15, 2024
@volcano-sh-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Monokaix

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@volcano-sh-bot volcano-sh-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 15, 2024
@volcano-sh-bot volcano-sh-bot merged commit 1142deb into volcano-sh:master Aug 15, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. 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.

5 participants