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

Added warning msg for kubectl get #28352

Merged
merged 1 commit into from
Aug 17, 2016

Conversation

vefimova
Copy link
Contributor

@vefimova vefimova commented Jul 1, 2016

  • added warning description regarding terminated pods to get long help message
  • added printing of warning message in case of get pods if there are hidden pods

Fixes #22986 (initiall PR and discussion are here #26417)

Output examples:

# kubectl get pods

NAME                       READY     STATUS             RESTARTS   AGE
dapi-test-pod1             0/1       Terminating        0          22h
liveness-http              0/1       CrashLoopBackOff   11245      22d
ubuntu1-1206318548-oh9tc   0/1       CrashLoopBackOff   2336       8d
  info: 1 completed object(s) was(were) not shown in pods list. Pass --show-all to see all objects.

# kubectl get pods,namespaces

NAME                          READY     STATUS             RESTARTS   AGE
po/dapi-test-pod1             0/1       Terminating        0          22h
po/liveness-http              1/1       Running            11242      22d
po/ubuntu1-1206318548-oh9tc   0/1       CrashLoopBackOff   2335       8d
 info: 1 completed object(s) was(were) not shown in pods list. Pass --show-all to see all objects.

NAME             STATUS    AGE
ns/default       Active    89d
ns/kube-system   Active    41d

# kubectl get pods -a

NAME                       READY     STATUS             RESTARTS   AGE
busybox                    0/1       Error              0          27d
dapi-test-pod1             0/1       Terminating        0          22h
liveness-http              0/1       CrashLoopBackOff   11245      22d
ubuntu1-1206318548-oh9tc   0/1       CrashLoopBackOff   2336       8d

# kubectl get -h

Display one or many resources.

Possible resource types include (case insensitive): pods (aka 'po'), services (aka 'svc'), deployments (aka 'deploy'),
replicasets (aka 'rs'), replicationcontrollers (aka 'rc'), nodes (aka 'no'), events (aka 'ev'), limitranges (aka 'limits'),
persistentvolumes (aka 'pv'), persistentvolumeclaims (aka 'pvc'), resourcequotas (aka 'quota'), namespaces (aka 'ns'),
serviceaccounts (aka 'sa'), ingresses (aka 'ing'), horizontalpodautoscalers (aka 'hpa'), daemonsets (aka 'ds'), configmaps (aka 'cm'),
componentstatuses (aka 'cs), endpoints (aka 'ep'), petsets (alpha feature, may be unstable) and secrets.

This command will hide resources that have completed. For instance, pods that are in the Succeeded or Failed phases.
You can see the full results for any resource by providing the '--show-all' flag.

By specifying the output as 'template' and providing a Go template as the value
of the --template flag, you can filter the attributes of the fetched resource(s).

Examples:

.........

This change is Reviewable

@@ -30,6 +30,11 @@ import (

const (
kubectlAnnotationPrefix = "kubectl.kubernetes.io/"
Warn = `
Copy link
Contributor

Choose a reason for hiding this comment

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

Give this a more meaningful name, e.g. HiddenPodsWarning.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 1, 2016
@smarterclayton
Copy link
Contributor

I would like to review this as well, but will not have time until Monday.

handlerMap map[reflect.Type]*handlerEntry
options PrintOptions
lastType reflect.Type
hiddenPodsNum int
Copy link
Member

Choose a reason for hiding this comment

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

We need to do something similar for replicasets in #27510 and we might need it again for other objects. Can you change the field name to something more generic like hiddenEntryNum, hiddenObjNum, hiddenCount or similar? That way, we can reuse the code and logic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added changes for reuse the same var hiddenObjNum for all objects and valid printing in case of user getting several resource types at once: kubectl get pods,namespaces (added output example in PR description)

Copy link
Member

Choose a reason for hiding this comment

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

Thank you so much!

@k8s-github-robot k8s-github-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 4, 2016
@k8s-github-robot k8s-github-robot removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. kind/design Categorizes issue or PR as related to design. labels Jul 13, 2016
@k8s-github-robot k8s-github-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 Aug 2, 2016
@smarterclayton
Copy link
Contributor

Looks better, will review.

@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 5, 2016
@j3ffml j3ffml added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-label-needed labels Aug 9, 2016
@j3ffml
Copy link
Contributor

j3ffml commented Aug 10, 2016

@smarterclayton still planning to review this?

@@ -30,6 +30,11 @@ import (

const (
kubectlAnnotationPrefix = "kubectl.kubernetes.io/"
HiddenPodsWarning = `
WARN: By default only active pods are displayed, to display terminated
Copy link
Contributor

@smarterclayton smarterclayton Aug 11, 2016

Choose a reason for hiding this comment

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

This message needs to be more generic, and doesn't need the warning prefix. It really belongs directly inside of the get comment.

This command will hide resources that have completed. For instance, pods that are in the Succeeded or Failed phases. You can see the full results for any resource by providing the `--show-all` flag.

Should be a separate paragraph and in get.go in the help text.

Copy link
Contributor

@smarterclayton smarterclayton Aug 11, 2016

Choose a reason for hiding this comment

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

A separate warning can remain here, but I would recommend making it shorter:

Edit: provided a clearer message below for the actual inline output.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 12, 2016
@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 12, 2016
  - added warning description regarding terminated objects to `get` long help message
  - added printing of warning message in case of `get pods` if there are hidden pods
Fixes kubernetes#22986
@vefimova
Copy link
Contributor Author

@jlowdermilk @smarterclayton

So guys, WDYT is patch ready to be merged?

@smarterclayton
Copy link
Contributor

LGTM

@smarterclayton smarterclayton added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 16, 2016
@k8s-bot
Copy link

k8s-bot commented Aug 17, 2016

GCE e2e build/test passed for commit f20c40e.

@k8s-github-robot
Copy link

Automatic merge from submit-queue

@k8s-github-robot k8s-github-robot merged commit aedeccd into kubernetes:master Aug 17, 2016
@smarterclayton
Copy link
Contributor

As a future note I recommended to someone else with a similar problem that the next change to this code should hoist filtering up as a generic tool that happens before printing. That will make this more resilient to future change

@therc
Copy link
Member

therc commented Aug 17, 2016

That would be me for get rs.

@adohe-zz
Copy link

adohe-zz commented Sep 5, 2016

@smarterclayton I think you mean this #29115, actually I am planning this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants