Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion internal/sanitize/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,17 @@ func isOperationalLabel(key string) bool {
// that belongs in Git, and stripping them would silently drop a user's sync
// ordering. Hence the exact-key match.
//
// `kcp.io/cluster` is matched exactly for the same reason. kcp stamps it on every
// object to name the logical cluster the object was read from, so it is an address
// rather than intent: committed to Git it would pin a manifest to one workspace and
// travel with it into every other. Sibling `kcp.io/` keys are not assumed to be
// bookkeeping too, so this is not a prefix strip either.
//
// Exercised end-to-end against a real Argo CD in
// test/e2e/argocd_bi_directional_e2e_test.go.
func isOperationalAnnotation(key string) bool {
switch key {
case "argocd.argoproj.io/tracking-id", "argocd.argoproj.io/installation-id":
case "argocd.argoproj.io/tracking-id", "argocd.argoproj.io/installation-id", "kcp.io/cluster":
return true
}

Expand Down
25 changes: 25 additions & 0 deletions internal/sanitize/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,12 +309,37 @@ func TestCleanAnnotations(t *testing.T) {
"argocd.argoproj.io/hook": "kept",
},
},
{
// kcp names the logical cluster an object was read from. It is an address,
// not intent: in Git it would pin the manifest to one workspace and travel
// with it into every other.
name: "remove kcp logical-cluster annotation",
input: map[string]string{
"kcp.io/cluster": "root:org:team",
"user-annotation": "kept",
},
expected: map[string]string{
"user-annotation": "kept",
},
},
{
// Exact-key, not a `kcp.io/` prefix strip: sibling keys under the prefix are
// not assumed to be bookkeeping.
name: "keep other kcp annotations",
input: map[string]string{
"kcp.io/path": "kept",
},
expected: map[string]string{
"kcp.io/path": "kept",
},
},
{
name: "all annotations operational - return nil",
input: map[string]string{
"kubectl.kubernetes.io/last-applied-configuration": "removed",
"control-plane.alpha.kubernetes.io/leader": "removed",
"argocd.argoproj.io/tracking-id": "removed",
"kcp.io/cluster": "removed",
},
expected: nil,
},
Expand Down