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

🐛 DeepCopy unstructured objects in helper before patching #1464

Merged

Conversation

vincepri
Copy link
Member

@vincepri vincepri commented Sep 27, 2019

Signed-off-by: Vince Prignano vincepri@vmware.com

What this PR does / why we need it:

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #1465

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Sep 27, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: vincepri

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 Sep 27, 2019
@vincepri
Copy link
Member Author

/assign @ncdc

@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Sep 27, 2019
@ncdc
Copy link
Contributor

ncdc commented Sep 27, 2019

Would you mind opening an issue?

@vincepri
Copy link
Member Author

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 27, 2019
@vincepri
Copy link
Member Author

This might not be the issue we're seeing with @CecileRobertMichon

@vincepri vincepri changed the title 🐛 DeepCopy object before patching WIP: 🐛 DeepCopy object before patching Sep 27, 2019
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 27, 2019
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Sep 27, 2019
@vincepri vincepri changed the title WIP: 🐛 DeepCopy object before patching WIP: 🐛 DeepCopy unstructured in helper object before patching Sep 27, 2019
@vincepri vincepri force-pushed the fix-patch-external-object branch 2 times, most recently from 243b93a to e70e058 Compare September 27, 2019 19:33
@@ -138,6 +140,36 @@ func TestHelperPatch(t *testing.T) {
},
},
},
{
name: "Only add ownerref update to unstructured object",
Copy link
Contributor

Choose a reason for hiding this comment

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

This test passes even without your code change. Is that expected?

Copy link
Member Author

Choose a reason for hiding this comment

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

I added a new one that actually tests this behavior

Copy link
Member Author

Choose a reason for hiding this comment

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

(Both should be valid tests though)

resource = resource.DeepCopyObject()
}

// Convert the resource to unstructured for easier comparison later.
before, err := runtime.DefaultUnstructuredConverter.ToUnstructured(resource)
Copy link
Member

Choose a reason for hiding this comment

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

Is there a point in doing the unstructured conversion here if it is already Unstructured?

Copy link
Member Author

Choose a reason for hiding this comment

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

The ToUnstructured gets the inner .Object map of the actual object, I kept this to avoid breaking the logic

@vincepri vincepri changed the title WIP: 🐛 DeepCopy unstructured in helper object before patching 🐛 DeepCopy unstructured in helper object before patching Sep 27, 2019
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 27, 2019
@vincepri vincepri changed the title 🐛 DeepCopy unstructured in helper object before patching WIP: 🐛 DeepCopy unstructured in helper before patching Sep 27, 2019
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 27, 2019
@vincepri vincepri changed the title WIP: 🐛 DeepCopy unstructured in helper before patching WIP: 🐛 DeepCopy unstructured objects in helper before patching Sep 27, 2019
Signed-off-by: Vince Prignano <vincepri@vmware.com>
@vincepri vincepri changed the title WIP: 🐛 DeepCopy unstructured objects in helper before patching 🐛 DeepCopy unstructured objects in helper before patching Sep 27, 2019
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 27, 2019
@vincepri
Copy link
Member Author

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 27, 2019
Copy link
Contributor

@CecileRobertMichon CecileRobertMichon left a comment

Choose a reason for hiding this comment

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

lgtm

@ncdc
Copy link
Contributor

ncdc commented Sep 27, 2019

@vincepri I'm not sure this will fix patching the owner ref on the infra resource (e.g. AWSCluster)?

@vincepri
Copy link
Member Author

@ncdc This should fix the issue that external objects don't get an OwnerReference. The external objects are unstructured, which is how we found the bug in the first place.

Is there anything I missed there? 🙂

@ncdc
Copy link
Contributor

ncdc commented Sep 27, 2019

The external object ownerRef is set with r.client.Patch

@ncdc
Copy link
Contributor

ncdc commented Sep 27, 2019

Nevermind. old code locally

@vincepri
Copy link
Member Author

@ncdc
Copy link
Contributor

ncdc commented Sep 27, 2019

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 27, 2019
@k8s-ci-robot k8s-ci-robot merged commit 0ded052 into kubernetes-sigs:master Sep 27, 2019
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. 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.

OwnerReference on external cluster objects is never set
5 participants