-
Notifications
You must be signed in to change notification settings - Fork 40k
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
Only expose top N images in NodeStatus
#25328
Conversation
// sort the images from max to min, and only set top N images into the node status. | ||
sort.Sort(ByImageSize(containerImages)) | ||
if maxImagesInNodeStatus < len(containerImages) { | ||
containerImages = containerImages[0 : maxImagesInNodeStatus-1] |
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.
Actually, this returns maxImagesInNodeStatus-1
images, is that what you want? @resouer
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.
Sorry, my mistake.
NodeStatus
9048885
to
d342b22
Compare
@@ -40,6 +40,22 @@ func Intn(max int) int { | |||
return rng.rand.Intn(max) | |||
} | |||
|
|||
// IntnRange generates an integer in range min->max. | |||
// By design this should panic if input is invalid, <= 0. | |||
func IntnRange(min int, max int) int { |
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.
nit: (min, max int)
LGTM. Ok to be merged once the two nits are addressed. Thanks for the PR @resouer |
Fixed rebase :) |
LGTM |
// 0 is invalid. | ||
for min, max := range map[int]int{1: 2, 10: 123, 100: 500} { | ||
inrange := IntnRange(min, max) | ||
if inrange < min || inrange > 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.
Apologies for the drive-by review, but since I'm build cop and looking for safe things to merge...
Generating a single number per test here is probably not sufficient, could take a long time to expose a problem. Suggest doing this 100+ times per test.
Second, these functions both have a bug/undocumented feature, which is that they'll never return the top number in the range. Either document or fix.
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.
Nice catch.
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.
Will fix this
updated the rand tests cc @lavalamp |
@resouer thanks for humoring me :) LGTM |
@k8s-bot test this [submit-queue is verifying that this PR is safe to merge] |
GCE e2e build/test passed for commit d917ed2. |
Automatic merge from submit-queue |
Fix #25209
Sorted the image and only pick set top 50 sized images in node status.
cc @vishh