-
Notifications
You must be signed in to change notification settings - Fork 63
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
deep copy slice object during append #242
Conversation
Welcome @kmala! |
Hi @kmala. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
/ok-to-test |
/assign @liggitt |
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.
Thanks, that looks good. A few comments for simplifying the test!
merge/conflict_test.go
Outdated
type args struct { | ||
sets fieldpath.ManagedFields | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
want string | ||
}{ |
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.
Since you have only on test I think it's fine to remove the table-test. Also this repo generally doesn't use that format for table-tests.
merge/conflict_test.go
Outdated
_P("spec", "template", "spec", "containers", _KBF("name", "probe"), "livenessProbe", "exec", "command"), | ||
_P("spec", "template", "spec", "containers", _KBF("name", "probe"), "livenessProbe", "periodSeconds"), | ||
_P("spec", "template", "spec", "containers", _KBF("name", "probe"), "readinessProbe", "exec", "command"), | ||
_P("spec", "template", "spec", "containers", _KBF("name", "probe"), "readinessProbe", "periodSeconds"), |
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.
Can we make these shorter? The simplest test to reproduce is usually best.
merge/conflict_test.go
Outdated
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
if got := merge.ConflictsFromManagers(tt.args.sets); !reflect.DeepEqual(got.Error(), tt.want) { |
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.
You don't need reflect.DeepEqual to compare strings.
|
merge/conflict_test.go
Outdated
@@ -92,3 +92,23 @@ func TestToSet(t *testing.T) { | |||
t.Fatalf("expected\n%v\n, but got\n%v\n", expected, actual) | |||
} | |||
} | |||
|
|||
func TestConflictsFromManagers(t *testing.T) { | |||
|
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.
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.
addressed
_P("obj", "template", "obj", "list", _KBF("name", "a"), "id"), | ||
_P("obj", "template", "obj", "list", _KBF("name", "a"), "key"), |
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.
Are these the simplest form that trigger the bug?!
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.
yes, this is the simplest which triggers the bug.
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.
@apelisse can you please review again when you get a chance
Could you explain why this PR will fix the issue. What is the cause of the issue? |
This will fix the issue because on apply this function gets called and it returns the wrong result. The cause as i mentioned in the description is because of doing shallow copy slice during iterate. |
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.
/lgtm
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: apelisse, kmala 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 |
Since p is slice, its value is changed during the tree traversal(iterate). Hence use deep copy instead.
fixes kubernetes/kubernetes#119141