From 7a8352ce1c014c7d944b0d6af2da027523128b73 Mon Sep 17 00:00:00 2001 From: Zexi Li Date: Mon, 30 Jul 2018 16:33:29 +0800 Subject: [PATCH] scheduler: fix specified network not enough still pass. --- pkg/scheduler/algorithm/predicates/guest/network_predicate.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/scheduler/algorithm/predicates/guest/network_predicate.go b/pkg/scheduler/algorithm/predicates/guest/network_predicate.go index 6b854cc687e..fa9e4df025d 100644 --- a/pkg/scheduler/algorithm/predicates/guest/network_predicate.go +++ b/pkg/scheduler/algorithm/predicates/guest/network_predicate.go @@ -159,6 +159,10 @@ func (p *NetworkPredicate) Execute(u *core.Unit, c core.Candidater) (bool, []cor // add resource reservedNetworks := 0 counter := counterOfNetwork(u, net, reservedNetworks) + if counter.GetCount() < d.Count { + errMsgs = append(errMsgs, fmt.Sprintf("%s: ports not enough, free: %d, required: %d", net.Name, counter.GetCount(), d.Count)) + continue + } p.SelectedNetworks.Store(net.ID, counter.GetCount()) counters.Add(counter) return ""