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
Scheduler: Update the PreFilterExtensions interface to use PodInfo #97599
Merged
k8s-ci-robot
merged 1 commit into
kubernetes:master
from
gavinfish:refact-updatewithpod
Jan 20, 2021
+58
−59
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,7 @@ const ( | |
// ErrReasonExistingAntiAffinityRulesNotMatch is used for ExistingPodsAntiAffinityRulesNotMatch predicate error. | ||
ErrReasonExistingAntiAffinityRulesNotMatch = "node(s) didn't satisfy existing pods anti-affinity rules" | ||
// ErrReasonAffinityNotMatch is used for MatchInterPodAffinity predicate error. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just thinking out loud, all those comment is outdated, those should be "InterPodAffinity" instead of legacy "MatchInterPodAffinity". |
||
ErrReasonAffinityNotMatch = "node(s) didn't match pod affinity/anti-affinity" | ||
ErrReasonAffinityNotMatch = "node(s) didn't match pod affinity/anti-affinity rules" | ||
// ErrReasonAffinityRulesNotMatch is used for PodAffinityRulesNotMatch predicate error. | ||
ErrReasonAffinityRulesNotMatch = "node(s) didn't match pod affinity rules" | ||
// ErrReasonAntiAffinityRulesNotMatch is used for PodAntiAffinityRulesNotMatch predicate error. | ||
|
@@ -71,22 +71,18 @@ func (s *preFilterState) Clone() framework.StateData { | |
return © | ||
} | ||
|
||
// updateWithPod updates the preFilterState counters with the (anti)affinity matches for the given pod. | ||
func (s *preFilterState) updateWithPod(updatedPod *v1.Pod, node *v1.Node, multiplier int64) error { | ||
// updateWithPod updates the preFilterState counters with the (anti)affinity matches for the given podInfo. | ||
func (s *preFilterState) updateWithPod(updatedPodInfo *framework.PodInfo, node *v1.Node, multiplier int64) { | ||
if s == nil { | ||
return nil | ||
return | ||
} | ||
|
||
// Update matching existing anti-affinity terms. | ||
// TODO(#91058): AddPod/RemovePod should pass a *framework.PodInfo type instead of *v1.Pod. | ||
updatedPodInfo := framework.NewPodInfo(updatedPod) | ||
s.topologyToMatchedExistingAntiAffinityTerms.updateWithAntiAffinityTerms(s.podInfo.Pod, node, updatedPodInfo.RequiredAntiAffinityTerms, multiplier) | ||
|
||
// Update matching incoming pod (anti)affinity terms. | ||
s.topologyToMatchedAffinityTerms.updateWithAffinityTerms(updatedPod, node, s.podInfo.RequiredAffinityTerms, multiplier) | ||
s.topologyToMatchedAntiAffinityTerms.updateWithAntiAffinityTerms(updatedPod, node, s.podInfo.RequiredAntiAffinityTerms, multiplier) | ||
|
||
return nil | ||
s.topologyToMatchedAffinityTerms.updateWithAffinityTerms(updatedPodInfo.Pod, node, s.podInfo.RequiredAffinityTerms, multiplier) | ||
s.topologyToMatchedAntiAffinityTerms.updateWithAntiAffinityTerms(updatedPodInfo.Pod, node, s.podInfo.RequiredAntiAffinityTerms, multiplier) | ||
} | ||
|
||
// TODO(Huang-Wei): It might be possible to use "make(map[topologyPair]*int64)" so that | ||
|
@@ -279,22 +275,22 @@ func (pl *InterPodAffinity) PreFilterExtensions() framework.PreFilterExtensions | |
} | ||
|
||
// AddPod from pre-computed data in cycleState. | ||
func (pl *InterPodAffinity) AddPod(ctx context.Context, cycleState *framework.CycleState, podToSchedule *v1.Pod, podToAdd *v1.Pod, nodeInfo *framework.NodeInfo) *framework.Status { | ||
func (pl *InterPodAffinity) AddPod(ctx context.Context, cycleState *framework.CycleState, podToSchedule *v1.Pod, podInfoToAdd *framework.PodInfo, nodeInfo *framework.NodeInfo) *framework.Status { | ||
state, err := getPreFilterState(cycleState) | ||
if err != nil { | ||
return framework.NewStatus(framework.Error, err.Error()) | ||
} | ||
state.updateWithPod(podToAdd, nodeInfo.Node(), 1) | ||
state.updateWithPod(podInfoToAdd, nodeInfo.Node(), 1) | ||
return nil | ||
} | ||
|
||
// RemovePod from pre-computed data in cycleState. | ||
func (pl *InterPodAffinity) RemovePod(ctx context.Context, cycleState *framework.CycleState, podToSchedule *v1.Pod, podToRemove *v1.Pod, nodeInfo *framework.NodeInfo) *framework.Status { | ||
func (pl *InterPodAffinity) RemovePod(ctx context.Context, cycleState *framework.CycleState, podToSchedule *v1.Pod, podInfoToRemove *framework.PodInfo, nodeInfo *framework.NodeInfo) *framework.Status { | ||
state, err := getPreFilterState(cycleState) | ||
if err != nil { | ||
return framework.NewStatus(framework.Error, err.Error()) | ||
} | ||
state.updateWithPod(podToRemove, nodeInfo.Node(), -1) | ||
state.updateWithPod(podInfoToRemove, nodeInfo.Node(), -1) | ||
return nil | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
It looks like you can change
removePod
to accept a PodInfoThere 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.
also change the following to use podInfo:
potentialVictims
should be of type PodInfofilterPodsWithPDBViolation
to accept and return lists of type PodInfoaddPod
andreprievePod
to accept PodInfoThere 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.
It is fine you were planning to do that in a separate PR, but if so, please update the title and description of the PR to indicate that the goal of this PR is to update the
PreFilterExtensions
interface to use PodInfo (not reduce struct initialization).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, I am working on it locally with one failing test to investigate. Let us keep this PR small and focused.