go composition function: observed XR managedFields leak into SSA status patch
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
Research direction
Start with internal/xfn/utils.go, especially AsStruct(), and composition_functions.go where the SSA status patch is built. Reproduce the difference between crossplane render and a cluster response containing metadata.managedFields, then trace where that field reaches the desired composite resource. Done means the generated-struct round trip no longer produces a rejected SSA status patch, with coverage for managedFields.
Written by the indexing model from the issue text.
Description
What happened?
I am using the Crossplane project sturcture generating the go structs for the composed and composite
resources. The object retains the ManagedFields from the request and when set to the response via
mapAny, err := runtime.DefaultUnstructuredConverter.ToUnstructured(goStructOfComposite)
unstr := unstructured.Unstructured{Object: mapAny}
response.SetDesiredCompositeResource(rsp, &resource.Composite{Resource: &composite.Unstructured{Unstructured: unstr}}),
the metadata.managedFields populated by the API server survive into the SSA patch
body, and Kubernetes rejects it
Below is an analysis by Claude:
When a Go composition function round-trips the observed XR through a generated
struct and calls response.SetDesiredCompositeResource, the
metadata.managedFields populated by the API server survive into the SSA patch
body, and Kubernetes rejects it:
cannot apply composite resource status: metadata.managedFields must be nil
AsStruct() (L52–76)
copies the full observed XR backing map into the RunFunctionRequest proto
without stripping managedFields. Generated ObjectMeta structs include
ManagedFields *[]ManagedFieldsEntry, so the field survives the Go struct
round-trip and reaches the
SSA patch in composition_functions.go,
where Kubernetes rejects it.
crossplane render does not populate managedFields
in the observed XR proto, so render passes while the cluster fails.
Workaround: call unstr.SetManagedFields(nil) before SetDesiredCompositeResource.
Related: crossplane/crossplane#7453
What environment did it happen in?
Crossplane version: v2.3.2, v2.3.
- Dominant language
- Go
- Stars
- 19
- Forks
- 31
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 53
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from crossplane/cli
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
crossplane/cli#282 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 52/100
crossplane/cli#384 ·
-
crossplane/cli#379 · 1 assignee ·
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 68/100
crossplane/cli#370 · 1 reaction ·
-
enhancement
Difficulty 5/5 Over a week Newbie friendliness 28/100
crossplane/cli#369 ·
Similar issues
-
bug github_actions
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
registrystack/registry-stack#1393 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
JakeChampion/lang#10213 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
oasisprotocol/oasis-sdk#2523 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100