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

Improvements to CRD webhook conversion KEP #2484

Closed
wants to merge 1 commit into from

Conversation

mbohlool
Copy link
Contributor

@mbohlool mbohlool commented Aug 7, 2018

A follow up to #2420 to address @lavalamp comments. @sttts @deads2k @erictune please let me know if you have any comment on the KEP and I can address them here or in a new PR.

/assign @lavalamp
/sig api-machinery

@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. labels Aug 7, 2018
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/design Categorizes issue or PR as related to design. labels Aug 7, 2018
// These three fields should not be set for first item in Versions list
Schema *JSONSchemaProp
Subresources *CustomResourceSubresources
AdditionalPrinterColumns []CustomResourceColumnDefinition
}

Type CustomResourceConversion struct {
// Conversion strategy, either "nop” or "webhook”. If webhook is set, Webhook field is required.
// Conversion strategy, either "None” or "Webhook”. If Webhook is set, Webhook field is required.
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

Choose a reason for hiding this comment

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

third "webhook" is lower-case

@@ -225,7 +230,7 @@ error on server: conversion from stored version v1 to requested version v2 for s
```


For operations that need more than one conversion (e.g. LIST), no partial result will be returned. Instead the whole operation will fail the same way with detailed error messages. To help debugging these kind of operations, the UID of the first failing conversion will also be included in the error message.
For operations that need more than one conversion (e.g. LIST), no partial result will be returned. Instead the whole operation will fail the same way with detailed error messages. Also the webhook will recieve the whole list to convert instead of items one by one.
Copy link
Contributor

Choose a reason for hiding this comment

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

receive

This sounds strange now to have LIST as example for multiple calls and for one call for a list.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed. Where do we have LIST as an example of multiple calls? It needs multiple conversion but it will be done with a single http call.

@mbohlool mbohlool force-pushed the crd_conversion_kep branch from d9ef19d to ee1c967 Compare August 7, 2018 07:02
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Aug 7, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To fully approve this pull request, please assign additional approvers.
We suggest the following additional approver: lavalamp

If they are not already assigned, you can assign the PR to them by writing /assign @lavalamp in a comment when ready.

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

@mbohlool mbohlool force-pushed the crd_conversion_kep branch from ee1c967 to c46ce6e Compare August 24, 2018 04:02
@mbohlool
Copy link
Contributor Author

@sttts PTAL
@lavalamp ping

// Optional, and correspond to the first version in the versions list


// These fields are optional and correspond to the first version in the versions list
Copy link
Contributor

Choose a reason for hiding this comment

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

indention

@@ -178,20 +178,27 @@ type ConversionRequest struct {
UID types.UID
// The version to convert given object to. E.g. "stable.example.com/v1"
APIVersion string
// Object is the CRD object to be converted.
// Object is the CRD object or list of objects to be converted.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: list of CRD objects

Copy link
Contributor

Choose a reason for hiding this comment

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

This is the custom CustomResourceList type or a generic List?

Copy link
Member

Choose a reason for hiding this comment

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

Object will not be a CRD object, right? It will be of the type described in the CRD?

Also +1 to being explicit about the list type

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nit: CR not CRD. Will fix that.

The list is a UnstructuredList (not sure what CustomResourceList is but I assume that is what you meant).

Object runtime.RawExtension
// IsList indicates that this is a List operation and Object contains a list of items.
IsList bool
Copy link
Member

Choose a reason for hiding this comment

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

Why is this necessary?

Another way to represent would be to have List []runtime.RawExtension and require that exactly one of object or list be set.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

List has its own meta data. Do we care let conversion webhook to modify that? right now the webhook is responsible for any change to that meta data (specifically changing the APIVersion). If we pass a list of objects, then the caller(APIServer) not the webhook is responsible for any list metadata changes.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see why the actual list object should be exposed to the conversion hook. Conversion is by list item by definition. @lavalamp's slice suggestion would make the interface obvious. We could even drop the Object field and just have an Objects instead.

Copy link
Member

Choose a reason for hiding this comment

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

+1 for unifying the interface to something like objects []runtime.RawExtension, treating single and multi-item conversion requests consistently.

// ConvertedObject is the converted version of request.Object.
ConvertedObject runtime.RawExtension
// ConvertedObject is the converted version of request.Object if the Result field is nil.
// +optional
Copy link
Member

Choose a reason for hiding this comment

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

Probably worth being explicit about what to do for lists.

@@ -225,7 +232,7 @@ error on server: conversion from stored version v1 to requested version v2 for s
```


For operations that need more than one conversion (e.g. LIST), no partial result will be returned. Instead the whole operation will fail the same way with detailed error messages. To help debugging these kind of operations, the UID of the first failing conversion will also be included in the error message.
For operations that need more than one conversion (e.g. LIST), no partial result will be returned. Instead the whole operation will fail the same way with detailed error message. Also the webhook will receive the whole list to convert instead of items one by one.
Copy link
Member

Choose a reason for hiding this comment

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

Is it actually easy to always group items in a list like this, given our stack?

I think we shouldn't promise the entire list in one call. We will probably wish to call it in multiple batches, to avoid causing the webhook to need super high memory usage if for no other reason.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

refer to the other comment about list metadata. We pass a list item and implementation is strightforward right now. Even with current design and implementation, we can divide List object (UnstructuredList) into smaller valid List items and send them to webhook. We promise here that we send an UnstructuredList to the webhook. The webhook is not aware of the actual user request and we do not promise we send that whole user requested objects in one call.

}
```

If the conversion is failed, the webhook should fail the HTTP request with a proper error code and message that will be used to create a status error for the original API caller.
If the conversion is failed, the webhook is prefered to fill up the Result field of the response with a proper error code and message instead of returning failure HTTP codes.
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps: "Instead of returning failure HTTP status codes, the preferred way for a webhook to indicate a conversion failure is to fill the result field of the response with an error code and message. Non-200 status return codes will be taken to mean there was a problem with the webhook rather than a problem with the object to be converted."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed that in the implementation and will fix it here too.

@mbohlool mbohlool force-pushed the crd_conversion_kep branch from c46ce6e to 0c1b0a8 Compare October 2, 2018 23:46
@mbohlool
Copy link
Contributor Author

mbohlool commented Oct 2, 2018

@lavalamp @sttts PTAL.

@justaugustus
Copy link
Member

/kind kep

@k8s-ci-robot
Copy link
Contributor

@mbohlool: PR needs rebase.

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 the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 28, 2018
@mattfarina
Copy link
Contributor

@lavalamp @deads2k what's the next step on this one?

@liggitt
Copy link
Member

liggitt commented Nov 9, 2018

obsoleted by #2737, I thought

@justaugustus
Copy link
Member

REMINDER: KEPs are moving to k/enhancements on November 30. Please attempt to merge this KEP before then to signal consensus.
For more details on this change, review this thread.

Any questions regarding this move should be directed to that thread and not asked on GitHub.

@justaugustus
Copy link
Member

KEPs have moved to k/enhancements.
This PR will be closed and any additional changes to this KEP should be submitted to k/enhancements.
For more details on this change, review this thread.

Any questions regarding this move should be directed to that thread and not asked on GitHub.
/close

@k8s-ci-robot
Copy link
Contributor

@justaugustus: Closed this PR.

In response to this:

KEPs have moved to k/enhancements.
This PR will be closed and any additional changes to this KEP should be submitted to k/enhancements.
For more details on this change, review this thread.

Any questions regarding this move should be directed to that thread and not asked on GitHub.
/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
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/design Categorizes issue or PR as related to design. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. 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.

7 participants