-
Notifications
You must be signed in to change notification settings - Fork 40k
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
Even Pods Spread - 2. Calculating Predicates Metadata #77760
Conversation
/kind feature |
d6a656b
to
5ae8ed5
Compare
/retest |
/retest |
/retest |
} | ||
|
||
func (topologyPairsMaps *topologyPairsMaps) removePod(deletedPod *v1.Pod) { | ||
// add a topology pair holder if needed |
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.
nit: this comment should start with the function name.
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's usually tolerant for private functions.
podFullName := schedutil.GetPodFullName(pod) | ||
if topologyPairsMaps.topologyPairToPods[pair] == nil { | ||
topologyPairsMaps.topologyPairToPods[pair] = make(map[*v1.Pod]struct{}) | ||
if m.topologyPairToPods[pair] == nil { |
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.
nit: Could we replace this we addTopologyPairWithoutPods
?
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.
Done.
@@ -19,7 +19,7 @@ package predicates | |||
import ( | |||
"strings" | |||
|
|||
v1 "k8s.io/api/core/v1" |
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.
Can we revert this change since there is nothing updates else in this file and it is not a restriction that we should import without v1
prefix
@@ -21,7 +21,7 @@ import ( | |||
|
|||
"time" | |||
|
|||
v1 "k8s.io/api/core/v1" |
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.
same here
I don't think we suggested that. Only to get rid of {tpPair:podSet}. I think we should still be able to hold {podName:tpPairSet}, which can even point to the same map (same address) for all the pods in the same node. |
That's an option. Let's see how it can benefit upon eliminating {tpPair:podSet}. |
sgtm |
- build a new `topologyPairsPodSpreadMap` into PredicateMetadata - update ShallowCopy() - unit tests
- update minMatchMap from []int32 to map[string]int32
- move "chanined" utils to pkg/scheduler/testing/utils.go so as to be re-used by all scheduler tests
- see more discussion at kubernetes#77760 (comment)
/retest |
1 similar comment
/retest |
/lgtm |
@alculquicondor: changing LGTM is restricted to collaborators In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
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
Thanks for modifying it.
errCh.SendErrorWithCancel(err, cancel) | ||
return | ||
} | ||
if ok { | ||
// constraint.TopologyKey is already guaranteed to be present | ||
pair := topologyPair{key: constraint.TopologyKey, value: node.Labels[constraint.TopologyKey]} |
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.
You may also want to add that since we restrict a toplogyKey to exist in a single hard constraint, using topolgyKey as the key in this map is good enough to identify which exact constraint this pod is counted against (because otherwise the key to the map should be some sort of an identifier that combines the topologyKey and the label selector)
/hold cancel |
This PR may require API review. If so, when the changes are ready, complete the pre-review checklist and request an API review. Status of requested reviews is tracked in the API Review project. |
/retest Review the full test history for this PR. Silence the bot with an |
for _, constraint := range constraints { | ||
topologyPairsPodSpreadMap.topologyKeyToMinPodsMap[constraint.TopologyKey] = math.MaxInt32 | ||
} | ||
for pair, podSet := range topologyPairsPodSpreadMap.topologyPairToPods { |
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.
Is it possible that value of some topologyPairsPodSpreadMap.topologyKeyToMinPodsMap is
math.MaxInt32 at the end of this loop ?
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.
Nope. The logic below ensures for each tp pair, they're valued with either empty podSet, or a concrete podSet:
kubernetes/pkg/scheduler/algorithm/predicates/metadata.go
Lines 260 to 272 in 5993ec5
// If needed, append topology pair without entry of pods. | |
// For example, on node-x, there is no pod matching spread constraints, | |
// but node-x should be also considered as a match (with match number 0) | |
// i.e. <node: node-x>: {} | |
for _, constraint := range constraints { | |
// constraint.TopologyKey is already guaranteed to be present | |
pair := topologyPair{ | |
key: constraint.TopologyKey, | |
value: node.Labels[constraint.TopologyKey], | |
} | |
// addTopologyPairWithoutPods is a non-op if other pods match this pair | |
nodeTopologyMaps.addTopologyPairWithoutPods(pair) | |
} |
Then in the above loop, the default value (MaxInt32) will be compared with len(podSet), so they won't remain MaxInt32 at the end of the loop.
topologyPairsPodSpreadMap.topologyKeyToMinPodsMap[constraint.TopologyKey] = math.MaxInt32 | ||
} | ||
for pair, podSet := range topologyPairsPodSpreadMap.topologyPairToPods { | ||
// TODO(Huang-Wei): short circuit unvisited portions of <topologyKey: any value> |
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 wonder what type of short circuiting you were thinking about.
Without short circuiting, the following comparison is performed and we continue to the next pair:
l < topologyPairsPodSpreadMap.topologyKeyToMinPodsMap[pair.key]
- see more discussion at kubernetes#77760 (comment)
What type of PR is this?
/sig scheduling
/hold
/assign @bsalamat
/cc @krmayankk
What this PR does / why we need it:
This is the 2nd PR of the "Even Pods Spread" KEP implementation.
topologyPairsPodSpreadMap
into PredicateMetadataWhich issue(s) this PR fixes:
Part of #77284.
Special notes for your reviewer:
Does this PR introduce a user-facing change?:
(will document all the changes in one place)