Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tags are not being merged as expected #50

Open
jcooklin opened this issue Nov 15, 2023 · 4 comments
Open

Tags are not being merged as expected #50

jcooklin opened this issue Nov 15, 2023 · 4 comments

Comments

@jcooklin
Copy link

Given a CompositeResourceDefinition with the following property.

tags:
  x-kubernetes-map-type: granular
  additionalProperties:
    type: string
  description: Key-value map of resource tags.
  type: object

And a xr with the following field.

tags:
      my-label: test

And P&T func configured like the following

    - step: patch-and-transform
      functionRef:
        name: function-patch-and-transform
      input:
        apiVersion: pt.fn.crossplane.io/v1beta1
        kind: Resources
        resources:
          - name: my-resource
            base: <redact>
            patches:
              - type: FromCompositeFieldPath
                fromFieldPath: spec.parameters.tags
                toFieldPath: spec.initProvider.tags

The tags are being overwritten where I am expecting/hoping they will be merged.

Please advise.

@negz
Copy link
Member

negz commented Nov 15, 2023

@jcooklin You're applying the x-kubernetes-map-type: granular OpenAPI extension to the XR that is the source of the tags, right? Given that you're patching to spec.initProvider.tags I'm guessing you're patching to an MR of some kind?

Unfortunately the x-kubernetes-map-type annotation also needs to be set on that MR's CRD in order for granular merge to work. This is tracked in crossplane/upjet#300, but realistically it's something that needs to be done on a provider by provider basis.

@jcooklin
Copy link
Author

Thanks for the response @negz. The MRs are coming from upbound/provider-aws-ec2:v0.44.0-rc.1 and related family providers. Is this something that the official (AWS) providers could support?

@jcooklin
Copy link
Author

After reflecting on this more I failed to provide a crucial bit of information. In this case I was using crossplane beta render to debug the constitution of the composition before applying it and noticed that the tags were not being merged between functions.

I have a go-template function that conditionally adds resources. In the p&t function I'm applying common patchsets that include adding tags which are overriding the tags added in the previous function.

@negz in this particular case it feels like a problem that needs to be solved in the p&t function (enabling merging).

@negz
Copy link
Member

negz commented Nov 15, 2023

Is this something that the official (AWS) providers could support?

Yes absolutely. This is definitely a matter of when, not if. The team who owns that provider is pretty busy right now but I'm hoping it could be a pretty small change to add this annotation to tags specifically.

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

No branches or pull requests

2 participants