-
Notifications
You must be signed in to change notification settings - Fork 39.9k
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: --chunk-size with selector returns missing result #110652
Conversation
/sig api-machinery |
/retest |
/cc @smarterclayton /cc @wojtek-t /triage accepted |
@Abirdcfly: GitHub didn't allow me to request PR reviews from the following users: focusing, that, because, it, like, are, on, I, misunderstood, function, meaning, of, you, the, original, looks, in, case. Note that only kubernetes members and repo collaborators can review this PR, and authors cannot review their own PRs. In response to this:
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. |
@@ -779,7 +779,7 @@ func growSlice(v reflect.Value, maxCapacity int, sizes ...int) { | |||
return | |||
} | |||
if v.Len() > 0 { | |||
extra := reflect.MakeSlice(v.Type(), 0, max) | |||
extra := reflect.MakeSlice(v.Type(), v.Len(), max) |
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.
This is kind of a terrifying function and it needs a bunch of unit tests. ... it looks to have been broken quite badly in ways that should cause drastic problems everywhere it's used, so either it's barely ever called, or we're reading it wrong, but either way I need to see a unit test.
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.
@logicalhan do you know anything about this function?
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.
so either it's barely ever called
I agree with this opinion. I have tested several versions and only the >= 1.24 version has errors.
The current exposure of this problem depends on #108569 code modifications and #110625 feedback. (Thanks @mborsz and @yokomotod!)
@yokomotod's test case is typical, in fact, if only some objects with the same lables were created, this problem would not be reproduced, otherwise we would not have found a problem here.
Maybe other scenarios also have the problem, but we did not find the feedback
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 you open an issue to capture these two points? (I won't block this PR on them since the bug looks disastrous)
- I am skeptical that this function is actually an improvement over just letting the go runtime pick the size. I'd like to see benchmarks with it swapped out for just calling append.
- If we do keep it, this desperately needs to be rewritten to use the new type parameters instead of reflection.
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.
Create #110734 to track these 2 points
Signed-off-by: Abirdcfly <[email protected]>
/lgtm Thanks for this fix!! Can you file the issue I mentioned above so we don't forget? |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Abirdcfly, lavalamp 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 |
…10652-upstream-release-1.24 Automated cherry pick of #110652: fix: --chunk-size with selector returns missing result
…10652-upstream-release-1.22 Automated cherry pick of #110652: fix: --chunk-size with selector returns missing result
…10652-upstream-release-1.23 Automated cherry pick of #110652: fix: --chunk-size with selector returns missing result
Thanks for the fix! |
Signed-off-by: Abirdcfly [email protected]
What type of PR is this?
/kind bug
What this PR does / why we need it:
It is easy to reproduce this bug:
I have tested several versions and only the >= 1.24 version has errors.
I found that once I revert #108569, the error disappears. 😂 This means that it is #108569 that exposes the bug.
But the version provided by the reporter is v1.23.6-gke.1700. I did not reproduce the bug in the 1.23.6 cluster created by kind.
So I think this fix should at least cherry-pick to 1.23 to help other distributions fix this issue.
Which issue(s) this PR fixes:
Fixes #110625
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: