-
Notifications
You must be signed in to change notification settings - Fork 9
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
Optimize GetCurrentPodCount() by listing pods only once #36
Optimize GetCurrentPodCount() by listing pods only once #36
Conversation
Signed-off-by: Raul Sevilla <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #36 +/- ##
=======================================
Coverage 83.33% 83.33%
=======================================
Files 6 6
Lines 312 312
=======================================
Hits 260 260
Misses 38 38
Partials 14 14 ☔ View full report in Codecov by Sentry. |
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
podList, err := meta.clientSet.CoreV1().Pods(metav1.NamespaceAll).List(context.TODO(), metav1.ListOptions{FieldSelector: "status.phase=Running,spec.nodeName=" + node.Name}) | ||
if err != nil { | ||
return podCount, err | ||
podList, err := meta.clientSet.CoreV1().Pods(metav1.NamespaceAll).List(context.TODO(), metav1.ListOptions{FieldSelector: "status.phase=Running"}) |
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.
I am not sure on how this logic is any different from previous code. Its seems like previously code is also collecting podsCount per each node. Are we seeing any duplicate counts in the previous logic?
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.
From what I can see, with the previous code if you have 100 nodes, this will create 100 API calls... Where the code change that @rsevilla87 has will be a single API call no matter the node count then using the pod description he filters per-node. Effectively doing the same thing, but with less API calls.
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 perfect. Make sense to me now.
Type of change
Description
This simple code change boosts this function
Related Tickets & Documents
Checklist before requesting a review
Testing