fluxcd / pkg

Toolkit common packages
https://pkg.go.dev/github.com/fluxcd/pkg
Apache License 2.0
48 stars 85 forks source link

bug(ssa): allow changes to only `metadata.ownerReferences` #781

Open fs185143 opened 3 months ago

fs185143 commented 3 months ago

If an object exists on the cluster in this state:

apiVersion: policy.linkerd.io/v1alpha1
kind: NetworkAuthentication
metadata:
  name: node-network
  namespace: emissary
  ownerReferences:
    - apiVersion: someapi.io/v1
      kind: SomeResource
      name: test1
      uid: <uid>
spec:
  networks:
  - cidr: "0.0.0.0"

And I want to update it to add an additional owner reference via ssa (without changing anything else), then I should be able to update it such that it becomes:

apiVersion: policy.linkerd.io/v1alpha1
kind: NetworkAuthentication
metadata:
  name: node-network
  namespace: emissary
  ownerReferences:
    - apiVersion: someapi.io/v1
      kind: SomeResource
      name: test1
      uid: <uid>
    - apiVersion: someapi.io/v1
      kind: SomeResource
      name: test2
      uid: <uid>
spec:
  networks:
  - cidr: "0.0.0.0"

However, applying a resource via ssa (using Force: true or otherwise) where only the metadata changes causes the resource to not be patched.

I think it may be derived from this line where the metadata is removed from any comparison https://github.com/fluxcd/pkg/blob/61276f4653ac73cd09659bed20dd4e592c3f2082/ssa/manager_diff.go#L119