scheduler: allow run container in kubelet host

This commit is contained in:
Zexi Li
2018-08-07 12:09:20 +08:00
parent f6b5f4f143
commit 953d77cc8e
2 changed files with 15 additions and 2 deletions

View File

@@ -2,6 +2,7 @@ package guest
import (
"github.com/yunionio/log"
"github.com/yunionio/onecloud/pkg/scheduler/algorithm/predicates"
"github.com/yunionio/onecloud/pkg/scheduler/api"
"github.com/yunionio/onecloud/pkg/scheduler/core"
@@ -35,6 +36,18 @@ func hostHasContainerTag(c core.Candidater) bool {
return false
}
func hostAllowRunContainer(c core.Candidater) bool {
hostType := c.Get("HostType")
if hostType == api.HostTypeKubelet {
return true
}
if hostHasContainerTag(c) {
log.Debugf("Host %q has %q tag, allow it run container", c.IndexKey(), CONTAINER_ALLOWED_TAG)
return true
}
return false
}
func (f *HypervisorPredicate) Execute(u *core.Unit, c core.Candidater) (bool, []core.PredicateFailureReason, error) {
h := predicates.NewPredicateHelper(f, u, c)
@@ -42,8 +55,7 @@ func (f *HypervisorPredicate) Execute(u *core.Unit, c core.Candidater) (bool, []
guestNeedType := u.SchedData().Hypervisor
if guestNeedType != hostType {
if guestNeedType == api.SchedTypeContainer && hostHasContainerTag(c) {
log.Debugf("Host %q has %q tag, allow it run container", c.IndexKey(), CONTAINER_ALLOWED_TAG)
if guestNeedType == api.SchedTypeContainer && hostAllowRunContainer(c) {
return h.GetResult()
}
h.Exclude2(f.Name(), hostType, guestNeedType)

View File

@@ -17,6 +17,7 @@ const (
SchedTypeKvm = "kvm"
HostHypervisorForKvm = "hypervisor"
HostTypeAliyun = "aliyun"
HostTypeKubelet = "kubelet"
AggregateStrategyRequire = "require"
AggregateStrategyExclude = "exclude"