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

GET/LIST subset of object fields #1459

Closed
bgrant0607 opened this issue Sep 26, 2014 · 19 comments
Closed

GET/LIST subset of object fields #1459

bgrant0607 opened this issue Sep 26, 2014 · 19 comments
Labels
area/api Indicates an issue on api area. priority/awaiting-more-evidence Lowest priority. Possibly useful, but not yet enough support to actually get it done. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery.

Comments

@bgrant0607
Copy link
Member

Split off of #1178 and #1200.

It would be useful to be able to specify fields to be returned by GET or LIST, such as just ObjectMetadata, DesiredState, or CurrentState.

This could make a number of operations easier and cheaper, such as LISTing pods controlled by a replication controller, as in #1325.

@bgrant0607 bgrant0607 added the area/api Indicates an issue on api area. label Sep 26, 2014
@erictune
Copy link
Member

@derekwaynecarr
Copy link
Member

I like the Google+ ?fields parameter.

@smarterclayton
Copy link
Contributor

I like xpath style better than JavaScript dot notation, and think in general it serves better for query/selection of a subset of a document. The event FieldPath and validation field selectors would then just be the singular case.

@erictune
Copy link
Member

erictune commented Oct 1, 2014

http://goessner.net/articles/JsonPath/

On Sat, Sep 27, 2014 at 7:20 AM, Clayton Coleman [email protected]
wrote:

I like xpath style better than JavaScript dot notation, and think in
general it serves better for query/selection of a subset of a document. The
event FieldPath and validation field selectors would then just be the
singular case.


Reply to this email directly or view it on GitHub
#1459 (comment)
.

@smarterclayton
Copy link
Contributor

I immediately retract my statement and return to my original position. Dots ftw :)

----- Original Message -----

http://goessner.net/articles/JsonPath/

On Sat, Sep 27, 2014 at 7:20 AM, Clayton Coleman [email protected]
wrote:

I like xpath style better than JavaScript dot notation, and think in
general it serves better for query/selection of a subset of a document. The
event FieldPath and validation field selectors would then just be the
singular case.


Reply to this email directly or view it on GitHub
#1459 (comment)
.


Reply to this email directly or view it on GitHub:
#1459 (comment)

@erictune
Copy link
Member

erictune commented Oct 1, 2014

The Google+ ?fields format lets you select multiple fields, and at multiple points in the hierarchy, in a compact fashion. This seems pretty useful. Can "dots" format do this?

@erictune erictune removed their assignment Oct 1, 2014
@bgrant0607
Copy link
Member Author

URL parameters can be specified multiple times if we need to select multiple fields.

@smarterclayton
Copy link
Contributor

Would we need to use the multi-field selection format inside of resources (i.e. ComponentReference or Validation errors)? I don't think so, which would mean we'd want the selector on in url params to be a superset of that selector inside the fields.

----- Original Message -----

URL parameters can be specified multiple times if we need to select multiple
fields.


Reply to this email directly or view it on GitHub:
#1459 (comment)

@erictune
Copy link
Member

erictune commented Oct 2, 2014

After consulting with internal experts on this area, I think we should do the following:

  • keep it very simple
    • rationale: there will be a number of clients that need this, so don't make them use a library to deal with this stuff.
  • syntax is dot separated property names, such as a.b.c
  • used for projection in GET request (?fields=a.b.c)
  • can specify multiple of these with comma-separation (?fields=a.b.c,a.d.e.f)
  • applies separately to each item in a LIST operation (cannot mask properties of the list itself, if such exist)
  • no provision for selecting an index out of an array.
    • Rationale: don't introduce indexes as a way to identify entities. We use names for that. If we need to talk about containers in isolation, then we should have a distinct resource path to them, like /pods/xyz/container/abc, where abc could be mapped to/from pods.currentState.manifest.container.name.
  • If there are arrays then the array has to be the last item in the dot-separated sequence.
    • Rationale: KISS
  • this syntax could be used in PATCH, if we want to implement that, to specify which fields to update.
  • this syntax could be used (hand waving) to specify which fields of a pod template that a controller was allowed to modify?

@smarterclayton
Copy link
Contributor

----- Original Message -----

After consulting with internal experts on this area, I think we should do the
following:

  • keep it very simple
    • rationale: there will be a number of clients that need this, so don't
      make them use a library to deal with this stuff.
  • syntax is dot separated property names, such as a.b.c
  • used for projection in GET request (?fields=a.b.c)
  • can specify multiple of these with comma-separation
    (?fields=a.b.c,a.d.e.f)
  • applies separately to each item in a LIST operation (cannot mask properties
    of the list itself, if such exist)
  • no provision for selecting an index out of an array.
    • Rationale: don't introduce indexes as a way to identify entities. We use
      names for that. If we need to talk about containers in isolation, then we
      should have a distinct resource path to them, like
      /pods/xyz/container/abc, where abc could be mapped to/from
      pods.currentState.manifest.container.name.
  • If there are arrays then the array has to be the last item in the
    dot-separated sequence.

I think we need to support this for validations. If I submit a pod with 5 containers and one of them has a missing attribute clients have no way to determine that. So maybe we say that it's not allowed in any context except for validations. I am extremely sensitive to building good UI experiences around default validations provided by the platform though so I have a strong bias. Is there another way to do validation on specific fields that means clients don't have to guess what failed?

  • Rationale: KISS
    • this syntax could be used in PATCH, if we want to implement that, to
      specify which fields to update.

+1

  • this syntax could be used (hand waving) to specify which fields of a pod
    template that a controller was allowed to modify?

+1

@erictune
Copy link
Member

erictune commented Oct 2, 2014

I see this as about specifying fields in an URL. If an HTTP request to create or update a resource fails, there is no URL to refer to on the apiserver. I think using a format with indexes in a non-URL error message or other context seems fine.

@smarterclayton
Copy link
Contributor

Ok, then latest proposal LGTM

----- Original Message -----

I see this as about specifying fields in an URL. If an HTTP request to
create or update a resource fails, there is no URL to refer to on the
apiserver. I think using a format with indexes in a non-URL error message
or other context seems fine.


Reply to this email directly or view it on GitHub:
#1459 (comment)

@bgrant0607 bgrant0607 added the priority/awaiting-more-evidence Lowest priority. Possibly useful, but not yet enough support to actually get it done. label Dec 4, 2014
@bgrant0607
Copy link
Member Author

@ghodss
Copy link
Contributor

ghodss commented Feb 20, 2015

What is the rationale for using dot approach and not just the Google+ API method exactly?

@smarterclayton
Copy link
Contributor

JavaScript. Anyone who has to do field validation or jquery or jq will be able to leverage that format. The others are somewhat ivory tower

@thockin
Copy link
Member

thockin commented Feb 20, 2015

Is that still true with the simplifying assumptions up-thread? E.g. no
indexes

On Thu, Feb 19, 2015 at 6:17 PM, Clayton Coleman [email protected]
wrote:

JavaScript. Anyone who has to do field validation or jquery or jq will be
able to leverage that format. The others are somewhat ivory tower

Reply to this email directly or view it on GitHub
#1459 (comment)
.

@smarterclayton
Copy link
Contributor

Sorry, I was responding to Sam, in that the format described by Eric works for me (no indexes) because it looks like what we would use for validation (which needs indexes), which we would probably end up using a lot in JavaScript (which benefits from the dot format).

----- Original Message -----

Is that still true with the simplifying assumptions up-thread? E.g. no
indexes

On Thu, Feb 19, 2015 at 6:17 PM, Clayton Coleman [email protected]
wrote:

JavaScript. Anyone who has to do field validation or jquery or jq will be
able to leverage that format. The others are somewhat ivory tower

Reply to this email directly or view it on GitHub
#1459 (comment)
.


Reply to this email directly or view it on GitHub:
#1459 (comment)

@bgrant0607 bgrant0607 added status/help-wanted sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. labels Feb 28, 2015
@smarterclayton
Copy link
Contributor

A version of this has been implemented in #40848 - clients can request only object metadata. Future enhancements will allow alternate schemas to be returned. The only consumer today is GC. Closing.

soltysh pushed a commit to soltysh/kubernetes that referenced this issue Apr 5, 2023
[4.11] OCPBUGS-6683: add message about possibly working with restricted SCC
@nicktimko
Copy link

If anyone finds this and is wondering where some documentation is and/or what it's called: look up information on "Tables"

https://kubernetes.io/docs/reference/using-api/api-concepts/#receiving-resources-as-tables

tl;dr: add a header like Accept: application/json;as=Table;v=v1;g=meta.k8s.io

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/api Indicates an issue on api area. priority/awaiting-more-evidence Lowest priority. Possibly useful, but not yet enough support to actually get it done. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery.
Projects
None yet
Development

No branches or pull requests

7 participants