You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: keps/sig-api-machinery/5073-declarative-validation-with-validation-gen/README.md
+16-5Lines changed: 16 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -166,7 +166,7 @@ Please feel free to try out the [prototype](https://github.com/jpbetz/kubernetes
166
166
* Reduce API development costs for API authors and reviewers. Reduce long term maintainer costs. Reclaiming time from core project contributors.
167
167
* Reduce risk of incorrect validation rules reaching production via API development approach that is easier to get right and harder to get wrong.
168
168
* No change to error message structure for clients. Difference to clients is limited to minimal changes to error detail strings. The goal is to preserve the `v1.Status` validation error message’s `field` and `reason`, etc. but we reserve the ability to change the `details` which are allowed to be modified over time from k8s guarantees.
169
-
* Enable development of linters and other API tool chains that use API validation rules and metadata. Further reducing development effort and risk of incorrect validation rules.
169
+
* Enable development of linters for API definition and other API tool chains that use API validation rules and metadata. Further reducing development effort and risk of incorrect validation rules.
170
170
* Retain native (or nearly native) performance.
171
171
* Improve testing rigor by being vastly easier to test.
172
172
@@ -201,6 +201,7 @@ Please feel free to try out the [prototype](https://github.com/jpbetz/kubernetes
201
201
* Easy to review and test.
202
202
* Easy to distribute.
203
203
* Leveraging the broader community to speedup migration is key to the success of the project.
204
+
* Net-new APIs will not be permitted to use declarative validation in the 1.33 release. This decision will be revisited for the 1.34 release.
204
205
* Build linters, documentation-generators, and other tools to make k8s development and API review easier and safer
205
206
* Example: Lint rule that verifies that all required/optional field information is correct
206
207
@@ -223,7 +224,12 @@ The goal is that when a user makes a mistake in authoring IDL tags we give a mea
223
224
New validation tests will be created as part of the migration process for contributors migrating fields using `validation-gen`. Additionally, a test framework and associated migration test utilities will be created as part of `validation-gen` to leverage the new centralized validation rules and to ensure validation consistency across hand-written and declarative validation rules. See the [Test Plan](?tab=t.0#bookmark=id.a86sekfgbuen) section for more details.
224
225
225
226
#### New Validations Vs Migrating Validations
226
-
FIXME...
227
+
**New validations** refer to validation rules added to fields or types that did not previously have any validation, or to entirely new API fields or types being introduced.
228
+
229
+
**Migrating validations** refer to the process of converting existing handwritten validation logic in `validation.go` files to the new declarative approach using IDL tags.
230
+
231
+
The difference is that new validations are implemented directly using IDL tags from the outset, while migrating validations involve a transition from existing handwritten code to IDL tags. Both types of validations will undergo thorough testing. However, migrating validations require additional equivalence testing. This ensures that the behavior of the new declarative validation is identical to that of the original handwritten validation. As a safeguard, until the GA stage, all newly generated validations will be used in conjunction with the existing handwritten validation code. This dual implementation allows for a smooth rollback if needed.
232
+
227
233
228
234
#### New Validation Tests
229
235
As part of the process for migrating fields, contributors will scrutinize and improve as needed the current validation tests. No field can go thru migration without a robust test for the field being migrated, which proves that it is validated correctly before the change and after. Many existing tests are not sufficient to verify 100% equivalency and need retooling. This allows us to de-risk migration problems by scrutinizing the current tests and enhancing them.
@@ -306,13 +312,13 @@ Based on this analysis we believe that the proposed `validation-gen` design can
306
312
307
313
##### Mitigation: Roll Back All Migrated Fields
308
314
309
-
In the case that the workstream loses steam over time and the migration project is abandoned, users can still FIXME...
315
+
In the case that the workstream loses steam over time and the migration project is abandoned, users can still roll back to the previous hand-written validation by disabling the `DeclarativeValidation` feature gate.
310
316
311
317
#### Risk: we get hundreds of PRs from people migrating fields and can't review them all.
312
318
313
319
##### Mitigation: These are not urgent and we will have patterns which can be reviewed by more people.
314
320
315
-
FIXME...
321
+
The migration to declarative validation is not time-sensitive. We can proceed at a comfortable pace, and the process will be broken down into small, manageable PRs. This allows for a wider pool of reviewers to participate, including those who may not be deeply familiar with the intricacies of API validation. The use of standardized IDL tags and generated code will establish clear patterns, making it easier for reviewers to understand and assess the changes.
316
322
317
323
#### Risk: Versioned validation drifts between versions.
318
324
@@ -837,9 +843,14 @@ We should be able to start the migration when:
837
843
#### Phase3: Finalization and GA (Core Team and community)
838
844
839
845
1. After DeclarativeValidation reaches GA
846
+
* The granularity of control for enabling/disabling declarative validation (group, version, type, or field) will be determined based on the experience gained during the Beta phase. The feature gate `DeclarativeValidation` may be retained for a period of time, gradually shifting more validation to the declarative approach, and allowing for a phased rollout and rollback if needed.
840
847
2. Deprecation of Legacy Validation is Announced
841
-
3. ...Deprecation wait period passes (period adhering to community policy)…
848
+
* A formal deprecation notice will be issued for the remaining hand-written validation functions. This notice will specify a timeline for the complete removal of the legacy validation code.
849
+
3. Deprecation wait period passes (period adhering to community policy)
850
+
* The community will have a defined period to adjust to the full migration to declarative validation. During this time, both hand-written and declarative validation may be used, depending on the feature gate's configuration.
842
851
4. Legacy validation code that is being validated declaratively can safely be deleted
852
+
* After the deprecation period, and once the feature gate is removed, the hand-written validation code which has been validated by the generated code will be removed from the codebase.
853
+
843
854
844
855
845
856
### Tagging and Validating Against Internal vs Versioned Types
0 commit comments