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

Show openapi custom columns in kubectl get #53483

Merged
merged 2 commits into from
Nov 18, 2017

Conversation

apelisse
Copy link
Member

@apelisse apelisse commented Oct 5, 2017

Change the name of the flag to something slightly more user-friendly,
while making it default true. The flag is kept so that someone can
revert it temporarly if things go wrong.

What this PR does / why we need it: OpenAPI can specify for some columns to be used in kubectl get. That's very useful for non-core/hard-coded type in order to print more valuable data in get.

Which issue this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged): fixes #

Special notes for your reviewer:

Closes kubernetes/kubectl#143

Release note:

`kubectl get` will now use OpenAPI schema extensions by default to select columns for custom types.

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Oct 5, 2017
@apelisse
Copy link
Member Author

apelisse commented Oct 5, 2017

cc @droot

Must be merged after #53472

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 5, 2017
@smarterclayton
Copy link
Contributor

I'd like to see this also applied to the server side code so we're not only working on half the solution.

@apelisse
Copy link
Member Author

apelisse commented Oct 5, 2017

I'm probably missing some context. Could you elaborate?

How is this half the solution, since it does exactly what I expect?

@smarterclayton
Copy link
Contributor

smarterclayton commented Oct 5, 2017 via email

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Oct 11, 2017
@apelisse
Copy link
Member Author

Updated to fix the broken tests.

I don't disagree with you but:

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 31, 2017
@arschles
Copy link

arschles commented Nov 2, 2017

We really shouldn't let that happen: https://twitter.com/prydonius/status/917816589201879040 😄

+1 on this. We already have the custom column syntax documented in the service-catalog walkthrough docs. Being able to remove it and have the custom columns "just work" (from the user perspective) would be tremendous from a UX point of view.

@pwittrock
Copy link
Member

@smarterclayton I don't follow the argument that we should hold off on UX improvements in the client so the server doesn't fall behind. Isn't needing to pairing client / server features the opposite of what we want since we can expect to work in client / server version skewed environments and will never be able to transactionally update both.

Failing to provide an adequate solution for printing extensions will likely result in folks doing something much worse - such as forking kubectl and compiling in custom logic (yes this was proposed), or writing plugins to print resources.

@smarterclayton
Copy link
Contributor

smarterclayton commented Nov 15, 2017 via email

@pwittrock
Copy link
Member

@smarterclayton Thanks for all you responses.

The server is ultimately the one who controls output, not the client, because the client will always be field skewed with the server.

I believe the implementation here is still driven by the server. As I understand it, this approach and the server-side-printing approach are very similar - in both cases the server provides to the client a list of columns + the structured data to populate those columns, and the client then formats the data for printing in a generic way without compiling in any information about the type. In neither case should version skew occur since the server controls the data is printed by the client. (round-tripping through structs aside, which won't happen for extension types and really shouldn't happen for non-extension types)

The difference with this implementation vs server-side-printing, is 1) that the server attaches the columns metadata to the object schema instead of including it in the response body, and 2) the server cannot pre-process the information in the object configuration.

Are you saying you don't agree with the move to have it on the server side?

Not entirely. Btw, do you have a link to the latests design for server-side-printing? I read the initial design, but that was some time ago, and things have probably changed since I read it.

The information currently in describe - absolutely - yes this belongs in server-side-printing.

The information in get - I think we need to be careful about what we provide from the server. Note: I do not intend this PR as a replacement for server-side-printing for get.

I am wary of having the server do much pre-processing of the data in the object configuration for a simple get / GET. I tend to think the information in get should be pulled directly from what is in the object configuration (I am sure there are some exceptions to this but don't know what they are), and have controllers write back aggregated / pre-processed information to the Status fields.
This is done instead of having the printer perform aggregation or processing. This approach simplifies the printer and makes the information more accessible through the usual means to language specific clients (such as client-go). What we have seen with the pre-processing done in describe is that users come to depend on that data and then build tools that consume it because they don't want to calculate it themselves (understandably). In these cases, I would prefer users got the data directly from the status of the object instead of having the printer alter both formatting and the information.

I'd rather focus on finishing server side than continuing to poke at it from the CLI side.

I don't think this will reduce focus on server side printing except that it reduces the negative impact of server side printing failing to land in 1.9, and reduces the impact of unknown-unknowns discovered with server-side-printing post code freeze. The feature enabled in this PR was completed and merged in 1.8, but kept as opt-in. This PR is limited to changing the default flag value so it is opt-out, and updating some tests.

My own bias'ed analysis:

Risks of not enabling this feature in 1.9

  • server side printing doesn't land in 1.9
  • server side printing lands in 1.9 but has unknown-unknowns that prevent it from adequately addressing the needs of extensions in 1.9 (either on the server side, or in the client integration)
  • server side printing lands in 1.9, but extensions have trouble rebasing their extension servers on the 1.9 codebase (I find this rather challenging myself)

Risks of enabling this feature

  • it introduces an optional dependency (only used if can be retrieved) on openapi for get (unknown-unknowns)
    • similar types of risks would be present for integrating server-side-printing in the client
    • we've optimized retrieving openapi now so it is relatively small (serialized proto), cached correctly (not just ttl based), and fast to parse
  • it gets some adoption over server-side-printing
    • if this happens, we should figure out why and use this to improve server-side-printing

Thoughts?

Antoine Pelisse added 2 commits November 15, 2017 14:02
Add a new EmptyResource class that implements openapi.Resources, but
just doesn't have any resources. That is useful for tests that expect
the OpenAPISchema to be working, but don't expect any actual result.

Also implement CreateOpenAPISchemaFunc to simply plug in the TestFactory
code when you want to use an actual APISchema.
Change the name of the flag to something slightly more user-friendly,
while making it default true. The flag is kept so that someone can
revert it temporarly if things go wrong.
@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 15, 2017
@apelisse
Copy link
Member Author

/retest

@pwittrock
Copy link
Member

@smarterclayton Planning on lgtming this today if you have no other comments.

@pwittrock
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 17, 2017
@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: apelisse, pwittrock

No associated issue. Update pull-request body to add a reference to an issue, or get approval with /approve no-issue

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-github-robot k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 17, 2017
@pwittrock
Copy link
Member

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 17, 2017
@k8s-github-robot
Copy link

Automatic merge from submit-queue (batch tested with PRs 50457, 55558, 53483, 55731, 52842). If you want to cherry-pick this change to another branch, please follow the instructions here.

@k8s-github-robot k8s-github-robot merged commit 153b5f5 into kubernetes:master Nov 18, 2017
k8s-github-robot pushed a commit that referenced this pull request Jun 29, 2018
Automatic merge from submit-queue (batch tested with PRs 65319, 64513, 65474, 65601, 65634). 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>.

deprecate --use-openapi-print-columns in favor of --server-print

server-side printing has been supported since 1.10 with identical output for core kubernetes types, support is available for extension API servers since 1.10, and for CRDs since 1.11.

openapi printing is mutually exclusive with server-side printing (you have to fetch full objects to do openapi printing, and table row output to do server side printing)

openapi printing has many downsides:
* it requires fetching/parsing a very large schema on every get request
* it requires complex object extraction logic be built into every client
* it is limited to literal values that appear in the objects

see discussion of long-term direction between these two approaches in #53483

/sig cli

@kubernetes/sig-cli-pr-reviews 
/assign @pwittrock @soltysh

```release-note
kubectl: --use-openapi-print-columns is deprecated in favor of --server-print
```
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. 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/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enable use-openapi-print-columns in kubectl
7 participants