@@ -39,6 +39,7 @@ found at [API Conventions](api-conventions.md).
39
39
- [ Alpha, Beta, and Stable Versions] ( #alpha-beta-and-stable-versions )
40
40
- [ Adding Unstable Features to Stable Versions] ( #adding-unstable-features-to-stable-versions )
41
41
- [ New field in existing API version] ( #new-field-in-existing-api-version )
42
+ - [ Ratcheting validation] ( #ratcheting-validation )
42
43
- [ New enum value in existing field] ( #new-enum-value-in-existing-field )
43
44
- [ New alpha API version] ( #new-alpha-api-version )
44
45
@@ -878,13 +879,13 @@ You need to regenerate the generated code as instructed in the sections above.
878
879
Part of our testing regimen for APIs is to "fuzz" (fill with random values) API
879
880
objects and then convert them to and from the different API versions. This is
880
881
a great way of exposing places where you lost information or made bad
881
- assumptions.
882
+ assumptions.
882
883
883
884
The fuzzer works by creating a random API object and calling the custom fuzzer
884
885
function in ` pkg/apis/$GROUP/fuzzer/fuzzer.go ` . The resulting object is then
885
886
round-tripped from one api version to another, and verified to be the same as
886
887
what was started with. Validation is not run during this process, but defaulting
887
- is.
888
+ is.
888
889
889
890
If you have added any fields which need very careful formatting (the test does
890
891
not run validation) or if you have made assumptions during defaulting such as
@@ -998,9 +999,9 @@ complexity of upgradeability and lack of long-term support and lack of
998
999
upgradability.
999
1000
- Beta level:
1000
1001
- Object Versioning: API version name contains ` beta ` (e.g. ` v2beta3 ` )
1001
- - Availability: in official Kubernetes releases; API is disabled by default
1002
+ - Availability: in official Kubernetes releases; API is disabled by default
1002
1003
but may be enabled by a flag.
1003
- (Note: beta APIs introduced before v1.24 were enabled by default, but this
1004
+ (Note: beta APIs introduced before v1.24 were enabled by default, but this
1004
1005
[ changed for new beta APIs] ( https://github.com/kubernetes/enhancements/blob/master/keps/sig-architecture/3136-beta-apis-off-by-default/README.md ) )
1005
1006
- Audience: users interested in providing feedback on features
1006
1007
- Completeness: all API operations, CLI commands, and UI support should be
@@ -1225,6 +1226,37 @@ In future Kubernetes versions:
1225
1226
}
1226
1227
` ` `
1227
1228
1229
+ #### Ratcheting validation
1230
+
1231
+ The word " ratcheting" refers to a process of incremental and often irreversible
1232
+ progression or change, typically in a single direction. The term originates from
1233
+ a mechanical device called a [ratchet](https:// en.wikipedia.org/wiki/Ratchet_(device)),
1234
+ which consists of a toothed wheel or bar and a pawl (a catch) that allows movement
1235
+ in only one direction while preventing backward motion.
1236
+
1237
+ In the Kubernetes world, a ratcheting validation refers to an incremental tightening
1238
+ of validation. This means we allow current resources to either remain invalid or
1239
+ be fixed, but all new resources must pass the validation. The following table
1240
+ best illustrates these cases:
1241
+
1242
+ | Resource | Validation |
1243
+ |-------------|------------|
1244
+ | new valid | succeeds |
1245
+ | new invalid | fails |
1246
+ | old valid | succeeds |
1247
+ | old invalid | succeeds |
1248
+
1249
+ A good example of ratcheting validation was introduced in [this pull request](https:// github.com/kubernetes/kubernetes/pull/130233).
1250
+ It introduced validation for the optional ` .spec.serviceName` field for StatefulSet,
1251
+ such that old resources (nregarldess of whether they are valid or not) will succeed
1252
+ the validation check, but new resources must adhere to stricter validation rules
1253
+ for that field. The relevant changes include:
1254
+ - A struct with options passed to validation methods (here it' s the `StatefulSetValidationOptions`
1255
+ struct, with `AllowInvalidServiceName` to handle this specific case).
1256
+ - Appropriate changes inside `Validate*` methods which ensure the rules from the
1257
+ table above are implemented.
1258
+ - Tests ensuring all the cases from the above table are covered.
1259
+
1228
1260
#### New enum value in existing field
1229
1261
1230
1262
A developer is considering adding a new allowed enum value of `"OnlyOnTuesday"`
0 commit comments