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

Ensure euqiv hash calculation is per schedule #59245

Merged
merged 1 commit into from
Feb 7, 2018

Conversation

resouer
Copy link
Contributor

@resouer resouer commented Feb 2, 2018

What this PR does / why we need it:

Currently, equiv hash is calculated per schedule, but also, per node. This is a potential cause of dragging integration test, see #58881

We should ensure this only happens once during scheduling of specific pod no matter how many nodes we have.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #58989

Special notes for your reviewer:

Release note:

Ensure euqiv hash calculation is per schedule

@resouer resouer added the sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. label Feb 2, 2018
@resouer resouer requested a review from bsalamat February 2, 2018 06:53
@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Feb 2, 2018
@@ -404,22 +430,18 @@ func podFitsOnNode(
ecache *EquivalenceCache,
queue SchedulingQueue,
alwaysCheckAllPredicates bool,
equivCacheInfo equivalenceClasseInfo,
Copy link
Member

Choose a reason for hiding this comment

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

I think a pointer to the struct would be better. Then you can pass nil instead of empty struct when no equivalence hash is available. eCacheAvailable should be changed to:

eCacheAvailable = equivCacheInfo != nil && equivCacheInfo.isAvailable && !podsAdded

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Aha, I was intentionally use struct to make this eCacheAvailable line here simpler, never mind, let's use pointer.

equivCacheInfo := equivalenceClasseInfo{}
if ecache != nil {
// getHashEquivalencePod will return immediately if no equivalence pod found
hash, available := ecache.getHashEquivalencePod(pod)
Copy link
Member

Choose a reason for hiding this comment

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

nit: you can directly assign to struct members.

@@ -388,6 +406,14 @@ func addNominatedPods(podPriority int32, meta algorithm.PredicateMetadata,
return true, metaOut, nodeInfoOut
}

// equivalenceClasseInfo holds information of equivalence cache for specific pod.
type equivalenceClasseInfo struct {
Copy link
Member

Choose a reason for hiding this comment

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

Is it a typo error? equivalenceClasseInfo -> equivalenceClassInfo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ack

@@ -388,7 +404,18 @@ func addNominatedPods(podPriority int32, meta algorithm.PredicateMetadata,
return true, metaOut, nodeInfoOut
}

// equivalenceClassInfo holds information of equivalence cache for specific pod.
// We will pass this to podFitsOnNode to ensure equivalence hash is only calculated per schedule.
type equivalenceClassInfo struct {
Copy link
Member

Choose a reason for hiding this comment

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

Could you please move this to equivalence_cache.go and change getHashEquivalencePod to return a pointer to this struct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed. In this case, we can use getHashEquivalencePod() return nil or not as available flag.

@@ -312,9 +312,25 @@ func findNodesThatFit(

// We can use the same metadata producer for all nodes.
meta := metadataProducer(pod, nodeNameToInfo)

equivCacheInfo := &equivalenceClassInfo{}
Copy link
Member

Choose a reason for hiding this comment

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

If you decided to follow my other suggestion, you could write this as:

var equivCacheInfo *equivalenceClassInfo
if eCached != nil {
     // getHashEquivalencePod will return immediately if no equivalence pod found
     equivCacheInfo = ecache.getHashEquivalencePod(pod)
}

@resouer
Copy link
Contributor Author

resouer commented Feb 6, 2018

kindly ping @bsalamat back for review :)

// 1. equivalenceHash
// 2. if equivalence hash is valid
func (ec *EquivalenceCache) getHashEquivalencePod(pod *v1.Pod) (uint64, bool) {
// equivalenceClassInfo holds information of equivalence cache for specific pod.
Copy link
Member

Choose a reason for hiding this comment

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

nit: equivalenceClassInfo holds equivalence hash which is used for checking equivalence cache.

@bsalamat
Copy link
Member

bsalamat commented Feb 6, 2018

LGTM. Just a nit.

@resouer
Copy link
Contributor Author

resouer commented Feb 6, 2018

nits fixed, thanks for quick response.

@bsalamat
Copy link
Member

bsalamat commented Feb 6, 2018

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 6, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bsalamat, resouer

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 6, 2018
@k8s-github-robot
Copy link

Automatic merge from submit-queue (batch tested with PRs 59394, 58769, 59423, 59363, 59245). If you want to cherry-pick this change to another branch, please follow the instructions here.

@k8s-github-robot k8s-github-robot merged commit 7223729 into kubernetes:master Feb 7, 2018
@resouer resouer deleted the equiv-node branch February 8, 2018 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hash of a pod for Equivalence Cache should be calculated once per schedule
5 participants