Change:
When creating a CRD object this error is printed; When trying to add the metadata fields in the CRD spec, this error is received; CDRs that worked in v1.23.x should work in v1.24.x. If there will be an NBC it should be preceeded with a warning printout before applied. CRD definition CRD object No response N/A Linux custom install. None N/A
cc
/assign cc /kind regression /milestone v1.24
It looks like this is an issue with CRDs which declare a metadata stanza: CRDs are only allowed to declare (at most) and properties within . Pruning is supposed to ignore content within and lean instead on direct decoding into the ObjectMeta type. The pruning bit is actually unit tested to not return "unknown field" errors for unknown fields within metadata, and appears to be working correctly if told it is pruning an object at the root: However, where the custom resource handler calls , it is passing for : I'm not sure why... that doesn't seem correct. Switching that to pass (since we are pruning at the root of the incoming object) fixes this bug. However, in digging into this, I also noticed that strict server-side field handling isn't noticing unknown fields within properly. That is currently done here: That uses json.Unmarshal internally, which ignores unknown fields. I think we need to propagate similar information about whether unknown field info is desired and propagate that back up. Otherwise, previous versions of kubectl using client-side validation notice unknown fields in metadata, and current kubectl with server-side validation doesn't: Implementing unknown field recognition in the coercion should be pretty straightforward (similar to the pruning bit), but is too big of a change post code-freeze, so I'd suggest the following: a test covering and fixing the bug reported here - the feature gate back to alpha for 1.24 - test coverage for how client-side validation catches unknown metadata fields before 1.24 test freeze server-side unknown metadata field validation in 1.25 and promote to beta then
Also, I opened since the client-side validation error citing "ObjectMeta_v2" looked weird (not related to this issue, and not a new issue, but something we need to fix)
Is there something "Spire" should correct? That is, shall I write an issue to them?
No, it's an issue on our side.
Thanks a ton for filing this ! we are landing now for upcoming 1.24 rc.0 please be sure to try that too to confirm that you are unblocked.
this is resolved for 1.24 by disabling the feature by default in retitling this and removing from milestone to track the bug fixed in
Works with
thanks Lars!
This is now fixed at HEAD with the server-side validation feature re-enabled for 1.25

Discussion:
if v.returnUnknownFieldPaths { pruneOpts.ReturnPruned = true } <del> unknownFieldPaths = structuralpruning.PruneWithOptions(u.Object, v.structuralSchemas[gv.Version], false, pruneOpts) </del> <ins> unknownFieldPaths = structuralpruning.PruneWithOptions(u.Object, v.structuralSchemas[gv.Version], true, pruneOpts) </ins> structuraldefaulting.PruneNonNullableNullsWithoutDefaults(u.Object, v.structuralSchemas[gv.Version]) }

"kind": "Foo", "metadata": { "name": "instance", <ins> "namespace": "myns", "labels":{"foo":"bar"}, </ins> "unspecified": "bar" }, "unspecified":"bar",

"unspecified": "bar", "metadata": { "name": "instance", <ins> "namespace": "myns", "labels":{"foo":"bar"}, </ins> "unspecified": "bar" }, "spec": {

`, isResourceRoot: true, schema: &structuralschema.Structural{ Generic: structuralschema.Generic{Type: "object"}, Properties: map[string]structuralschema.Structural{ <ins> "metadata": { Generic: structuralschema.Generic{Type: "object"}, }, </ins> "pruned": { Generic: structuralschema.Generic{Type: "object"}, Extensions: structuralschema.Extensions{ XEmbeddedResource: true, }, Properties: map[string]structuralschema.Structural{ <ins> "metadata": { Generic: structuralschema.Generic{Type: "object"}, }, </ins> "spec": { Generic: structuralschema.Generic{Type: "object"}, },

XEmbeddedResource: true, }, Properties: map[string]structuralschema.Structural{ <ins> "metadata": { Generic: structuralschema.Generic{Type: "object"}, }, </ins> "spec": { Generic: structuralschema.Generic{Type: "object"}, },

"kind": "Foo", "metadata": { "name": "instance", <ins> "namespace": "myns", "labels": {"foo": "bar"}, </ins> "unspecified": "bar" }, "pruned": {

"unspecified": "bar", "metadata": { "name": "instance", <ins> "namespace": "myns", "labels": {"foo": "bar"}, </ins> "unspecified": "bar" }, "spec": {

"kind": "Foo", "metadata": { "name": "instance", <ins> "namespace": "myns", "labels": {"foo": "bar"}, </ins> "unspecified": "bar" }, "spec": {

"storage": true, "schema": { "openAPIV3Schema": { <del> "x-kubernetes-preserve-unknown-fields": true, "type": "object" </del> <ins> "type": "object", "properties": { "metadata": {"type": "object"}, "nestedField": { "type": "object", "properties": { "someSubfield": {"type": "string"}, "otherSubfield": {"type": "string"}, "newSubfield": {"type": "string"} } }, "otherField": {"type": "string"}, "someField": {"type": "string"}, "newField": {"type": "string"}, "patched": {"type": "string"} } </ins> } } }