mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-05-31 04:50:10 +08:00
scheduler: allow run container in kubelet host
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -17,6 +17,7 @@ const (
|
||||
SchedTypeKvm = "kvm"
|
||||
HostHypervisorForKvm = "hypervisor"
|
||||
HostTypeAliyun = "aliyun"
|
||||
HostTypeKubelet = "kubelet"
|
||||
|
||||
AggregateStrategyRequire = "require"
|
||||
AggregateStrategyExclude = "exclude"
|
||||
|
||||
Reference in New Issue
Block a user