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

Switch to use .DeepCopy() instead of kapi.Scheme.DeepCopy() #17444

Merged
merged 3 commits into from
Nov 26, 2017

Conversation

mfojtik
Copy link
Contributor

@mfojtik mfojtik commented Nov 23, 2017

The later will not work in k8s 1.9 (@sttts to confirm). The first commit is just mechanical update.
The second commit is needed because image trigger controller used DeepCopy on interface{}.

@smarterclayton I switched that to be runtime.Object and nothing seems to be complaining. PTAL.

@openshift-ci-robot openshift-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Nov 23, 2017
@openshift-merge-robot openshift-merge-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 23, 2017
@mfojtik
Copy link
Contributor Author

mfojtik commented Nov 23, 2017

/assign sttts
/cc deads2k

Copy link
Contributor

@soltysh soltysh left a comment

Choose a reason for hiding this comment

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

lgtm

@mfojtik
Copy link
Contributor Author

mfojtik commented Nov 23, 2017

@bparees tagging you because this is interesting change and you also used DeepCopy() in many places.

@mfojtik mfojtik force-pushed the fix-deep-copy branch 3 times, most recently from e8e7b56 to eab83cc Compare November 23, 2017 17:30
@mfojtik
Copy link
Contributor Author

mfojtik commented Nov 24, 2017

/retest

for _, r := range tc.Rules {
rPtr := &r
copy := rPtr.DeepCopy()
originalRules = append(originalRules, *copy)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit:

originalRules := make([]authorizationapi.PolicyRule, len(tc.Rules))
...
rPtr.DeepCopyInto(&originalRules[i])

previousTagHistoryCopy := map[string]imageapi.TagEventList{}
for k, v := range previousTagHistory {
ptrVal := v.DeepCopy()
previousTagHistory[k] = *ptrVal
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: *v.DeepCopy()

err.Field = "spec.template." + err.Field
allErrs = append(allErrs, err)
}
templatePtr := &templateInstance.Spec.Template
Copy link
Contributor

Choose a reason for hiding this comment

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

is that Ptr var really necessary? Go should be clever enough to infer that.

return field.ErrorList{field.InternalError(field.NewPath(""), err)}
}
oldTemplateInstance := oldcopy.(*templateapi.TemplateInstance)
oldTemplateInstanceCopy := old.DeepCopyObject()
Copy link
Contributor

Choose a reason for hiding this comment

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

can old be nil?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i don't think it can be nil, but I will double check

@mfojtik
Copy link
Contributor Author

mfojtik commented Nov 24, 2017

@sttts comments addressed, thanks

continue
originalRules := make([]authorizationapi.PolicyRule, len(tc.Rules))
for i, r := range tc.Rules {
rPtr := &r
Copy link
Contributor

Choose a reason for hiding this comment

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

this line is not necessary anymore I guess.

}
err = r.ImageChanged(test.obj, fakeTagRetriever(test.tags))
initial := test.obj.DeepCopy()
err := r.ImageChanged(test.obj, fakeTagRetriever(test.tags))
Copy link
Contributor

Choose a reason for hiding this comment

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

this is odd. The r.ImageChanged func mutates test.obj?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i think the test guards against mutation (see the line below)

@mfojtik
Copy link
Contributor Author

mfojtik commented Nov 24, 2017

@sttts updated

@mfojtik
Copy link
Contributor Author

mfojtik commented Nov 24, 2017

/hold

Realized there is also kapi.Scheme.Copy()...

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 24, 2017
@openshift-ci-robot openshift-ci-robot removed the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Nov 24, 2017
@openshift-ci-robot openshift-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Nov 24, 2017
@mfojtik
Copy link
Contributor Author

mfojtik commented Nov 24, 2017

/hold cancel

@mfojtik mfojtik removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 24, 2017
@sttts
Copy link
Contributor

sttts commented Nov 24, 2017

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Nov 24, 2017
@openshift-merge-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mfojtik, sttts

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

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@mfojtik
Copy link
Contributor Author

mfojtik commented Nov 24, 2017

/retest

@0xmichalis
Copy link
Contributor

/refresh

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

8 similar comments
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-ci-robot
Copy link

openshift-ci-robot commented Nov 26, 2017

@mfojtik: The following test failed, say /retest to rerun them all:

Test name Commit Details Rerun command
ci/openshift-jenkins/extended_conformance_install_update 0b49deb link /test extended_conformance_install_update

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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. I understand the commands that are listed here.

@openshift-merge-robot
Copy link
Contributor

Automatic merge from submit-queue.

@openshift-merge-robot openshift-merge-robot merged commit 33c21b7 into openshift:master Nov 26, 2017
@mfojtik mfojtik deleted the fix-deep-copy branch September 5, 2018 21:07
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. lgtm Indicates that a PR is ready to be merged. needs-api-review size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants