Skip to content

feat: annotate applied manifests with parent placement name#464

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/add-annotation-to-manifest
Draft

feat: annotate applied manifests with parent placement name#464
Copilot wants to merge 2 commits intomainfrom
copilot/add-annotation-to-manifest

Conversation

Copy link
Contributor

Copilot AI commented Feb 25, 2026

Applied manifest objects on member clusters had no indication of which placement placed them. The PlacementTrackingLabel (kubernetes-fleet.io/parent-CRP) already exists on Work objects — this change propagates it as an annotation onto each applied manifest object.

Changes

  • apply.go: Added placementName string parameter to apply(); after sanitizeManifestObject, sets kubernetes-fleet.io/parent-CRP annotation on manifestObjCopy when the placement name is non-empty
  • process.go: Updated the apply() call to pass work.GetLabels()[fleetv1beta1.PlacementTrackingLabel]

Notes

  • Reuses the existing PlacementTrackingLabel constant as the annotation key — same semantic, separate map
  • The annotation is stripped by discardFieldsIrrelevantInComparisonFrom (all kubernetes-fleet.io/ keys are excluded from comparison), so it does not affect drift detection or manifest hashing
Original prompt

can you please add an annotation on the manifestObjCopy that includes the placement so we can clearly see on the member cluster which placement placed it? The placement label is on the work object so we just need to pass it down the call stack.

The user has attached the following file paths as relevant context:

  • .github/copilot-instructions.md
  • CLAUDE.md

Created from VS Code.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: ryanzhang-oss <59209500+ryanzhang-oss@users.noreply.github.com>
Copilot AI changed the title [WIP] Add annotation to manifestObjCopy for placement visibility feat: annotate applied manifests with parent placement name Feb 25, 2026
@ryanzhang-oss ryanzhang-oss requested review from Copilot and michaelawyu and removed request for michaelawyu February 27, 2026 22:57
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Propagates placement identity from Work objects down to the applied resources on member clusters by annotating each applied manifest with the parent placement name (kubernetes-fleet.io/parent-CRP), improving traceability without impacting drift detection/hashing.

Changes:

  • Pass placement name (from Work label fleetv1beta1.PlacementTrackingLabel) into the apply call path.
  • Annotate the sanitized manifest copy with the placement name before applying.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
pkg/controllers/workapplier/process.go Passes the placement tracking label value from the Work into apply() as a new argument.
pkg/controllers/workapplier/apply.go Adds a placementName parameter to apply() and sets the placement tracking annotation on the manifest being applied.

Comment on lines +88 to +97
// Add an annotation that identifies which placement placed this object, so that
// it is visible on the member cluster.
if placementName != "" {
annotations := manifestObjCopy.GetAnnotations()
if annotations == nil {
annotations = map[string]string{}
}
annotations[fleetv1beta1.PlacementTrackingLabel] = placementName
manifestObjCopy.SetAnnotations(annotations)
}
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New behavior (propagating the Work placement tracking label onto applied objects as an annotation) is introduced here, but there is no unit test covering it. Since this package already has unit tests in apply_test.go, please add a focused test to verify: (1) when placementName is non-empty, the annotation key fleetv1beta1.PlacementTrackingLabel is set on the sanitized manifest copy; and (2) when placementName is empty, no annotation is added/modified. Consider extracting the annotation injection into a small helper to make it easy to unit test without requiring dynamic client interactions.

Copilot generated this review using guidance from repository custom instructions.
@codecov
Copy link

codecov bot commented Feb 27, 2026

Codecov Report

❌ Patch coverage is 14.28571% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/controllers/workapplier/apply.go 0.00% 5 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants