-
Notifications
You must be signed in to change notification settings - Fork 905
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
Preserve rendered annotations & labels on composed resources #2423
Conversation
- Do not override rendered annotations or labels when patches on metadata.annotations or metadata.labels are defined - Fixes crossplane#2416 Signed-off-by: Alper Rifat Ulucinar <ulucinar@users.noreply.github.com>
cd.SetName(name) | ||
cd.SetNamespace(namespace) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ulucinar would this change mean that it is now impossible to patch over the metadata.name
and metadata.namespace
values? If so, I think this may be a breaking change that we are not willing to make. The existing behavior is desirable in cases where you want to provision a resource like a ProviderConfig
with an identifying name that is used to group all the resources in a composition: https://github.com/upbound/platform-ref-aws/blob/63e724fc104ca1147c61787acc8a2891aced0393/cluster/eks/composition.yaml#L180
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @hasheddan,
Yes it would prevent such use cases, thanks for pointing to the example use case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the second commit, we now allow such patches.
Signed-off-by: Alper Rifat Ulucinar <ulucinar@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems reasonable to me -- we are essentially mandating that our opinionated labels always be present. I would like for @negz to sign off on this though as it is somewhat subjective and I believe he originally added this functionality.
@@ -359,6 +350,17 @@ func (r *APIDryRunRenderer) Render(ctx context.Context, cp resource.Composite, c | |||
} | |||
} | |||
|
|||
// Fix(2416): composed labels and annotations should be rendered after patches are applied |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This Fix(NNNN)
practice is new to me. Do you think it's something we should adopt? Typically I've mostly trusted git to create the audit trail we need through commit messages, git blame, etc such that code can be traced back to a PR. We do specifically link to a PR or via its full URL in some cases when we feel that the reader would benefit from additional context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea is to use a concise format similar to GitHub's autolinked references to refer to a related issue (in case of a Fix
, to refer to an issue reporting a bug) in order to add some more context on the source listing itself. I think it draws attention to the specific site and warns future maintainers about a potential pitfall on the site. But we can of course embed full URLs or just leave comments (+ git blame) to achieve the same goal.
Signed-off-by: Alper Rifat Ulucinar <ulucinar@users.noreply.github.com>
Backport failed for Please cherry-pick the changes locally. git fetch origin release-1.1
git worktree add -d .worktree/backport-2423-to-release-1.1 origin/release-1.1
cd .worktree/backport-2423-to-release-1.1
git checkout -b backport-2423-to-release-1.1
ancref=$(git merge-base 1842c4bb2e1258980bca4eda43a55761fe8e19f4 e83ee5777cbc3beab66ed7422654b30a43a66592)
git cherry-pick -x $ancref..e83ee5777cbc3beab66ed7422654b30a43a66592 |
Backport failed for Please cherry-pick the changes locally. git fetch origin release-1.2
git worktree add -d .worktree/backport-2423-to-release-1.2 origin/release-1.2
cd .worktree/backport-2423-to-release-1.2
git checkout -b backport-2423-to-release-1.2
ancref=$(git merge-base 1842c4bb2e1258980bca4eda43a55761fe8e19f4 e83ee5777cbc3beab66ed7422654b30a43a66592)
git cherry-pick -x $ancref..e83ee5777cbc3beab66ed7422654b30a43a66592 |
Successfully created backport PR #2428 for |
@ulucinar it looks like we will need manual backports to |
Description of your changes
As detailed in #2416, we would like to keep any rendered annotations or labels on composed resources when patches on
metada.annotations
ormetadata.labels
are applied. Notably, if there is a patch (from composition to composed) is defined onmetadata.annotations
in the composition:and the composite has non-zero
metadata.annotations
, we lose the renderedcrossplane.io/composition-resource-name: rdsinstance
annotation on the composed.Fixes #2416
I have:
make reviewable
to ensure this PR is ready for review.backport release-x.y
labels to auto-backport this PR if necessary.How has this code been tested
With a composition specifying a patch on
metadata.annotations
(exemplified above) selected, a dynamically provisioned XR with the following annotations:now renders the following composed resource:
Without the proposed changes, it renders a composed like the following: