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

Implement a stub server printer for CRDs #60269

Merged
merged 1 commit into from Feb 25, 2018

Conversation

smarterclayton
Copy link
Contributor

@smarterclayton smarterclayton commented Feb 23, 2018

This wires up TableConvertor to CRDs and puts a basic implementation in place for custom paths. However, since our OpenAPISchema can't store OpenAPI extension fields there is no way to expose the custom column piece that get.go supports today (x-kubernetes-print-columns). That piece can be implemented separately and needs discussion.

As this is purely exposing the default interface, very low risk. Will add an e2e test that covers this under a registered CRD.

@soltysh @sttts @kubernetes/sig-api-machinery-pr-reviews

A couple of options for wiring up the actual definition:

  1. add a new "extensions" map to spec.validation
    1. Downside: won't handle future child nested fields, not the correct schema
  2. try to change the OpenAPISchema3 field to support extensions
    1. Would require a breaking protobuf change, is also very difficult
    2. Could store the entire schema as opaque JSON and then parse on load (might be the right thing anyway)
  3. Support this as an annotation in 1.11 - alpha.customresource.k8s.io/x-kubernetes-print-columns like the CLI

Part of #58536

@k8s-ci-robot
Copy link
Contributor

@smarterclayton: Adding do-not-merge/release-note-label-needed because the release note process has not been followed.

One of the following labels is required "release-note", "release-note-action-required", or "release-note-none".
Please see: https://git.k8s.io/community/contributors/devel/pull-requests.md#write-release-notes-if-needed.

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.

@k8s-ci-robot k8s-ci-robot added sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Feb 23, 2018
@smarterclayton smarterclayton force-pushed the crd_printing branch 2 times, most recently from 61b7806 to b336053 Compare February 23, 2018 04:32
@smarterclayton smarterclayton added release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Feb 23, 2018
@smarterclayton
Copy link
Contributor Author

Given how late we are, and the limitations in existing CRD, i think we'll need to punt custom columns to 1.11. However, this PR enables the default columns so I'd like to get it in (there's no complexity in the core path)

@smarterclayton
Copy link
Contributor Author

@sttts @soltysh @kubernetes/sig-api-machinery-pr-reviews equivalent to #60219

@k8s-ci-robot
Copy link
Contributor

@smarterclayton: Adding do-not-merge/release-note-label-needed because the release note process has not been followed.

One of the following labels is required "release-note", "release-note-action-required", or "release-note-none".
Please see: https://git.k8s.io/community/contributors/devel/pull-requests.md#write-release-notes-if-needed.

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.

@k8s-ci-robot k8s-ci-robot added do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Feb 23, 2018
@smarterclayton smarterclayton added release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Feb 23, 2018
Copy link
Contributor

@soltysh soltysh left a comment

Choose a reason for hiding this comment

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

lgtm

@@ -447,6 +448,11 @@ func (r *crdHandler) getOrCreateServingInfoFor(crd *apiextensions.CustomResource
scaleSpec = crd.Spec.Subresources.Scale
}

table, err := tableconvertor.New(nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

// TODO: replace the nil with the actual extensions when we support them in OpenAPI validation specs.

@@ -71,6 +72,8 @@ func newStorage(t *testing.T) (customresource.CustomResourceStorage, *etcdtestin

status := &apiextensions.CustomResourceSubresourceStatus{}

table, _ := tableconvertor.New(nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

// TODO: .... as above.

cells[1] = age
for _, column := range c.columns {
if err := column.Execute(buf, obj); err != nil {
cells = append(cells, nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

should be distinguish between not found paths and unprintable data?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Possibly. I think of the current annotation from OpenAPI is underspecified and a bit of a quick hack, so some more thought is deserved for all of this. I was going to propose a 1.11 design extension that covered more of the edge cases - I think given server side printing depends on the CRD, not just OpenAPI, we can do a better job of making this useful. The design goal of CRD is to invert the API model and make clients able to usefully function against a dumb api server, so a better definition (server side smarts) seems logical.

Add the plumbing for server side printing. Not connected until we
support a way to get OpenAPI extensions from CRDs.
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 24, 2018
Copy link
Contributor

@soltysh soltysh left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: smarterclayton, soltysh

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

@smarterclayton
Copy link
Contributor Author

/retest

@smarterclayton
Copy link
Contributor Author

/retest

might be related, although the stack output doesn't help

@k8s-ci-robot
Copy link
Contributor

k8s-ci-robot commented Feb 24, 2018

@smarterclayton: The following test failed, say /retest to rerun them all:

Test name Commit Details Rerun command
pull-kubernetes-cross 61b7806cb9f9af16dcf345de6bb129207953e34f link /test pull-kubernetes-cross

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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. I understand the commands that are listed here.

@smarterclayton
Copy link
Contributor Author

/retest

weird, passes locally

@k8s-github-robot
Copy link

/test all [submit-queue is verifying that this PR is safe to merge]

@k8s-github-robot
Copy link

Automatic merge from submit-queue (batch tested with PRs 60324, 60269, 59771, 60314, 59941). If you want to cherry-pick this change to another branch, please follow the instructions here.

@k8s-github-robot k8s-github-robot merged commit 0f9b5e9 into kubernetes:master Feb 25, 2018
@mbohlool
Copy link
Contributor

mbohlool commented Mar 1, 2018

/sub

@sttts
Copy link
Contributor

sttts commented Mar 9, 2018

From Slack:

Stefan Schimanski [18:16] @claytonc which kinds of fields do we have to support? I guess simple json paths .word.word style are enough.
claytonc [18:16]i think anything more complex than that will have problems
we might want to gather feedback
from actual CRDs
like tectonic

Stefan Schimanski [18:17] @claytonc what I don't like about openapi x-kubectl-column style extensions is that with quantors this becomes ambiguous easily
allOf: [someSchemaWithColumns, anotherSchemaWithColumns]
a flat json path list spec.validation sounds more reasonable

claytonc [18:18] i don’t like x-kubectl-columns for a lot of reasons
but yes

@sttts
Copy link
Contributor

sttts commented Mar 9, 2018

@brancz can you comment on your requirements for columns?

@brancz
Copy link
Member

brancz commented Mar 10, 2018

For us simple json paths would definitely suffice for tables/columns.

k8s-github-robot pushed a commit that referenced this pull request May 28, 2018
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

apiextensions-apiserver: add columns to CRD spec

Follow-up of #60269.

```release-note
Add spec. additionalPrinterColumns to CRDs to define server side printing columns.
```
k8s-publishing-bot added a commit to kubernetes/apimachinery that referenced this pull request May 28, 2018
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

apiextensions-apiserver: add columns to CRD spec

Follow-up of kubernetes/kubernetes#60269.

```release-note
Add spec. additionalPrinterColumns to CRDs to define server side printing columns.
```

Kubernetes-commit: 34383aa0a49ab916d74ea897cebc79ce0acfc9dd
k8s-publishing-bot added a commit to kubernetes/apiserver that referenced this pull request Jun 1, 2018
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

apiextensions-apiserver: add columns to CRD spec

Follow-up of kubernetes/kubernetes#60269.

```release-note
Add spec. additionalPrinterColumns to CRDs to define server side printing columns.
```

Kubernetes-commit: 34383aa0a49ab916d74ea897cebc79ce0acfc9dd
k8s-publishing-bot added a commit to kubernetes/apiextensions-apiserver that referenced this pull request Jun 1, 2018
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

apiextensions-apiserver: add columns to CRD spec

Follow-up of kubernetes/kubernetes#60269.

```release-note
Add spec. additionalPrinterColumns to CRDs to define server side printing columns.
```

Kubernetes-commit: 34383aa0a49ab916d74ea897cebc79ce0acfc9dd
akhilerm pushed a commit to akhilerm/apimachinery that referenced this pull request Sep 20, 2022
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

apiextensions-apiserver: add columns to CRD spec

Follow-up of kubernetes/kubernetes#60269.

```release-note
Add spec. additionalPrinterColumns to CRDs to define server side printing columns.
```

Kubernetes-commit: 34383aa0a49ab916d74ea897cebc79ce0acfc9dd
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. 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. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note-none Denotes a PR that doesn't merit a release note. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. 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.

None yet

8 participants