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

Optimize GetCurrentPodCount() by listing pods only once #36

Merged
merged 1 commit into from
Nov 29, 2023

Conversation

rsevilla87
Copy link
Member

@rsevilla87 rsevilla87 commented Nov 21, 2023

Type of change

  • Refactor
  • New feature
  • Bug fix
  • Optimization
  • Documentation Update

Description

This simple code change boosts this function

Related Tickets & Documents

  • Related Issue #
  • Closes #

Checklist before requesting a review

  • I have performed a self-review of my code.
  • If it is a core feature, I have added thorough tests.

Testing

  • Please describe the System Under Test.
  • Please provide detailed steps to perform tests related to this code change.
  • How were the fix/results from this change verified? Please provide relevant screenshots or results.

@rsevilla87 rsevilla87 added the enhancement New feature or request label Nov 21, 2023
Copy link

codecov bot commented Nov 21, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (dc2da49) 83.33% compared to head (c923ca5) 83.33%.

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.
📢 Have feedback on the report? Share it here.

Copy link
Member

@jtaleric jtaleric left a 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"})
Copy link
Collaborator

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?

Copy link
Member

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.

Copy link
Collaborator

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.

@vishnuchalla vishnuchalla merged commit d38a199 into cloud-bulldozer:main Nov 29, 2023
6 checks passed
@rsevilla87 rsevilla87 deleted the optimize-pod-count branch November 29, 2023 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants