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

sig-api-machinery KEP: Pruning for CustomResources #709

Merged
merged 1 commit into from
Apr 30, 2019

Conversation

sttts
Copy link
Contributor

@sttts sttts commented Jan 22, 2019

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jan 22, 2019
@k8s-ci-robot k8s-ci-robot added kind/kep Categorizes KEP tracking issues and PRs modifying the KEP directory sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/architecture Categorizes an issue or PR as relevant to SIG Architecture. sig/pm labels Jan 22, 2019
@lavalamp
Copy link
Member

/assign @apelisse

@sttts
Copy link
Contributor Author

sttts commented Apr 26, 2019

I will update this today to match the vanilla OpenAPI subset #1002.

@sttts
Copy link
Contributor Author

sttts commented Apr 26, 2019

This is updated now to match #1002.

@sttts sttts force-pushed the sttts-pruning branch 5 times, most recently from ee7989c to 9c42677 Compare April 26, 2019 09:55
@sttts
Copy link
Contributor Author

sttts commented Apr 26, 2019

@sttts sttts force-pushed the sttts-pruning branch 3 times, most recently from c82ed16 to 591edf5 Compare April 26, 2019 10:51
@sttts sttts changed the title sig-api-machinery: add "Pruning for CustomResources" sig-api-machinery KEP: Pruning for CustomResources Apr 26, 2019
@sttts sttts force-pushed the sttts-pruning branch 5 times, most recently from e0cf9f9 to caefa54 Compare April 28, 2019 08:38
keps/sig-api-machinery/20180731-crd-pruning.md Outdated Show resolved Hide resolved

**blockers for GA:**

* we verified that performance of pruning is adequat and not considerably reducing throughput.
Copy link
Contributor

Choose a reason for hiding this comment

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

s/adequat/adequate

Copy link
Contributor

Choose a reason for hiding this comment

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

Quantify this? Intuitively, I don't expect much difference in cost from a validation pass to a validation+pruning pass. So maybe saying within X% is sufficient here.

@roycaihw any thoughts from you're work on benchmarking validation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is hard to quantify without defining test cases to compare against. It depends on the input CR instances and on the schema a lot.

My gut feeling is that with structural schemas and a handful of pruned fields, this is not expensive at all (compared to unmarshalling and value validation).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that we don't have to fill this for alpha.

keps/sig-api-machinery/20180731-crd-pruning.md Outdated Show resolved Hide resolved
@sttts
Copy link
Contributor Author

sttts commented Apr 30, 2019

@jpbetz addressed your comments

// Defaults to false.
// Setting this field to true is considered an alpha API.
// Note: this will default to true in version v1.
PruneUnknownFields bool
Copy link
Member

@liggitt liggitt Apr 30, 2019

Choose a reason for hiding this comment

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

needs to be a *bool (at least in v1beta1) so we can distinguish between unset and explicitly false

if explicitly false, is this equivalent to putting x-kubernetes-preserve-unknown-fields: true at every level of the schema?

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.

And yes, x-kubernetes-preserve-unknown-fields: true at each object level.

Copy link
Member

Choose a reason for hiding this comment

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

that equivalence is helpful to call out in the documentation

// Defaults to false.
// Setting this field to true is considered an alpha API.
// Note: this will default to true in version v1.
PruneUnknownFields bool
Copy link
Member

@liggitt liggitt Apr 30, 2019

Choose a reason for hiding this comment

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

Since "known fields" are derived from properties directives in the schema, would it be clearer to name it x-kubernetes-preserve-unknown-properties?

Also, would it be helpful to align the name and polarity of the field and the schema extension? This would let us omit the field in v1 when set to false, which is nice.

v1beta1:

// defaults to true
// +optional
PreserveUnknownProperties *bool `json:"preserveUnknownProperties,omitempty"

v1:

// defaults to false
// +optional
PreserveUnknownProperties bool `json:"preserveUnknownProperties,omitempty"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure about field-vs-properties. @apelisse is using "fields" in his new tags as well.

Am fine with switching polarity.

Copy link
Member

Choose a reason for hiding this comment

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

I like matching polarity and name, I don't feel strongly about properties vs fields

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I leave it at fields for the moment. We have time to find consensus before code freeze. This is not critical.


**Pruning will be enabled by default for CRDs created in `v1`**.

Pruning requires _structural schemas_ (as described in [KEP Vanilla OpenAPI Subset: Structural Schema](https://github.com/kubernetes/enhancements/pull/1002)) for all defined versions. Validation will reject the CRD with `pruneUnknownFields: true` otherwise.
Copy link
Member

Choose a reason for hiding this comment

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

What is the behavior when submitting a v1 CRD without a validation schema?

Copy link
Contributor Author

@sttts sttts Apr 30, 2019

Choose a reason for hiding this comment

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

We will prune everything, other than TypeMeta and ObjectMeta.

@liggitt
Copy link
Member

liggitt commented Apr 30, 2019

if someone opts into pruning an existing v1beta1 CRD, should that signal something like the storage migrator that a read/write cycle should be done to prune existing etcd data? I had a similar question about the defaulting KEP.

For CRDs with pruning enabled or with defaulting enabled, should the validation schema(s) factor into the published storageVersionHash, since they affect what is stored in etcd?

cc @caesarxuchao

@deads2k
Copy link
Contributor

deads2k commented Apr 30, 2019

we have a typo checker that could stall merge of this today. Really....

@liggitt
Copy link
Member

liggitt commented Apr 30, 2019

Glad to see this come together

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 30, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: deads2k, liggitt, sttts

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

@k8s-ci-robot k8s-ci-robot merged commit 310d877 into kubernetes:master Apr 30, 2019

![Decoding steps which must prune](20180731-crd-pruning-decoding.png)

We will also prune after mutating webhooks have been run.
Copy link
Member

Choose a reason for hiding this comment

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

what about after reading the response from a conversion webhook?

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/kep Categorizes KEP tracking issues and PRs modifying the KEP directory lgtm "Looks good to me", indicates that a PR is ready to be merged. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/architecture Categorizes an issue or PR as relevant to SIG Architecture. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants