From 91fa5f8c88dde3251972d0f974186381d11d9e34 Mon Sep 17 00:00:00 2001 From: Hongchao Deng Date: Sat, 9 Jan 2016 20:03:52 -0800 Subject: [PATCH] PodFitsHostPorts: small refactor and speedup --- plugin/pkg/scheduler/algorithm/predicates/predicates.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugin/pkg/scheduler/algorithm/predicates/predicates.go b/plugin/pkg/scheduler/algorithm/predicates/predicates.go index f45c248ba61..e436e3bc25a 100644 --- a/plugin/pkg/scheduler/algorithm/predicates/predicates.go +++ b/plugin/pkg/scheduler/algorithm/predicates/predicates.go @@ -513,8 +513,11 @@ func (s *ServiceAffinity) CheckServiceAffinity(pod *api.Pod, existingPods []*api } func PodFitsHostPorts(pod *api.Pod, existingPods []*api.Pod, node string) (bool, error) { - existingPorts := getUsedPorts(existingPods...) wantPorts := getUsedPorts(pod) + if len(wantPorts) == 0 { + return true, nil + } + existingPorts := getUsedPorts(existingPods...) for wport := range wantPorts { if wport == 0 { continue