@@ -156,6 +156,11 @@ type crdHandler struct {
156156 // disableServerSideApply allows to deactivate Server Side Apply for a specific API server instead of globally through the feature gate
157157 // used for embedded cache server with kcp
158158 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
159164}
160165
161166// crdInfo stores enough information to serve the storage for the custom resource
@@ -210,6 +215,7 @@ func NewCustomResourceDefinitionHandler(
210215 staticOpenAPISpec * spec.Swagger ,
211216 maxRequestBodyBytes int64 ,
212217 disableServerSideApply bool ,
218+ disableGenerationRepair bool ,
213219) (* crdHandler , error ) {
214220 if converterFactory == nil {
215221 return nil , fmt .Errorf ("converterFactory is required" )
@@ -233,6 +239,7 @@ func NewCustomResourceDefinitionHandler(
233239 staticOpenAPISpec : staticOpenAPISpec ,
234240 maxRequestBodyBytes : maxRequestBodyBytes ,
235241 disableServerSideApply : disableServerSideApply ,
242+ disableGenerationRepair : disableGenerationRepair ,
236243 }
237244 crdInformer .Informer ().AddEventHandler (cache.ResourceEventHandlerFuncs {
238245 AddFunc : ret .createCustomResourceDefinition ,
@@ -1030,6 +1037,7 @@ func (r *crdHandler) getOrCreateServingInfoFor(crd *apiextensionsv1.CustomResour
10301037 structuralSchemas : structuralSchemas ,
10311038 structuralSchemaGK : kind .GroupKind (),
10321039 preserveUnknownFields : crd .Spec .PreserveUnknownFields ,
1040+ repairGeneration : ! r .disableGenerationRepair ,
10331041 },
10341042 crd : crd ,
10351043 },
@@ -1400,6 +1408,7 @@ type crdConversionRESTOptionsGetter struct {
14001408 structuralSchemas map [string ]* structuralschema.Structural // by version
14011409 structuralSchemaGK schema.GroupKind
14021410 preserveUnknownFields bool
1411+ repairGeneration bool
14031412}
14041413
14051414func (t crdConversionRESTOptionsGetter ) GetRESTOptions (resource schema.GroupResource ) (generic.RESTOptions , error ) {
@@ -1408,7 +1417,7 @@ func (t crdConversionRESTOptionsGetter) GetRESTOptions(resource schema.GroupReso
14081417 d := schemaCoercingDecoder {delegate : ret .StorageConfig .Codec , validator : unstructuredSchemaCoercer {
14091418 // drop invalid fields while decoding old CRs (before we haven't had any ObjectMeta validation)
14101419 dropInvalidMetadata : true ,
1411- repairGeneration : true ,
1420+ repairGeneration : t . repairGeneration ,
14121421 structuralSchemas : t .structuralSchemas ,
14131422 structuralSchemaGK : t .structuralSchemaGK ,
14141423 preserveUnknownFields : t .preserveUnknownFields ,
0 commit comments