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

Ability for patches within same resource to overwrite target array or map #4026

Closed
Tracked by #4047
shanproofpoint opened this issue Apr 27, 2023 · 6 comments
Closed
Tracked by #4047
Labels
enhancement New feature or request stale
Milestone

Comments

@shanproofpoint
Copy link

shanproofpoint commented Apr 27, 2023

In a composition, if there are 2 patches that contribute information to a target array or map, there should be an option to merge the results but erase what was there first. The inability to take things away from the target array or map results in the need to manually purge the attribute and wait for crossplane to repopulate. This could be nerve wracking in an emergency situation.

        - type: FromCompositeFieldPath
          fromFieldPath: spec.frontDetails.specifiedTlsCerts
          toFieldPath: spec.forProvider.sslCertificates
          policy:
            mergeOptions:
              appendSlice: true
              keepMapValues: true
              mergeOnlyForSisterPatches: true

        - type: FromCompositeFieldPath
          fromFieldPath: status.processingData.discoveredSslCerts
          toFieldPath: spec.forProvider.sslCertificates
          policy:
            mergeOptions:
              appendSlice: true
              keepMapValues: true
              mergeOnlyForSisterPatches: true

given:

  specifiedTlsCerts : [ "a", "b" ]
  discoveredTlsCerts: [ "c", d" ]

  the outcome will be [ "a", "b", "c", "d" ]

and if we later remove "c" the outcome will not change. It then becomes impossible to clean the array or map without manual intervention.

It would be preferable to have an option to have the outcome reflecting the removal of "c" in aggregate: ["a", "b", "d" ]

so some option like :

mergeOnlyForSisterPatches: true

What problem are you facing?

See above.

How could Crossplane help solve your problem?

@shanproofpoint shanproofpoint added the enhancement New feature or request label Apr 27, 2023
@chlunde
Copy link
Contributor

chlunde commented Apr 27, 2023

what happens with if you do this?

        - type: FromCompositeFieldPath
          fromFieldPath: spec.frontDetails.specifiedTlsCerts
          toFieldPath: spec.forProvider.sslCertificates

        - type: FromCompositeFieldPath
          fromFieldPath: status.processingData.discoveredSslCerts
          toFieldPath: spec.forProvider.sslCertificates
          policy:
            mergeOptions:
              keepMapValues: true

@shanproofpoint
Copy link
Author

shanproofpoint commented Apr 27, 2023

Thank you @chlunde for your suggestion! I have not tried it, but will. I assume this will successfully cleanup one contributor but leaving the cleanup of the other contributor lacking. But thank you for this partial work around , I will try it soon!

@pedjak
Copy link
Contributor

pedjak commented Jul 11, 2023

@shanproofpoint did the workaround help?

turkenh added a commit to turkenh/xp-ssa-experiments that referenced this issue Aug 24, 2023
@github-actions
Copy link

Crossplane does not currently have enough maintainers to address every issue and pull request. This issue has been automatically marked as stale because it has had no activity in the last 90 days. It will be closed in 14 days if no further activity occurs. Leaving a comment starting with /fresh will mark this issue as not stale.

@github-actions github-actions bot added the stale label Oct 10, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 24, 2023
@github-project-automation github-project-automation bot moved this from Backlog to Done in Crossplane Roadmap Oct 24, 2023
@pedjak
Copy link
Contributor

pedjak commented Dec 13, 2023

Fixed via #4896.

@pedjak pedjak closed this as completed Dec 13, 2023
@jbw976 jbw976 added this to the v1.15 milestone Dec 13, 2023
@negz
Copy link
Member

negz commented Feb 4, 2024

I'm not sure #4896 fixes this. I think this is a similar situation to the one I described in #4036 (comment). Similar to that issue, I think issue is probably syncing XR -> composed resources rather than claim -> XR. Switching to using function-patch-and-transform should fix the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request stale
Projects
Status: Done
Development

No branches or pull requests

5 participants