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

🌱 Save a DeepCopy when patching typed objects #3628

Merged
merged 1 commit into from
Sep 14, 2020

Conversation

vincepri
Copy link
Member

When using the patch helper to patch objects, we perform lots of
DeepCopy for safety purposes. After giving a closer look, it seems we
can definitely save one deep copy when the patch helper is created and
when Patch() is invoked by checking if the incoming object is
unstructured or not.

The deep copy was previously performed because the unstructured coverter
in the runtime package returns the inner map of an unstructured object
instead of making it a copy (this isn't a bug, it's how it's meant to be
used).

Signed-off-by: Vince Prignano [email protected]

/milestone v0.3.10

@k8s-ci-robot k8s-ci-robot added this to the v0.3.10 milestone Sep 11, 2020
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Sep 11, 2020
@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Sep 11, 2020
@vincepri
Copy link
Member Author

/assign @ncdc

When using the patch helper to patch objects, we perform lots of
DeepCopy for safety purposes. After giving a closer look, it seems we
can definitely save one deep copy when the patch helper is created and
when Patch() is invoked by checking if the incoming object is
unstructured or not.

The deep copy was previously performed because the unstructured coverter
in the runtime package returns the inner map of an unstructured object
instead of making it a copy (this isn't a bug, it's how it's meant to be
used).

Signed-off-by: Vince Prignano <[email protected]>
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Sep 11, 2020
@ncdc
Copy link
Contributor

ncdc commented Sep 11, 2020

/lgtm
/assign @detiber @fabriziopandini

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 11, 2020
@fabriziopandini
Copy link
Member

lgtm for me. Good catch @vincepri
Leaving final ok to @detiber

@vincepri
Copy link
Member Author

Once this merges, I'll add tests for in the #3630 to avoid rebasing :P

@fabriziopandini
Copy link
Member

/lgtm
to unblock works on tests

@fabriziopandini
Copy link
Member

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: fabriziopandini

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 14, 2020
@vincepri
Copy link
Member Author

/test pull-cluster-api-test

@k8s-ci-robot k8s-ci-robot merged commit 8c3e0fe into kubernetes-sigs:master Sep 14, 2020
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/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants