- 
                Notifications
    
You must be signed in to change notification settings  - Fork 1.6k
 
KEP-5667: CRD Map Key Validation #5668
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
base: master
Are you sure you want to change the base?
Conversation
| 
           [APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: jpbetz 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   | 
    
4c6d82c    to
    bea50d5      
    Compare
  
    | 
           @jpbetz: The following tests failed, say  
 Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. 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-sigs/prow repository. I understand the commands that are listed here.  | 
    
| `x-kubernetes-property-names` extension as a way of evolving OpenAPI 3.0 in a direction that is | ||
| aligned with OpenAPI 3.1. | ||
| 
               | 
          ||
| ### Goals | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps a good goal here is to make sure that any changes we build in this direction are compatible with a future move to OpenAPI 3.1?
| 
               | 
          ||
| - Add `x-kubernetes-property-names` extension. | ||
| - Require the use of structural schemas for map keys. | ||
| - Update CEL cost estimate system to use `maxLength` of map keys. | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the moment it assumes unbounded effectively? So max string length of ~3MiB?
| - OpenAPI 3.0 libraries that do not recognize the `x-kubernetes-property-names` property are required to ignore it. | ||
| This is what makes using an extension preferable to using `propertyNames`. OpenAPI 3.0 libraries may report | ||
| an "unrecognized property" error if `propertyNames` is encountered. | ||
| - Support for key defaults will also be added. | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this mean? How does defaulting for a key work?
| Risk: The ecosystem is fragmented by CRD schemas that use this feature, since older versions of Kubernetes | ||
| do not support it. | ||
| 
               | 
          ||
| Mitigation: Ratchet it in. We do this for other capabilities like new formats, CEL functions, ... | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume we will need to follow the same pattern for bringing CEL in of introduce the extension in 1.X, but only allow CRDs to write to the extension in 1.X+1 right? To allow for upgrades/rollback cycles
We propose adding a
x-kubernetes-property-namesextension to OpenAPI 3.0.This extension can be used to validate map keys. For example, to define map
of string to string where the keys and values have a max length of 32: