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

oc get pods --show-all=false -o name doesn't work #9901

Closed
rhcarvalho opened this issue Jul 18, 2016 · 5 comments
Closed

oc get pods --show-all=false -o name doesn't work #9901

rhcarvalho opened this issue Jul 18, 2016 · 5 comments
Assignees
Labels
component/cli kind/bug Categorizes issue or PR as related to a bug. priority/P2

Comments

@rhcarvalho
Copy link
Contributor

The --show-all=false flag is documented as:

-a, --show-all=true: When printing, show all resources (false means hide terminated pods.)

However, when used together with --output name, all pods are listed, terminated pods are not omitted.

Upstream bug

This bug was also filled in Kubernetes: kubernetes/kubernetes#29115

Version
$ openshift version
openshift v1.3.0-alpha.2-267-g2fe486f-dirty
kubernetes v1.3.0-alpha.3-599-g2746284
etcd 2.3.0+git
$ oc version
oc v1.3.0-alpha.2-267-g2fe486f-dirty
kubernetes v1.3.0-alpha.3-599-g2746284
Steps To Reproduce
  1. In a new project, start a build like origin/examples/sample-app:

    oc new-app https://raw.githubusercontent.com/openshift/origin/master/examples/sample-app/application-template-stibuild.json
    
  2. After the build is complete and the app is deployed, you should see two pods, one in Completed state, and the other Running:

    $ oc get pods
    NAME                       READY     STATUS      RESTARTS   AGE
    ruby-hello-world-1-build   0/1       Completed   0          9d
    ruby-hello-world-1-sg623   1/1       Running     0          9d
    
Current Result

Now, the --show-all flag works with the default output, but doesn't when the output is set to name:

$ oc get pods --show-all=false
NAME                       READY     STATUS    RESTARTS   AGE
ruby-hello-world-1-sg623   1/1       Running   0          9d
$ oc get pods --show-all=false -o name
pod/ruby-hello-world-1-build
pod/ruby-hello-world-1-sg623
Expected Result
$ oc get pods --show-all=false
NAME                       READY     STATUS    RESTARTS   AGE
ruby-hello-world-1-sg623   1/1       Running   0          9d
$ oc get pods --show-all=false -o name
pod/ruby-hello-world-1-sg623
@rhcarvalho rhcarvalho added kind/bug Categorizes issue or PR as related to a bug. component/cli labels Jul 18, 2016
@juanvallejo
Copy link
Contributor

What NamePrinter currently does is take a generic runtime.Object and use meta.Accessor's GetName() method to obtain its name. Since NamePrinter does not know the specific type of resource it is dealing with, it has no way of knowing if the current runtime.Object has a status, and if it should be skipped based on that status.

A quick solution would be to have an if statement that checks to see if the current generic object being printed is of kind pod, then cast it to *api.Pod, and then access its status to determine if it should be printed.

A better solution would be to call the same handler functions that HumanReadablePrinter calls, and include a flag that tells that function to only print the resource's name.

What are your thoughts on this?

cc @fabianofranz @deads2k @liggitt @smarterclayton

@deads2k
Copy link
Contributor

deads2k commented Aug 15, 2016

A quick solution would be to have an if statement that checks to see if the current generic object being printed is of kind pod, then cast it to *api.Pod, and then access its status to determine if it should be printed.

No. Generic methods should be generic. Sounds like you should be filtering the list before calling the printer function, right?

@smarterclayton
Copy link
Contributor

Filtering should happen before printing.

On Mon, Aug 15, 2016 at 11:28 AM, David Eads notifications@github.com
wrote:

A quick solution would be to have an if statement that checks to see if
the current generic object being printed is of kind pod, then cast it to
*api.Pod, and then access its status to determine if it should be printed.

No. Generic methods should be generic. Sounds like you should be filtering
the list before calling the printer function, right?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#9901 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABG_p6FJCAvyzJuFo-o0ut3U5x4tkl8Fks5qgIWQgaJpZM4JOyGd
.

@juanvallejo
Copy link
Contributor

Thanks for the feedback. I'll filter the list of resources as they're iterated through in get.go

@smarterclayton
Copy link
Contributor

When you do that, you can also extract out the recent changes that went in
to filter hidden pods (having filtering happen before printing is much
superior). Remember though that printing needs to be generic, so you'll
likely have to have an abstraction that allows that (which means a lot more
work)

On Tue, Aug 16, 2016 at 9:23 AM, Juan Vallejo notifications@github.com
wrote:

Thanks for the feedback. I'll filter the list of resources as they're
iterated through in get.go
https://github.com/openshift/origin/blob/master/vendor/k8s.io/kubernetes/pkg/kubectl/cmd/get.go


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#9901 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABG_pxn3oBo8QOzX0oLpzgGGdlyDhxEpks5qgbm6gaJpZM4JOyGd
.

juanvallejo added a commit to juanvallejo/origin that referenced this issue Aug 19, 2016
Fixes: openshift#9901

Resources are currently filtered (in order to prevent printing) at print
time in their HumanReadablePrinter handlers. This design makes it not
possible to filter objects when they are printed using any other
printer, such as YAML, JSON, or the NamePrinter.

This patch adds a way to define resource-specific filters in order to
handle this before they are sent to a printer handler, and implements a
working filter handler for pods as an example.
juanvallejo added a commit to juanvallejo/origin that referenced this issue Aug 22, 2016
Fixes: openshift#9901

Resources are currently filtered (in order to prevent printing) at print
time in their HumanReadablePrinter handlers. This design makes it not
possible to filter objects when they are printed using any other
printer, such as YAML, JSON, or the NamePrinter.

This patch adds a way to define resource-specific filters in order to
handle this before they are sent to a printer handler, and implements a
working filter handler for pods.

Filters affect resources being printed through the HumanReadablePrinter,
YAML, JSON, and `--template` printers.
juanvallejo added a commit to juanvallejo/origin that referenced this issue Aug 22, 2016
Fixes: openshift#9901

Resources are currently filtered (in order to prevent printing) at print
time in their HumanReadablePrinter handlers. This design makes it not
possible to filter objects when they are printed using any other
printer, such as YAML, JSON, or the NamePrinter.

This patch removes any filters previously added at the printer level for
pods and adds a way to define resource-specific filters before they are
sent to a printer handler. A woking filter handler for pods has also been
implemented.

Filters affect resources being printed through the HumanReadablePrinter,
YAML, JSON, and `--template` printers.
juanvallejo added a commit to juanvallejo/origin that referenced this issue Aug 22, 2016
Fixes: openshift#9901

Resources are currently filtered (in order to prevent printing) at print
time in their HumanReadablePrinter handlers. This design makes it not
possible to filter objects when they are printed using any other
printer, such as YAML, JSON, or the NamePrinter.

This patch removes any filters previously added at the printer level for
pods and adds a way to define resource-specific filters before they are
sent to a printer handler. A woking filter handler for pods has also been
implemented.

Filters affect resources being printed through the HumanReadablePrinter,
YAML, JSON, and `--template` printers.
juanvallejo added a commit to juanvallejo/origin that referenced this issue Aug 22, 2016
Fixes: openshift#9901

Resources are currently filtered (in order to prevent printing) at print
time in their HumanReadablePrinter handlers. This design makes it not
possible to filter objects when they are printed using any other
printer, such as YAML, JSON, or the NamePrinter.

This patch removes any filters previously added at the printer level for
pods and adds a way to define resource-specific filters before they are
sent to a printer handler. A woking filter handler for pods has also been
implemented.

Filters affect resources being printed through the HumanReadablePrinter,
YAML, JSON, and `--template` printers.
juanvallejo added a commit to juanvallejo/origin that referenced this issue Sep 12, 2016
Fixes: openshift#9901

Resources are currently filtered (in order to prevent printing) at print
time in their HumanReadablePrinter handlers. This design makes it not
possible to filter objects when they are printed using any other
printer, such as YAML, JSON, or the NamePrinter.

This patch removes any filters previously added at the printer level for
pods and adds a way to define resource-specific filters before they are
sent to a printer handler. A woking filter handler for pods has also been
implemented.

Filters affect resources being printed through the HumanReadablePrinter,
YAML, JSON, and `--template` printers.
juanvallejo added a commit to juanvallejo/origin that referenced this issue Sep 12, 2016
UPSTREAM: kubernetes/kubernetes#31163
Fixes: openshift#9901

Resources are currently filtered (in order to prevent printing) at print
time in their HumanReadablePrinter handlers. This design makes it not
possible to filter objects when they are printed using any other
printer, such as YAML, JSON, or the NamePrinter.

This patch removes any filters previously added at the printer level for
pods and adds a way to define resource-specific filters before they are
sent to a printer handler. A woking filter handler for pods has also been
implemented.

Filters affect resources being printed through the HumanReadablePrinter,
YAML, JSON, and `--template` printers.
juanvallejo added a commit to juanvallejo/origin that referenced this issue Sep 12, 2016
UPSTREAM: kubernetes/kubernetes#31163
Fixes: openshift#9901

Resources are currently filtered (in order to prevent printing) at print
time in their HumanReadablePrinter handlers. This design makes it not
possible to filter objects when they are printed using any other
printer, such as YAML, JSON, or the NamePrinter.

This patch removes any filters previously added at the printer level for
pods and adds a way to define resource-specific filters before they are
sent to a printer handler. A woking filter handler for pods has also been
implemented.

Filters affect resources being printed through the HumanReadablePrinter,
YAML, JSON, and `--template` printers.
juanvallejo added a commit to juanvallejo/origin that referenced this issue Sep 12, 2016
UPSTREAM: kubernetes/kubernetes#31163
Fixes: openshift#9901

Resources are currently filtered (in order to prevent printing) at print
time in their HumanReadablePrinter handlers. This design makes it not
possible to filter objects when they are printed using any other
printer, such as YAML, JSON, or the NamePrinter.

This patch removes any filters previously added at the printer level for
pods and adds a way to define resource-specific filters before they are
sent to a printer handler. A woking filter handler for pods has also been
implemented.

Filters affect resources being printed through the HumanReadablePrinter,
YAML, JSON, and `--template` printers.
juanvallejo added a commit to juanvallejo/origin that referenced this issue Sep 13, 2016
UPSTREAM: kubernetes/kubernetes#31163
Fixes: openshift#9901

Resources are currently filtered (in order to prevent printing) at print
time in their HumanReadablePrinter handlers. This design makes it not
possible to filter objects when they are printed using any other
printer, such as YAML, JSON, or the NamePrinter.

This patch removes any filters previously added at the printer level for
pods and adds a way to define resource-specific filters before they are
sent to a printer handler. A woking filter handler for pods has also been
implemented.

Filters affect resources being printed through the HumanReadablePrinter,
YAML, JSON, and `--template` printers.
juanvallejo added a commit to juanvallejo/origin that referenced this issue Sep 19, 2016
UPSTREAM: kubernetes/kubernetes#31163
Fixes openshift#9901

Resources are currently filtered (in order to prevent printing) at print
time in their HumanReadablePrinter handlers. This design makes it not
possible to filter objects when they are printed using any other
printer, such as YAML, JSON, or the NamePrinter.

This patch removes any filters previously added at the printer level for
pods and adds a way to define resource-specific filters before they are
sent to a printer handler. A woking filter handler for pods has also
been
implemented.

Filters affect resources being printed through the HumanReadablePrinter,
YAML, JSON, and `--template` printers.
juanvallejo added a commit to juanvallejo/origin that referenced this issue Sep 20, 2016
UPSTREAM: kubernetes/kubernetes#31163
Fixes openshift#9901

Resources are currently filtered (in order to prevent printing) at print
time in their HumanReadablePrinter handlers. This design makes it not
possible to filter objects when they are printed using any other
printer, such as YAML, JSON, or the NamePrinter.

This patch removes any filters previously added at the printer level for
pods and adds a way to define resource-specific filters before they are
sent to a printer handler. A woking filter handler for pods has also
been
implemented.

Filters affect resources being printed through the HumanReadablePrinter,
YAML, JSON, and `--template` printers.
juanvallejo added a commit to juanvallejo/origin that referenced this issue Sep 23, 2016
UPSTREAM: kubernetes/kubernetes#31163
Fixes openshift#9901

Resources are currently filtered (in order to prevent printing) at print
time in their HumanReadablePrinter handlers. This design makes it not
possible to filter objects when they are printed using any other
printer, such as YAML, JSON, or the NamePrinter.

This patch removes any filters previously added at the printer level for
pods and adds a way to define resource-specific filters before they are
sent to a printer handler. A woking filter handler for pods has also
been
implemented.

Filters affect resources being printed through the HumanReadablePrinter,
YAML, JSON, and `--template` printers.
smarterclayton pushed a commit to smarterclayton/kubernetes that referenced this issue Sep 26, 2016
UPSTREAM: kubernetes#31163
Fixes openshift/origin#9901

Resources are currently filtered (in order to prevent printing) at print
time in their HumanReadablePrinter handlers. This design makes it not
possible to filter objects when they are printed using any other
printer, such as YAML, JSON, or the NamePrinter.

This patch removes any filters previously added at the printer level for
pods and adds a way to define resource-specific filters before they are
sent to a printer handler. A woking filter handler for pods has also
been
implemented.

Filters affect resources being printed through the HumanReadablePrinter,
YAML, JSON, and `--template` printers.

:100644 100644 cf7d1af... 185d31b... M	pkg/kubectl/cmd/cmd_test.go
:100644 100644 6551226... 99d7838... M	pkg/kubectl/cmd/get.go
:100644 100644 49ffb4d... 72d6c0f... M	pkg/kubectl/cmd/util/factory.go
:100644 100644 adc82b6... e42e819... M	pkg/kubectl/cmd/util/helpers.go
:100644 100644 892b30e... 78f11e4... M	pkg/kubectl/resource/result.go
:000000 100644 0000000... 8ca31d8... A	pkg/kubectl/resource_filter.go
:100644 100644 5af291e... 0b07610... M	pkg/kubectl/resource_printer.go
:100644 100644 2f341ac... cc04248... M	pkg/kubectl/resource_printer_test.go
smarterclayton pushed a commit to smarterclayton/kubernetes that referenced this issue Oct 25, 2016
UPSTREAM: kubernetes#31163
Fixes openshift/origin#9901

Resources are currently filtered (in order to prevent printing) at print
time in their HumanReadablePrinter handlers. This design makes it not
possible to filter objects when they are printed using any other
printer, such as YAML, JSON, or the NamePrinter.

This patch removes any filters previously added at the printer level for
pods and adds a way to define resource-specific filters before they are
sent to a printer handler. A woking filter handler for pods has also
been
implemented.

Filters affect resources being printed through the HumanReadablePrinter,
YAML, JSON, and `--template` printers.

:100644 100644 cf7d1af... 185d31b... M	pkg/kubectl/cmd/cmd_test.go
:100644 100644 6551226... 99d7838... M	pkg/kubectl/cmd/get.go
:100644 100644 49ffb4d... 72d6c0f... M	pkg/kubectl/cmd/util/factory.go
:100644 100644 adc82b6... e42e819... M	pkg/kubectl/cmd/util/helpers.go
:100644 100644 892b30e... 78f11e4... M	pkg/kubectl/resource/result.go
:000000 100644 0000000... 8ca31d8... A	pkg/kubectl/resource_filter.go
:100644 100644 5af291e... 0b07610... M	pkg/kubectl/resource_printer.go
:100644 100644 2f341ac... cc04248... M	pkg/kubectl/resource_printer_test.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/cli kind/bug Categorizes issue or PR as related to a bug. priority/P2
Projects
None yet
Development

No branches or pull requests

6 participants