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

Promote feature CustomResourceValidationExpressions to beta #111524

Merged
merged 1 commit into from Jul 29, 2022

Conversation

cici37
Copy link
Contributor

@cici37 cici37 commented Jul 29, 2022

What type of PR is this?

/kind feature

What this PR does / why we need it:

This PR is to promote feature CustomResourceValidationExpressions to beta as it's proposed in KEP.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

The feature is in alpha since v1.23. For v1.25 cycle, we focus on performance optimization, test coverage, bug fix, metrics adding, dependency bumping, etc. The related PR FYI:

Graduation to beta criteria from the KEP

  • Resolve topic of what support we should provide for access to the previous versions of object (ie. 'oldSelf' feature) -- resolved in
    {name: "transition rules",
    obj: map[string]interface{}{
    "v": "new",
    },
    oldObj: map[string]interface{}{
    "v": "old",
    },
    schema: objectTypePtr(map[string]schema.Structural{
    "v": stringType,
    }),
    valid: []string{
    "oldSelf.v != self.v",
    "oldSelf.v == 'old' && self.v == 'new'",
    },
    },
    {name: "skipped transition rule for nil old primitive",
    expectSkipped: true,
    obj: "exists",
    oldObj: nil,
    schema: &stringType,
    valid: []string{
    "oldSelf == self",
    },
    },
    {name: "skipped transition rule for nil old array",
    expectSkipped: true,
    obj: []interface{}{},
    oldObj: nil,
    schema: listTypePtr(&stringType),
    valid: []string{
    "oldSelf == self",
    },
    },
    {name: "skipped transition rule for nil old object",
    expectSkipped: true,
    obj: map[string]interface{}{"f": "exists"},
    oldObj: nil,
    schema: objectTypePtr(map[string]schema.Structural{
    "f": stringType,
    }),
    valid: []string{
    "oldSelf.f == self.f",
    },
    },
    {name: "skipped transition rule for old with non-nil interface but nil value",
    expectSkipped: true,
    obj: []interface{}{},
    oldObj: nilInterfaceOfStringSlice(),
    schema: listTypePtr(&stringType),
    valid: []string{
    "oldSelf == self",
    },
    },
  • x-kubernetes-int-or-string is upgraded to use a union type of just int or string, not a dynamic type (CEL go support is planned in lates 2021) -- resolved in
    {name: "string in intOrString",
    obj: map[string]interface{}{
    "something": "25%",
    },
    schema: objectTypePtr(map[string]schema.Structural{
    "something": intOrStringType(),
    }),
    valid: []string{
    // In Kubernetes 1.24 and later, the CEL type returns false for an int-or-string comparison against the
    // other type, making it safe to write validation rules like:
    "self.something == '25%'",
    "self.something != 1",
    "self.something == 1 || self.something == '25%'",
    "self.something == '25%' || self.something == 1",
    // In Kubernetes 1.23 and earlier, all int-or-string access must be guarded by a type check to prevent
    // a runtime error attempting an equality check between string and int types.
    "type(self.something) == string && self.something == '25%'",
    "type(self.something) == int ? self.something == 1 : self.something == '25%'",
    // Because the type is dynamic it receives no type checking, and evaluates to false when compared to
    // other types at runtime.
    "self.something != ['anything']",
    },
    },
    {name: "int in intOrString",
    obj: map[string]interface{}{
    "something": int64(1),
    },
    schema: objectTypePtr(map[string]schema.Structural{
    "something": intOrStringType(),
    }),
    valid: []string{
    // In Kubernetes 1.24 and later, the CEL type returns false for an int-or-string comparison against the
    // other type, making it safe to write validation rules like:
    "self.something == 1",
    "self.something != 'some string'",
    "self.something == 1 || self.something == '25%'",
    "self.something == '25%' || self.something == 1",
    // In Kubernetes 1.23 and earlier, all int-or-string access must be guarded by a type check to prevent
    // a runtime error attempting an equality check between string and int types.
    "type(self.something) == int && self.something == 1",
    "type(self.something) == int ? self.something == 1 : self.something == '25%'",
    // Because the type is dynamic it receives no type checking, and evaluates to false when compared to
    // other types at runtime.
    "self.something != ['anything']",
    },
    },
  • Understanding of upper bounds of CPU/memory usage and appropriate limits set to prevent abuse.(Done in Add CEL runtime cost into CR validation #108482; Update CEL runtime cost limit #108595; Calculate CEL cost totals #108612; Reduce CEL runtime cost limits by 1/2 based on latency goals #109122)
  • Build-in macro/function library is comprehensive and stable (any changes to this will be a breaking change) - The later addition of quantity appears to complicate this. See CEL Validation Use Cases where it is postponed as a use-case (Add CEL function library #108312)
  • CEL numeric comparison issue is resolved (e.g. ability to compare ints to doubles) (Added test here)
  • Reduce noise of invalid data messages reported from cel.UnstructuredToVal #106440 Asking for clarification of the fix
  • Benchmark cel.UnstructuredToVal and optimize away repeated wrapper object construction #106438
  • Demonstrate adoption and successful feature usage in the community -- confirmed against the list in CEL Validation Use Cases. quantity to be rejected by supported releases when it is added.
  • Optimization on super-linear complexity growth (Optimize away repeated structural schema and CEL DeclType construction in CRD validation #110135)
  • Adding metric of the latency of CEL evaluation for CRD evaluation

Does this PR introduce a user-facing change?

Graduated `CustomResourceValidationExpressions` to `beta`. The `CustomResourceValidationExpressions` feature gate is now enabled by default.

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

- [KEP]: https://github.com/kubernetes/enhancements/blob/master/keps/sig-api-machinery/2876-crd-validation-expression-language/README.md

@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. kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Jul 29, 2022
@k8s-ci-robot k8s-ci-robot added area/apiserver sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Jul 29, 2022
@cici37
Copy link
Contributor Author

cici37 commented Jul 29, 2022

#111158 was accidentally closed and cannot be reopen due to a force-push. Sorry for the inconvenience.
/sig api-machinery
/triage accepted
/priority important-soon
/assign @deads2k @jpbetz @liggitt

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Jul 29, 2022
@cici37 cici37 added this to the v1.25 milestone Jul 29, 2022
@cici37
Copy link
Contributor Author

cici37 commented Jul 29, 2022

/test pull-kubernetes-conformance-kind-ga-only-parallel

@deads2k
Copy link
Contributor

deads2k commented Jul 29, 2022

/lgtm
/approve

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cici37, deads2k

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 added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 29, 2022
@k8s-ci-robot k8s-ci-robot merged commit 762f39e into kubernetes:master Jul 29, 2022
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. area/apiserver cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants