-
Notifications
You must be signed in to change notification settings - Fork 39k
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
Eliminate round-trip conversion of API objects in kubectl convert
#3955
Comments
Right now, the mutation we are doing on create/update is to set the namespace of the object, and during update we set the resource version. Ideally, we'd be able to do this opaquely, and with less conversions (perhaps by having a runtime.Object that supported deferred decoding by working a bit like runtime.Unknown). Right now we don't assume that it's safe to mutate the JSON directly because we'd have to write code for each object type that says what sort of mutation we need for metadata (we can read it from the scheme via the name conversion rules, but it's a bit tricky because we don't define what fields are metadata). The assumption that an apiversion can have rules defined on it is invalid (because eventually core resources will split and migrate at different times, so they may have different rules). Once we nuke v1beta1/2, it would be a good time to go through the code and simplify a bit to say that there is a fast path for certain known object types (core resources) which can bypass direct conversion and do mutation directly on the JSON, and the rest can use the slower pass for mutation. ----- Original Message -----
|
Some observations:
|
Yeah, its dubious that clients should even be able to see internal structs If validation is applied to versioned structs, then clients can stay
|
We should use (potentially cached) swagger for basic (optional) client-side validation. That approach will work with newer releases, new versions, and new objects (plugins, etc.). Detailed validation that can't be expressed via swagger can be performed by the server. |
Some of the work I did with RESTMapper last week could be used in the future where we introspect swagger and build a RESTMapper from it on the client. Sent from my iPhone
|
Agreed that clients should not have to perform the conversion. What's the main purpose of client-side validation? |
Client-side validation can be lower-latency. On Tue, Feb 3, 2015 at 11:58 AM, Yu-Ju Hong notifications@github.com
|
Clients can be about validation, which increases user frustration (go to web UI, set something, go to client, can't set it, hate product forever). I would argue client validation is always optional and as much as possible comes from source of truth (schema exposed a la swagger, which is a reasonable compromise). ----- Original Message -----
|
"can be very wrong" ----- Original Message -----
|
Agreed that we want the source of truth to come from the server. |
Found that the test for template-based printing in kubectl (resource_printer_test.go) failed when I removed the json tags on api/types.go for #3933. |
cc @vishh |
w00t! that's huge. On Thu, Aug 25, 2016 at 8:52 AM, Clayton Coleman notifications@github.com
|
@krousey is there more to do or can we close this issue? |
@lavalamp Because of the way we do patching (relies on data being of the same version and also needs versioned struct tags for merge strategies), anything that computes a strategic merge patch still does client side conversion. I may have missed a few, but that's We'd have to fix how we compute patches client-side (and/or handle them server-side) to change that. I don't know if we want to attempt that, and if we do, whether this is the place to track that effort. |
For operations not on the server we can either implement one patch
calculation for each API version kubectl supports, or split defaulting
into its own pass and allow conversion without defaulting (we are
going to have to do that anyway for other reasons). The latter could
still introduce patch artifacts.
The "set" commands are going to end up having a lot of internal code
that needs patch. I would regret the cut and paste, but one function
per version isn't the end of the world.
|
Kicking this out of the milestone since we're not planning on doing more at the moment. |
This was mostly completed in 1.6. Some specific commands still use internal version. |
Issues go stale after 90d of inactivity. Prevent issues from auto-closing with an If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or |
/remove-lifecycle stale |
reassigning to @lavalamp as I haven't actually worked on this in a while. |
kubectl convert
Is this still a real issue? |
This functionality got split out to kubectl-convert so kubectl no longer has a dependency on internal types. I think that's the final destination and this can be closed |
kubectl decodes a json file and encodes it again before sending out the request to the API server, i.e.,
versioned json-> versioned api object -> internal api object -> versioned api object -> versioned json
The API server then decodes the versioned json and converts it to the internal API object.
It is debatable whether kubectl needs to perform the round-trip conversion, since the API server would perform the similar process immediately after receiving the request. Can we simplify this?
@bgrant0607 @smarterclayton
The text was updated successfully, but these errors were encountered: