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

Age printer column is no more reported when adding additional ones #903

Closed
prometherion opened this issue Aug 5, 2020 · 4 comments
Closed
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@prometherion
Copy link

prometherion commented Aug 5, 2020

What happened:

I'm developing some Custom Resource Definitions (CRDs) and noticed the missing of the column AGE when getting the resources from the CLI.

# kubectl get tenants.capsule.clastix.io
NAME   NAMESPACE QUOTA   NAMESPACE COUNT
oil    3                 1

The reason is that I'm implementing some additional columns using the .spec.additionalPrinterColumns array provided by CustomResourceDefinition Kind (apiextensions.k8s.io/v1beta1).

spec:
  additionalPrinterColumns:
  - JSONPath: .spec.namespaceQuota
    description: The max amount of Namespaces can be created
    name: Namespace quota
    type: integer
  - JSONPath: .status.size
    description: The total amount of Namespaces in use
    name: Namespace count
    type: integer

When I remove these two additional columns, the AGE is printed back correctly.

# kubectl get tenants.capsule.clastix.io
NAME   AGE
oil    117m

I'm not sure if this is a problem from kubectl or rather the API Server perspective.

What you expected to happen:

Although adding additional printer columns, I'm expecting to get AGE as usual.

How to reproduce it (as minimally and precisely as possible):

Try to install the following CRD and applying a sample definition.

Getting the tenants.capsule.clastix.io from kubectl will not report the AGE.

Anything else we need to know?:

Not relevant.

Environment:

  • Kubernetes client and server versions (use kubectl version):
Client Version: version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.4", GitCommit:"224be7bdce5a9dd0c2fd0d46b83865648e2fe0ba", GitTreeState:"clean", BuildDate:"2019-12-11T12:47:40Z", GoVersion:"go1.12.12", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.2", GitCommit:"52c56ce7a8272c798dbc29846288d7cd9fbae032", GitTreeState:"clean", BuildDate:"2020-04-30T20:19:45Z", GoVersion:"go1.13.9", Compiler:"gc", Platform:"linux/amd64"}
  • Cloud provider or hardware configuration: KinD (Kubernetes in Docker)
  • OS (e.g: cat /etc/os-release):
NAME=Fedora
VERSION="30 (Workstation Edition)"
ID=fedora
VERSION_ID=30
VERSION_CODENAME=""
PLATFORM_ID="platform:f30"
PRETTY_NAME="Fedora 30 (Workstation Edition)"
ANSI_COLOR="0;34"
LOGO=fedora-logo-icon
CPE_NAME="cpe:/o:fedoraproject:fedora:30"
HOME_URL="https://fedoraproject.org/"
DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora/f30/system-administrators-guide/"
SUPPORT_URL="https://fedoraproject.org/wiki/Communicating_and_getting_help"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_BUGZILLA_PRODUCT="Fedora"
REDHAT_BUGZILLA_PRODUCT_VERSION=30
REDHAT_SUPPORT_PRODUCT="Fedora"
REDHAT_SUPPORT_PRODUCT_VERSION=30
PRIVACY_POLICY_URL="https://fedoraproject.org/wiki/Legal:PrivacyPolicy"
VARIANT="Workstation Edition"
VARIANT_ID=workstation
@brianpursley
Copy link
Member

brianpursley commented Aug 5, 2020

It looks like Age is added as a default if you haven't defined any additionalPrinterColumns. You should be able to add it yourself if you want to include it for your CRD.

What if you you do something like this?

spec:
  additionalPrinterColumns:
  - JSONPath: .spec.namespaceQuota
    description: The max amount of Namespaces can be created
    name: Namespace quota
    type: integer
  - JSONPath: .status.size
    description: The total amount of Namespaces in use
    name: Namespace count
    type: integer
  - JSONPath: .metadata.creationTimestamp
    description: The age of this resource
    name: Age
    type: date

@prometherion
Copy link
Author

Thanks for the hint, pretty sure I'll fix in this way.

My issue reporting was more involved into raising the topic to understand if this is a sort of bug or rather a default behavior, since I wasn't able to figure out this from the docs or any other knowledge source.

I know there are some Kubernetes resources that doesn't provide an age like Component Status and it looks weird to me that kubectl (or API Server, still didn't figure out who's the real actor involved here) is providing that field as default.

What do you think about this?

@brianpursley
Copy link
Member

This came up at the monthly bug scrub meeting today.

The consensus was that how it works currently is the desired behavior.

To recap the behavior:

  1. You always get NAME no matter what, and it is always first.
  2. If you DON'T specify additionalPrinterColumns in your spec, then you get the default which is the AGE column.
  3. If you DO specify additionalPrinterColumns in your spec, then you no longer get the default column (AGE) and you get the columns you specify instead.

This provides the most flexibility because you can decide whether you want to include AGE in the output (by explicitly including it), or if you don't want to include it.

Given the above explanation and per the discussion at the bug scrub meeting, I will close this issue.

/close

@k8s-ci-robot
Copy link
Contributor

@brianpursley: Closing this issue.

In response to this:

This came up at the monthly bug scrub meeting today.

The consensus was that how it works currently is the desired behavior.

To recap the behavior:

  1. You always get NAME no matter what, and it is always first.
  2. If you DON'T specify additionalPrinterColumns in your spec, then you get the default which is the AGE column.
  3. If you DO specify additionalPrinterColumns in your spec, then you no longer get the default column (AGE) and you get the columns you specify instead.

This provides the most flexibility because you can decide whether you want to include AGE in the output (by explicitly including it), or if you don't want to include it.

Given the above explanation and per the discussion at the bug scrub meeting, I will close this issue.

/close

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/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

No branches or pull requests

3 participants