mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-17 15:13:08 +00:00
Replace PodFitsPorts with PodFitsHostPorts
This commit is contained in:
@@ -356,7 +356,7 @@ func (s *ServiceAffinity) CheckServiceAffinity(pod *api.Pod, existingPods []*api
|
||||
return affinitySelector.Matches(labels.Set(node.Labels)), nil
|
||||
}
|
||||
|
||||
func PodFitsPorts(pod *api.Pod, existingPods []*api.Pod, node string) (bool, error) {
|
||||
func PodFitsHostPorts(pod *api.Pod, existingPods []*api.Pod, node string) (bool, error) {
|
||||
existingPorts := getUsedPorts(existingPods...)
|
||||
wantPorts := getUsedPorts(pod)
|
||||
for wport := range wantPorts {
|
||||
|
@@ -244,7 +244,7 @@ func newPod(host string, hostPorts ...int) *api.Pod {
|
||||
}
|
||||
}
|
||||
|
||||
func TestPodFitsPorts(t *testing.T) {
|
||||
func TestPodFitsHostPorts(t *testing.T) {
|
||||
tests := []struct {
|
||||
pod *api.Pod
|
||||
existingPods []*api.Pod
|
||||
@@ -291,7 +291,7 @@ func TestPodFitsPorts(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
fits, err := PodFitsPorts(test.pod, test.existingPods, "machine")
|
||||
fits, err := PodFitsHostPorts(test.pod, test.existingPods, "machine")
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
|
@@ -69,11 +69,16 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
|
||||
// Do not change this JSON after 1.1 is tagged. A failure indicates backwards compatibility with 1.1 was broken.
|
||||
"1.1": {
|
||||
JSON: `{
|
||||
"priorities": [
|
||||
"predicates": [
|
||||
{"name": "PodFitsHostPorts"}
|
||||
],"priorities": [
|
||||
{"name": "SelectorSpreadPriority", "weight": 2}
|
||||
]
|
||||
}`,
|
||||
ExpectedPolicy: schedulerapi.Policy{
|
||||
Predicates: []schedulerapi.PredicatePolicy{
|
||||
{Name: "PodFitsHostPorts"},
|
||||
},
|
||||
Priorities: []schedulerapi.PriorityPolicy{
|
||||
{Name: "SelectorSpreadPriority", Weight: 2},
|
||||
},
|
||||
|
@@ -46,12 +46,15 @@ func init() {
|
||||
Weight: 1,
|
||||
},
|
||||
)
|
||||
// PodFitsPorts has been replaced by PodFitsHostPorts for better user understanding.
|
||||
// For backwards compatibility with 1.0, PodFitsPorts is regitered as well.
|
||||
factory.RegisterFitPredicate("PodFitsPorts", predicates.PodFitsHostPorts)
|
||||
}
|
||||
|
||||
func defaultPredicates() sets.String {
|
||||
return sets.NewString(
|
||||
// Fit is defined based on the absence of port conflicts.
|
||||
factory.RegisterFitPredicate("PodFitsPorts", predicates.PodFitsPorts),
|
||||
factory.RegisterFitPredicate("PodFitsHostPorts", predicates.PodFitsHostPorts),
|
||||
// Fit is determined by resource availability.
|
||||
factory.RegisterFitPredicateFactory(
|
||||
"PodFitsResources",
|
||||
|
@@ -188,7 +188,7 @@ func TestSchedulerForgetAssumedPodAfterDelete(t *testing.T) {
|
||||
|
||||
// Create the scheduler config
|
||||
algo := NewGenericScheduler(
|
||||
map[string]algorithm.FitPredicate{"PodFitsPorts": predicates.PodFitsPorts},
|
||||
map[string]algorithm.FitPredicate{"PodFitsHostPorts": predicates.PodFitsHostPorts},
|
||||
[]algorithm.PriorityConfig{},
|
||||
modeler.PodLister(),
|
||||
rand.New(rand.NewSource(time.Now().UnixNano())))
|
||||
|
Reference in New Issue
Block a user