@@ -156,6 +156,11 @@ type crdHandler struct {
156
156
// disableServerSideApply allows to deactivate Server Side Apply for a specific API server instead of globally through the feature gate
157
157
// used for embedded cache server with kcp
158
158
disableServerSideApply bool
159
+
160
+ // disableGenerationRepair allows for disabling setting a generation during an object decoding (for objects that haven't had it)
161
+ // this field is meant to be set by the cache server so that built-in (assuming all CRs must have it) source objects
162
+ // don't differ from the replicated ones.
163
+ disableGenerationRepair bool
159
164
}
160
165
161
166
// crdInfo stores enough information to serve the storage for the custom resource
@@ -210,6 +215,7 @@ func NewCustomResourceDefinitionHandler(
210
215
staticOpenAPISpec * spec.Swagger ,
211
216
maxRequestBodyBytes int64 ,
212
217
disableServerSideApply bool ,
218
+ disableGenerationRepair bool ,
213
219
) (* crdHandler , error ) {
214
220
if converterFactory == nil {
215
221
return nil , fmt .Errorf ("converterFactory is required" )
@@ -233,6 +239,7 @@ func NewCustomResourceDefinitionHandler(
233
239
staticOpenAPISpec : staticOpenAPISpec ,
234
240
maxRequestBodyBytes : maxRequestBodyBytes ,
235
241
disableServerSideApply : disableServerSideApply ,
242
+ disableGenerationRepair : disableGenerationRepair ,
236
243
}
237
244
crdInformer .Informer ().AddEventHandler (cache.ResourceEventHandlerFuncs {
238
245
AddFunc : ret .createCustomResourceDefinition ,
@@ -1030,6 +1037,7 @@ func (r *crdHandler) getOrCreateServingInfoFor(crd *apiextensionsv1.CustomResour
1030
1037
structuralSchemas : structuralSchemas ,
1031
1038
structuralSchemaGK : kind .GroupKind (),
1032
1039
preserveUnknownFields : crd .Spec .PreserveUnknownFields ,
1040
+ repairGeneration : ! r .disableGenerationRepair ,
1033
1041
},
1034
1042
crd : crd ,
1035
1043
},
@@ -1400,6 +1408,7 @@ type crdConversionRESTOptionsGetter struct {
1400
1408
structuralSchemas map [string ]* structuralschema.Structural // by version
1401
1409
structuralSchemaGK schema.GroupKind
1402
1410
preserveUnknownFields bool
1411
+ repairGeneration bool
1403
1412
}
1404
1413
1405
1414
func (t crdConversionRESTOptionsGetter ) GetRESTOptions (resource schema.GroupResource ) (generic.RESTOptions , error ) {
@@ -1408,7 +1417,7 @@ func (t crdConversionRESTOptionsGetter) GetRESTOptions(resource schema.GroupReso
1408
1417
d := schemaCoercingDecoder {delegate : ret .StorageConfig .Codec , validator : unstructuredSchemaCoercer {
1409
1418
// drop invalid fields while decoding old CRs (before we haven't had any ObjectMeta validation)
1410
1419
dropInvalidMetadata : true ,
1411
- repairGeneration : true ,
1420
+ repairGeneration : t . repairGeneration ,
1412
1421
structuralSchemas : t .structuralSchemas ,
1413
1422
structuralSchemaGK : t .structuralSchemaGK ,
1414
1423
preserveUnknownFields : t .preserveUnknownFields ,
0 commit comments