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

[YUNIKORN-1842] improve updatePVCRefCounts #629

Closed
wants to merge 1 commit into from

Conversation

FrankYang0529
Copy link
Member

@FrankYang0529 FrankYang0529 commented Jul 5, 2023

What is this PR for?

In the previous version, we call updatePVCRefCounts in updateNode, updatePod, and removePod. These functions call NodeInfo.SetNode, NodeInfo.AddPod, or NodeInfo.RemovePod. All these NodeInfo functions update Generation, so I think we don't need to use pvcGeneration to determine whether we need to update pvcRefCounts. We can just give nodeInfo object to updatePVCRefCounts and update pvcRefCounts in SchedulerCache.

What type of PR is it?

  • - Bug Fix
  • - Improvement
  • - Feature
  • - Documentation
  • - Hot Fix
  • - Refactoring

Todos

  • - Task

What is the Jira issue?

https://issues.apache.org/jira/browse/YUNIKORN-1842

How should this be tested?

Add unit tests for updatePVCRefCounts

Screenshots (if appropriate)

Questions:

  • - The licenses files need update.
  • - There is breaking changes for older versions.
  • - It needs documentation.

@codecov
Copy link

codecov bot commented Jul 7, 2023

Codecov Report

Merging #629 (3b3234e) into master (9d1158a) will increase coverage by 0.23%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #629      +/-   ##
==========================================
+ Coverage   70.84%   71.07%   +0.23%     
==========================================
  Files          50       50              
  Lines        8194     8177      -17     
==========================================
+ Hits         5805     5812       +7     
+ Misses       2186     2164      -22     
+ Partials      203      201       -2     
Impacted Files Coverage Δ
pkg/cache/external/scheduler_cache.go 69.21% <100.00%> (+3.18%) ⬆️

... and 1 file with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@FrankYang0529 FrankYang0529 marked this pull request as ready for review July 7, 2023 09:56
Copy link
Contributor

@craigcondit craigcondit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nit - avoid calling node.Node().Name multiple times.

maxGeneration = node.Generation
func (cache *SchedulerCache) updatePVCRefCounts(node *framework.NodeInfo, removeNode bool) {
for k, v := range cache.pvcRefCounts {
delete(v, node.Node().Name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Save node.Node().Name to a variable at the top of the function so it can be re-used.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated it. Thank you!

Copy link
Contributor

@craigcondit craigcondit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 LGTM.

@FrankYang0529 FrankYang0529 deleted the YUNIKORN-1842 branch July 12, 2023 03:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants