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

🐛 Fix AddAnnotations for unstructured.Unstructured #9164

Merged
merged 1 commit into from
Aug 14, 2023

Conversation

g-gaston
Copy link
Contributor

@g-gaston g-gaston commented Aug 10, 2023

What this PR does / why we need it:
The previous implementation worked well for most Object implementations (definitely all embedding metav1.ObjectMeta) because it relies on:

  • The fact that GetAnnotations doesn't return a copy of the annotations but the underlying map storing them.
  • When calling set annotations, the input map is used for storage in the Object implementation, hence when adding entries to that map from the outside, it changes the content of the Object's annotations.

This is not necessarily part of the contract specified by metav1.Object so we can't really guarantee all implementations will satisfy these 2 conditions. It turns out, unstructured.Unstructured doesn't.

This issue is probably and edge and hence why no one has run into it yet. But it bite me when writing some tests the other day, so probably worth fixing jic.

/area util

The previous implementation worked well for most Object implementations
(definitely all embedding metav1.ObjectMeta) because it relies on:
* The fact that GetAnnotations doesn't return a copy of the
annotations but the underlying map storing them.
* When calling set annotations, the input map is used for storage in the
  Object implementation, hence when adding entries to that map from the
  outside, it changes the content of the Object's annotations.
This is not necessarily part of the contract specified by metav1.Object
so we can't really guarantee all implementations will satisfy these 2
conditions. It turns out, unstructured.Unstructured doesn't.
@k8s-ci-robot k8s-ci-robot added the area/util Issues or PRs related to utils label Aug 10, 2023
@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Aug 10, 2023
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Aug 10, 2023
@sbueringer
Copy link
Member

sbueringer commented Aug 14, 2023

/lgtm

Thank you!

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 14, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 926634fda8145ca34783b294952b23e56e9076ff

Copy link
Contributor

@killianmuldoon killianmuldoon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

/approve

@killianmuldoon
Copy link
Contributor

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: killianmuldoon

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 14, 2023
@killianmuldoon
Copy link
Contributor

/cherry-pick release-1.5

@k8s-infra-cherrypick-robot

@killianmuldoon: once the present PR merges, I will cherry-pick it on top of release-1.5 in a new PR and assign it to you.

In response to this:

/cherry-pick release-1.5

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@killianmuldoon
Copy link
Contributor

/cherry-pick release-1.4

@k8s-infra-cherrypick-robot

@killianmuldoon: once the present PR merges, I will cherry-pick it on top of release-1.4 in a new PR and assign it to you.

In response to this:

/cherry-pick release-1.4

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-infra-cherrypick-robot

@killianmuldoon: new pull request created: #9176

In response to this:

/cherry-pick release-1.5

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-infra-cherrypick-robot

@killianmuldoon: new pull request created: #9178

In response to this:

/cherry-pick release-1.4

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/util Issues or PRs related to utils cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants