Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

go composition function: observed XR managedFields leak into SSA status patch

オープン
#182 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
静か
技術スタック
go, kubernetes
領域
api, backend

調査の方向性

internal/xfn/utils.go、特に AsStruct() から始め、SSA ステータスパッチが構築される composition_functions.go を確認します。crossplane render と metadata.managedFields を含むクラスターのレスポンスとの差分を再現し、そのフィールドが目的の composite resource に到達する箇所を追跡します。生成された構造体のラウンドトリップによって拒否される SSA ステータスパッチが生成されなくなり、managedFields のカバレッジが追加されれば完了です。

索引モデルが issue の本文から書いたものです。

説明

bug
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.

主要言語
Go
スター
19
フォーク
31
平均マージ
2日 15時間
マージ済み PR(30日)
53

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

crossplane/cli のほかの issue

crossplane/cli の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。